{"id":15284469,"url":"https://github.com/marmelab/ra-auth-auth0","last_synced_at":"2025-04-12T23:35:29.948Z","repository":{"id":63622924,"uuid":"525392977","full_name":"marmelab/ra-auth-auth0","owner":"marmelab","description":"Auth0 / Okta auth provider for react-admin.","archived":false,"fork":false,"pushed_at":"2024-09-04T13:21:33.000Z","size":1837,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-02-07T17:12:36.756Z","etag":null,"topics":["auth0","okta","react-admin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marmelab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2022-08-16T13:31:35.000Z","updated_at":"2024-09-04T13:21:36.000Z","dependencies_parsed_at":"2024-10-14T15:01:22.136Z","dependency_job_id":"4497de51-5fc8-4ab7-9ca3-8db12078e0af","html_url":"https://github.com/marmelab/ra-auth-auth0","commit_stats":{"total_commits":42,"total_committers":5,"mean_commits":8.4,"dds":"0.40476190476190477","last_synced_commit":"58acd1a5fa2a96da16d13c20c40add612b6219b3"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelab%2Fra-auth-auth0","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelab%2Fra-auth-auth0/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelab%2Fra-auth-auth0/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelab%2Fra-auth-auth0/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marmelab","download_url":"https://codeload.github.com/marmelab/ra-auth-auth0/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239000673,"owners_count":19565831,"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":["auth0","okta","react-admin"],"created_at":"2024-09-30T14:57:07.632Z","updated_at":"2025-02-22T12:30:39.855Z","avatar_url":"https://github.com/marmelab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ra-auth-auth0\n\nAn auth provider for [react-admin](https://github.com/marmelab/react-admin) which handles authentication via a [Auth0 / Okta](https://auth0.com) instance.\n\n[![Documentation]][DocumentationLink] \n[![Source Code]][SourceCodeLink] \n\n[Documentation]: https://img.shields.io/badge/Documentation-darkgreen?style=for-the-badge\n[Source Code]: https://img.shields.io/badge/Source_Code-blue?style=for-the-badge\n\n[DocumentationLink]: ./packages/ra-auth-auth0/Readme.md 'Documentation'\n[SourceCodeLink]: https://github.com/marmelab/ra-auth-auth0/tree/main/packages/ra-auth-auth0 'Source Code'\n\nThis repository contains:\n\n-   The actual `ra-auth-auth0` package\n-   A simple demo app you can run locally to try out `ra-auth-auth0` with your own Auth0 instance\n\n## Simple Demo\n\n### Prerequesites\n\n-   You need to have a [Auth0](https://auth0.com) account\n\n### Initial setup\n\n1. Clone this project\n\nWe need to add some minimal configuration to our Auth0 instance to use it. This need to be done from the Auth0 Admin Console.\n\n1. Go to the [Auth0 Dashboard](https://manage.auth0.com/dashboard)\n1. Select your Auth0 Application (or create a new one)\n1. Add `admin@acme.com` user to your Auth0 Application. For this, you need to go to the `User Management` section and create a new user.\n1. Add `admin` to the `Roles` section of your Auth0 Application. Assign `admin@acme.com` to the `admin` role.\n1. Do the same for `user@acme.com` and the `user` role.\n1. Go to the `Applications` section of your Auth0 Application and select `Settings`\n1. Create a `single page` application with the following settings:\n    - Allowed Callback URLs: `http://127.0.0.1:8081/auth-callback`\n    - Allowed Logout URLs: `http://127.0.0.1:8081`\n    - Allowed Web Origins: `http://127.0.0.1:8081`\n    - Allowed Origins (CORS): `http://127.0.0.1:8081`\n\nIf you want to use permissions, you need to add the following to your Auth0 Application as an [`Action`](https://auth0.com/docs/manage-users/access-control/sample-use-cases-actions-with-authorization#add-user-roles-to-tokens):\n\n```JS\nexports.onExecutePostLogin = async (event, api) =\u003e {\n  const namespace = 'https://my-app.example.com';\n  if (event.authorization) {\n    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);\n    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);\n  }\n}\n```\n\nThe `authProvider` exported by this package will look for a claim that has a name with the term `role` in it and return its value.\n\nFor react-admin, you need to setup environment variables. You can do this by creating a `.env` file in the root of the project. The following variables are required:\n\n```JS\nVITE_AUTH0_DOMAIN=\"your-domain.auth0.com\"\nVITE_AUTH0_CLIENT_ID=\"your-client-id\"\nVITE_AUTH0_AUDIENCE=\"https://your-domain.auth0.com/api/v2/\" // optional but recommended for having non opaque tokens\nVITE_LOGIN_REDIRECT_URL=\"http://127.0.0.1:8081/auth-callback\"\nVITE_LOGOUT_REDIRECT_URL=\"http://127.0.0.1:8081\"\n```\n\n1. Run `make install start` to install the dependencies and start the Demo App\n\n### Using the Simple Demo\n\nNow that all is configured and running, you can browse to http://127.0.0.1:8081/ to access the React Admin App.\n\n-   Signing in with `user@acme.com` will only grant the `user` role permissions\n-   Signing in with `admin@acme.com` will grant full `admin` role permissions, allowing for instance to see the 'Users' resource in the main menu\n\nFeel free to play around with this demo, along with the Auth0 config, to understand better how it works!\n\n### JSON Server API\n\nThe demo app uses a [JSON Server](https://github.com/typicode/json-server) to provide a REST API. You can find the configuration in the `demo-fake-api` folder.\nIt shows how use middleware to validate the JWT token via the Auth0 API.\n\n## License\n\nThis repository and the code it contains are licensed under the MIT License and sponsored by [marmelab](https://marmelab.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarmelab%2Fra-auth-auth0","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarmelab%2Fra-auth-auth0","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarmelab%2Fra-auth-auth0/lists"}