Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
oidc-jwt-client
Advanced tools
Fetch JWTs for API access from oidc-jwt-provider
npm install oidc-jwt-client --save
<OidcJwtProvider
client={{ url: 'https://api-auth.acc.titan.awssdu.nl' }}
shouldAttemptLogin={false}
shouldMonitorAccessTokens={false}
>
// Contents of your app
</OidcJwtProvider>
Within the provider we make use of several hooks to use the functionality exposed within the context.
The accessToken is directly returned from the fetchAccessToken function when already present and valid. If not it will automatically fetch a new accessToken for you.
To get the accessToken you can do this:
const [token, setToken] = useState<null | string>(null);
const fetchAccessToken = useAuthAccessToken();
useEffect(() => {
fetchAccessToken().then((token) => {
setToken(token);
});
}, [fetchAccessToken, setToken]);
To login or logout a user manually you can make use of these two function exposed by the useAuthControls hook:
const { authorize, logout } = useAuthControls();
const onClickLogout = React.useCallback(() => {
logout();
}, [logout]);
const onClickLogin = React.useCallback(() => {
authorize();
}, [authorize]);
To get the user info you can do this within the context of the provider:
const userInfo = useAuthUserInfo();
console.log('This is the userInfo: ', userInfo)
To get the claims you can do this within the context of the provider:
const claims = useAuthAccessClaims();
console.log('This are the claims: ', claims)
To check if there is a session and for example show a loader when there's not yet one:
const sessionInfo = useAuthSessionInfo();
console.log('There is a session started: ', sessionInfo.hasSession)
FAQs
Fetch JWTs for API access from oidc-jwt-provider
The npm package oidc-jwt-client receives a total of 95 weekly downloads. As such, oidc-jwt-client popularity was classified as not popular.
We found that oidc-jwt-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.