{"id":13617193,"url":"https://github.com/auth0/symfony","last_synced_at":"2025-05-15T03:07:01.115Z","repository":{"id":26309608,"uuid":"29757600","full_name":"auth0/symfony","owner":"auth0","description":"Symfony SDK for Auth0 Authentication and Management APIs.","archived":false,"fork":false,"pushed_at":"2025-05-13T09:35:54.000Z","size":1432,"stargazers_count":126,"open_issues_count":3,"forks_count":73,"subscribers_count":58,"default_branch":"main","last_synced_at":"2025-05-13T09:40:44.656Z","etag":null,"topics":["dx-sdk","php","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"react-community/react-native-maps","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-23T23:07:31.000Z","updated_at":"2025-04-24T21:46:40.000Z","dependencies_parsed_at":"2024-01-17T16:17:11.924Z","dependency_job_id":"983449ac-3fe5-451a-b473-396c060fbe17","html_url":"https://github.com/auth0/symfony","commit_stats":{"total_commits":296,"total_committers":41,"mean_commits":7.219512195121951,"dds":0.7702702702702703,"last_synced_commit":"e0ccaf383b56fa16c12bd3ab0455943373b39eea"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fsymfony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fsymfony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fsymfony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fsymfony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0","download_url":"https://codeload.github.com/auth0/symfony/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264766,"owners_count":22041793,"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":["dx-sdk","php","symfony"],"created_at":"2024-08-01T20:01:38.140Z","updated_at":"2025-05-15T03:06:56.096Z","avatar_url":"https://github.com/auth0.png","language":"PHP","readme":"![auth0/symfony](https://cdn.auth0.com/website/sdks/banners/jwt-auth-bundle-banner.png)\n\nSymfony SDK for [Auth0](https://auth0.com) Authentication and Management APIs.\n\n:books: [Documentation](#documentation) - :rocket: [Getting Started](#getting-started) - :speech_balloon: [Feedback](#feedback)\n\n## Documentation\n\n- [Docs site](https://www.auth0.com/docs) — explore our docs site and learn more about Auth0.\n\n## Getting Started\n\n### Requirements\n\n- [PHP](http://php.net/) 8.1+\n- [Symfony](https://symfony.com/) 6.4 LTS or 7\n  - Symfony 7 support is community-contributed and presently experimental.\n\n\u003e Please review our [support policy](#support-policy) to learn when language and framework versions will exit support in the future.\n\n### Installation\n\nAdd the dependency to your application with [Composer](https://getcomposer.org/):\n\n```\ncomposer require auth0/symfony\n```\n\n### Configure Auth0\n\nCreate a **Regular Web Application** in the [Auth0 Dashboard](https://manage.auth0.com/#/applications). Verify that the \"Token Endpoint Authentication Method\" is set to `POST`.\n\nNext, configure the callback and logout URLs for your application under the \"Application URIs\" section of the \"Settings\" page:\n\n- **Allowed Callback URLs**: URL of your application where Auth0 will redirect to during authentication, e.g., `http://localhost:8000/callback`.\n- **Allowed Logout URLs**: URL of your application where Auth0 will redirect to after logout, e.g., `http://localhost:8000/login`.\n\nNote the **Domain**, **Client ID**, and **Client Secret**. These values will be used later.\n\n### Configure the SDK\n\nAfter installation, you should find a new file in your application, `config/packages/auth0.yaml`. If this file isn't present, please create it manually.\n\nThe following is an example configuration that will use environment variables to assign values. You should avoid storing sensitive credentials directly in this file, as it will often be committed to version control.\n\n```yaml\nauth0:\n  sdk:\n    domain: \"%env(trim:string:AUTH0_DOMAIN)%\"\n    client_id: \"%env(trim:string:AUTH0_CLIENT_ID)%\"\n    client_secret: \"%env(trim:string:AUTH0_CLIENT_SECRET)%\"\n    cookie_secret: \"%kernel.secret%\"\n\n    # custom_domain: \"%env(trim:string:AUTH0_CUSTOM_DOMAIN)%\"\n\n    # audiences:\n    #  - \"%env(trim:string:AUTH0_API_AUDIENCE)%\"\n\n    # token_cache: cache.auth0_token_cache\n    # management_token_cache: cache.auth0_management_token_cache\n\n    scopes:\n      - openid\n      - profile\n      - email\n      - offline_access\n\n  authenticator:\n    routes:\n      callback: \"%env(string:AUTH0_ROUTE_CALLBACK)%\"\n      success: \"%env(string:AUTH0_ROUTE_SUCCESS)%\"\n      failure: \"%env(string:AUTH0_ROUTE_FAILURE)%\"\n      login: \"%env(string:AUTH0_ROUTE_LOGIN)%\"\n      logout: \"%env(string:AUTH0_ROUTE_LOGOUT)%\"\n```\n\n### Configure your `.env` file\n\nCreate or open a `.env.local` file within your application directory, and add the following lines:\n\n```ini\n#\n# ↓ Refer to your Auth0 application details (https://manage.auth0.com/#/applications) for these values.\n#\n\n# Your Auth0 application domain\nAUTH0_DOMAIN=...\n\n# Your Auth0 application client ID\nAUTH0_CLIENT_ID=...\n\n# Your Auth0 application client secret\nAUTH0_CLIENT_SECRET=...\n\n# Optional. Your Auth0 custom domain, if you have one. (https://manage.auth0.com/#/custom_domains)\nAUTH0_CUSTOM_DOMAIN=...\n\n# Optional. Your Auth0 API identifier/audience, if used. (https://manage.auth0.com/#/apis)\nAUTH0_API_AUDIENCE=...\n\n#\n# ↓ These routes will be used by the SDK to direct traffic during authentication.\n#\n\n# The route that SDK will redirect to after authentication:\nAUTH0_ROUTE_CALLBACK=callback\n\n# The route that will trigger the authentication process:\nAUTH0_ROUTE_LOGIN=login\n\n# The route that the SDK will redirect to after a successful authentication:\nAUTH0_ROUTE_SUCCESS=private\n\n# The route that the SDK will redirect to after a failed authentication:\nAUTH0_ROUTE_FAILURE=public\n\n# The route that the SDK will redirect to after a successful logout:\nAUTH0_ROUTE_LOGOUT=public\n```\n\nPlease ensure this `.env.local` file is included in your `.gitignore`. It should never be committed to version control.\n\n### Configure your `security.yaml` file\n\nOpen your application's `config/packages/security.yaml` file, and update it based on the following example:\n\n```yaml\nsecurity:\n  providers:\n    auth0_provider:\n      id: Auth0\\Symfony\\Security\\UserProvider\n\n  firewalls:\n    auth0:\n      pattern: ^/private$ # A pattern example for stateful (session-based authentication) route requests\n      provider: auth0_provider\n      custom_authenticators:\n        - auth0.authenticator\n    api:\n      pattern: ^/api # A pattern example for stateless (token-based authorization) route requests\n      stateless: true\n      provider: auth0_provider\n      custom_authenticators:\n        - auth0.authorizer\n    dev:\n      pattern: ^/(_(profiler|wdt)|css|images|js)/\n      security: false\n    main:\n      lazy: true\n\n  access_control:\n    - { path: ^/api$, roles: PUBLIC_ACCESS } # PUBLIC_ACCESS is a special role that allows everyone to access the path.\n    - { path: ^/api/scoped$, roles: ROLE_USING_TOKEN } # The ROLE_USING_TOKEN role is added by the Auth0 SDK to any request that includes a valid access token.\n    - { path: ^/api/scoped$, roles: ROLE_READ_MESSAGES } # This route will expect the given access token to have the `read:messages` scope in order to access it.\n```\n\n### Update your `config/bundle.php`\n\nThe SDK bundle should be automatically detected and registered by [Symfony Flex](https://symfony.com/doc/current/setup.html#symfony-flex) projects, but you may need to add the Auth0Bundle to your application's bundle registry. Either way, it's a good idea to register the bundle anyway, just to be safe.\n\n```php\n\u003c?php\n\nreturn [\n    /*\n     * Leave any existing entries in this array as they are.\n     * You should just append this line to the end:\n     */\n\n    Auth0\\Symfony\\Auth0Bundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n### Optional: Add Authentication helper routes\n\nThe SDK includes a number of pre-built HTTP controllers that can be used to handle authentication. These controllers are not required, but can be helpful in getting started. In many cases, these may provide all the functionality you need to integrate Auth0 into your application, providing a plug-and-play solution.\n\nTo use these, open your application's `config/routes.yaml` file, and add the following lines:\n\n```yaml\nlogin: # Send the user to Auth0 for authentication.\n  path: /login\n  controller: Auth0\\Symfony\\Controllers\\AuthenticationController::login\n\ncallback: # This user will be returned here from Auth0 after authentication; this is a special route that completes the authentication process. After this, the user will be redirected to the route configured as `AUTH0_ROUTE_SUCCESS` in your .env file.\n  path: /callback\n  controller: Auth0\\Symfony\\Controllers\\AuthenticationController::callback\n\nlogout: # This route will clear the user's session and return them to the route configured as `AUTH0_ROUTE_LOGOUT` in your .env file.\n  path: /logout\n  controller: Auth0\\Symfony\\Controllers\\AuthenticationController::logout\n```\n\n### Recommended: Configure caching\n\nThe SDK provides two caching properties in it's configuration: `token_cache` and `management_token_cache`. These are compatible with any PSR-6 cache implementation, of which Symfony offers several out of the box.\n\nThese are used to store JSON Web Key Sets (JWKS) results for validating access token signatures and generated management API tokens, respectively. We recommended configuring this feature to improve your application's performance by reducing the number of network requests the SDK needs to make. It will also greatly help in avoiding hitting rate-limiting conditions, if you're making frequent Management API requests.\n\nThe following is an example `config/packages/cache.yaml` file that would configure the SDK to use a Redis backend for caching:\n\n```yaml\nframework:\n  cache:\n    prefix_seed: auth0_symfony_sample\n\n    app: cache.adapter.redis\n    default_redis_provider: redis://localhost\n\n    pools:\n      auth0_token_cache: { adapter: cache.adapter.redis }\n      auth0_management_token_cache: { adapter: cache.adapter.redis }\n```\n\nPlease review [the Symfony cache documentation](https://symfony.com/doc/current/components/cache.html#cache-component-psr6-caching) for adapter-specific configuration options. Please note that the SDK does not currently support Symfony's \"Cache Contract\" adapter type.\n\n### Example: Retrieving the User\n\nThe following example shows how to retrieve the authenticated user within a controller. For this example, we'll create a mock `ExampleController` class that is accessible from a route at `/private`.\n\nAdd a route to your application's `config/routes.yaml` file:\n\n```yaml\nprivate:\n  path: /private\n  controller: App\\Controller\\ExampleController::private\n```\n\nNow update or create a `src/Controller/ExampleController.php` class to include the following code:\n\n```php\n\u003c?php\n\nnamespace App\\Controller;\n\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\n\nclass ExampleController extends AbstractController\n{\n    public function private(): Response\n    {\n        return new Response(\n            '\u003chtml\u003e\u003cbody\u003e\u003cpre\u003e' . print_r($this-\u003egetUser(), true) . '\u003c/pre\u003e \u003ca href=\"/logout\"\u003eLogout\u003c/a\u003e\u003c/body\u003e\u003c/html\u003e'\n        );\n    }\n}\n```\n\nIf you visit the `/private` route in your browser, you should see the authenticated user's details. If you are not already authenticated, you will be redirected to the `/login` route to login, and then back to `/private` afterward.\n\n## Support Policy\n\nOur support windows are determined by the [Symfony release support](https://symfony.com/doc/current/contributing/community/releases.html#maintenance) and [PHP release support](https://www.php.net/supported-versions.php) schedules, and support ends when either the Symfony framework or PHP runtime outlined below stop receiving security fixes, whichever may come first.\n\n| SDK Version | Symfony Version | PHP Version | Support Ends |\n| ----------- | --------------- | ----------- | ------------ |\n| 5.3         | 7.0\\*           | 8.2         | Jul 31 2024  |\n| 5           | 6.2             | 8.2         | Jul 31 2023  |\n|             |                 | 8.1         | Jul 31 2023  |\n|             | 6.1             | 8.2         | Jan 31 2023  |\n|             |                 | 8.1         | Jan 31 2023  |\n\nDeprecations of EOL'd language or framework versions are not considered a breaking change, as Composer handles these scenarios elegantly. Legacy applications will stop receiving updates from us, but will continue to function on those unsupported SDK versions.\n\n\u003e _Note:_\n\u003e We do not currently support Symfony LTS versions, but anticipate adding support for this when Symfony's 6.x branch enters it's LTS window.\n\n\u003e _Note:_\n\u003e Symfony 7 support is community-contributed, and currently considered experimental.\n\n## Feedback\n\n### Contributing\n\nWe appreciate feedback and contribution to this repo! Before you get started, please see the following:\n\n- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)\n- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)\n\n### Raise an issue\n\nTo provide feedback or report a bug, [please raise an issue on our issue tracker](https://github.com/auth0/symfony/issues).\n\n### Vulnerability Reporting\n\nPlease do not report security vulnerabilities on the public Github issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\"\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png\" width=\"150\"\u003e\n    \u003cimg alt=\"Auth0 Logo\" src=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eAuth0 is an easy to implement, adaptable authentication and authorization platform.\u003cbr /\u003eTo learn more checkout \u003ca href=\"https://auth0.com/why-auth0\"\u003eWhy Auth0?\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eThis project is licensed under the MIT license. See the \u003ca href=\"./LICENSE\"\u003e LICENSE\u003c/a\u003e file for more info.\u003c/p\u003e\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fsymfony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0%2Fsymfony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fsymfony/lists"}