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.
ra-cognito-auth
Advanced tools
AWS Cognito auth provider for react-admin.
npm install ra-cognito-auth amazon-cognito-identity-js-promises aws-jwt-verify
Build auth provider and pass it to the react admin.
Example:
import { CognitoUserPool } from 'amazon-cognito-identity-js-promises';
import { buildCognitoAuthProvider } from 'ra-cognito-auth';
import jsonServerProvider from 'ra-data-json-server';
import { Admin, ListGuesser, Resource } from 'react-admin';
const dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com');
const userPool: CognitoUserPool = new CognitoUserPool({
UserPoolId: 'myUserPool',
ClientId: 'myClientId',
});
const authProvider = buildCognitoAuthProvider({ userPool });
export const App = () => (
<Admin dataProvider={dataProvider} authProvider={authProvider}>
<Resource name="users" list={ListGuesser} />
</Admin>
);
Get access token from the cognito pool to authorize api calls:
// calling `getSession()` will also refresh token if needed
const session = await userPool.getCurrentUser()?.getSession();
const accessToken = session?.getAccessToken().getJwtToken();
If you would like to verify the JWT instead of just checking the validity of the session, pass a configured cognito jwt verifier to the build function. The JWT token from the session is then verified against the verifier during the checkAuth method of the provider.
Example with validating if the user has an admin group:
// ...
const cognitoJwtVerifier = CognitoJwtVerifier.create({
tokenUse: 'access',
userPoolId: 'myUserPool',
clientId: 'myClientId',
groups: ['admin'],
});
const authProvider = buildCognitoAuthProvider({ userPool, cognitoJwtVerifier });
// ...
FAQs
Cognito auth provider for react-admin
We found that ra-cognito-auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.