{"id":24225745,"url":"https://github.com/instea/ra-cognito-auth","last_synced_at":"2025-08-10T08:33:52.034Z","repository":{"id":65331144,"uuid":"577703689","full_name":"instea/ra-cognito-auth","owner":"instea","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-20T12:24:26.000Z","size":115,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-28T01:42:28.695Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/instea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-13T10:37:34.000Z","updated_at":"2024-02-20T12:13:31.000Z","dependencies_parsed_at":"2025-06-02T22:46:18.905Z","dependency_job_id":null,"html_url":"https://github.com/instea/ra-cognito-auth","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/instea/ra-cognito-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instea%2Fra-cognito-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instea%2Fra-cognito-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instea%2Fra-cognito-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instea%2Fra-cognito-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/instea","download_url":"https://codeload.github.com/instea/ra-cognito-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instea%2Fra-cognito-auth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261494651,"owners_count":23167170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-14T08:15:53.002Z","updated_at":"2025-06-23T14:33:04.876Z","avatar_url":"https://github.com/instea.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ra-cognito-auth\n\nAWS Cognito auth provider for react-admin.\n\n## Installation\n\n```sh\nnpm install ra-cognito-auth amazon-cognito-identity-js-promises aws-jwt-verify\n```\n\n## Usage\n\n### Basic usage\n\nBuild auth provider and pass it to the react admin.\n\nExample:\n\n```js\nimport { CognitoUserPool } from 'amazon-cognito-identity-js-promises';\nimport { buildCognitoAuthProvider } from 'ra-cognito-auth';\nimport jsonServerProvider from 'ra-data-json-server';\nimport { Admin, ListGuesser, Resource } from 'react-admin';\n\nconst dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com');\n\nconst userPool: CognitoUserPool = new CognitoUserPool({\n  UserPoolId: 'myUserPool',\n  ClientId: 'myClientId',\n});\n\nconst authProvider = buildCognitoAuthProvider({ userPool });\n\nexport const App = () =\u003e (\n  \u003cAdmin dataProvider={dataProvider} authProvider={authProvider}\u003e\n    \u003cResource name=\"users\" list={ListGuesser} /\u003e\n  \u003c/Admin\u003e\n);\n```\n\nGet access token from the cognito pool to authorize api calls:\n\n```js\n// calling `getSession()` will also refresh token if needed\nconst session = await userPool.getCurrentUser()?.getSession();\nconst accessToken = session?.getAccessToken().getJwtToken();\n```\n\n### Usage with verifying JWT\n\nIf 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.\n\nExample with validating if the user has an admin group:\n\n```js\n// ...\n\nconst cognitoJwtVerifier = CognitoJwtVerifier.create({\n  tokenUse: 'access',\n  userPoolId: 'myUserPool',\n  clientId: 'myClientId',\n  groups: ['admin'],\n});\n\nconst authProvider = buildCognitoAuthProvider({ userPool, cognitoJwtVerifier });\n\n// ...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstea%2Fra-cognito-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finstea%2Fra-cognito-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstea%2Fra-cognito-auth/lists"}