{"id":22859198,"url":"https://github.com/el-abdel/abelkeycloakbeareronlyadapterbundle","last_synced_at":"2025-04-30T17:44:19.944Z","repository":{"id":41976831,"uuid":"314271526","full_name":"el-abdel/ABELkeycloakBearerOnlyAdapterBundle","owner":"el-abdel","description":"[Symfony Bundle]: Keycloak security adapter for bearer-only clients","archived":false,"fork":false,"pushed_at":"2023-02-20T13:31:49.000Z","size":89,"stargazers_count":4,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T18:23:53.150Z","etag":null,"topics":["api","authentication","hacktoberfest","keycloak","oauth","security","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/el-abdel.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":"Security/Authenticator/KeycloakBearerAuthenticator.php","support":null}},"created_at":"2020-11-19T14:24:13.000Z","updated_at":"2024-01-20T14:59:23.000Z","dependencies_parsed_at":"2022-08-26T23:40:47.507Z","dependency_job_id":null,"html_url":"https://github.com/el-abdel/ABELkeycloakBearerOnlyAdapterBundle","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el-abdel%2FABELkeycloakBearerOnlyAdapterBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el-abdel%2FABELkeycloakBearerOnlyAdapterBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el-abdel%2FABELkeycloakBearerOnlyAdapterBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el-abdel%2FABELkeycloakBearerOnlyAdapterBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/el-abdel","download_url":"https://codeload.github.com/el-abdel/ABELkeycloakBearerOnlyAdapterBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251753690,"owners_count":21638367,"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":["api","authentication","hacktoberfest","keycloak","oauth","security","symfony","symfony-bundle"],"created_at":"2024-12-13T09:06:24.705Z","updated_at":"2025-04-30T17:44:19.916Z","avatar_url":"https://github.com/el-abdel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"ABELkeycloakBearerOnlyAdapterBundle\n===================================\n\nThis Symfony bundle is an adapter that allows securing API using keycloak Bearer Only clients.\n\n## Installation\n\n\u003e Befor installing the bundle, automatic packages configuration can be activated with the following command:\n\u003e ```\n\u003e composer config extra.symfony.allow-contrib true\n\u003e ```\n\nWith composer:\n\n```\ncomposer require abel/keycloak-bearer-only-adapter-bundle\n```\n\n## Configuration\n\nIf you want to set up keycloak locally you can download it [here](https://www.keycloak.org/downloads) and follow instructions from [the official documentation](https://www.keycloak.org/docs/latest/server_installation/index.html).\n\n### Bundle configuration\n\n#### Via a recipe (Automatic)\nThis bundle hase a Symfony recipe that allow the automation of configuration via the Symfony Flex Composer plugin.\nTo enable recipe for your project, run the following command:\n\n```\ncomposer config extra.symfony.allow-contrib true\n```\n\n#### Manual\nHaving a running keycloak locally or in Docker and already configured a client with **Access Type = bearer-only**\nhere is the configuration to use:\n\n```yaml\n# config/packages/abel_keycloak_bearer_only_adapter.yaml\nabel_keycloak_bearer_only_adapter:\n    issuer: '%env(OAUTH_KEYCLOAK_ISSUER)%' # your accessible keycloak url\n    realm: '%env(OAUTH_KEYCLOAK_REALM)%' # your keycloak realm name\n    client_id: '%env(OAUTH_KEYCLOAK_CLIENT_ID)%' # your keycloak client id\n    client_secret: '%env(OAUTH_KEYCLOAK_CLIENT_SECRET)%' # your keycloak client secret\n    #ssl_verification: False # by default ssl_verification is set to False\n```\nThe best practice is to load your configuration from **.env** file.\n\n```\n# .env\n...\n###\u003e Abel_keycloak_bearer_only_adapter ###\nOAUTH_KEYCLOAK_ISSUER=keycloak:8080\nOAUTH_KEYCLOAK_REALM=my_realm\nOAUTH_KEYCLOAK_CLIENT_ID=my_bearer_client\nOAUTH_KEYCLOAK_CLIENT_SECRET=my_bearer_client_secret\n###\u003c Abel_keycloak_bearer_only_adapter ###\n...\n```\n\u003e Since Keycloak 17 the default distribution is now powered by **Quarkus**, while the legacy **WildFly** powered distribution will still be around until June 2022 \u003cbr\u003e\n\u003e The new distribution introduces a number of breaking changes, including: \u003cbr\u003e\n\u003e - `/auth` removed from the default context path \u003cbr\u003e\n\u003e ⚠️ **If you are using a legacy version make sure to include /auth in OAUTH_KEYCLOAK_ISSUER** \u003cbr\u003e\n\u003e Example: `keycloak:8080/auth`\n\nIn case of using Keycloak with Docker locally replace **issuer** value with your keycloak container reference in the network\n\nFor example, you can use the service name, or container IPAdresse that you can get using this command:\n\n```\ndocker inspect \u003ccontainer id\u003e | grep \"IPAddress\"\n```\n### Symfony security configuration\n\nTo secure your API with Keycloak you must change the default security configuration in symfony.\n\nHere is a simple configuration that restrict access to ```/api/*``` routes only to user with role **ROLE_API** :\n\n```yaml\n# config/packages/security.yaml\nsecurity:\n    enable_authenticator_manager: true\n    providers:\n        keycloak_bearer_user_provider:\n            id: ABEL\\Bundle\\keycloakBearerOnlyAdapterBundle\\Security\\User\\KeycloakBearerUserProvider\n    firewalls:\n        dev:\n            pattern: ^/(_(profiler|wdt)|css|images|js)/\n            security: false\n        api:\n            pattern: ^/api/\n            provider: keycloak_bearer_user_provider\n            custom_authenticators:\n              - ABEL\\Bundle\\keycloakBearerOnlyAdapterBundle\\Security\\Authenticator\\KeycloakBearerAuthenticator\n            stateless: true\n    access_control:\n        - { path: ^/api/, roles: ROLE_API }\n```\n\u003e :information_source: Referring to Symfony [documentation](https://symfony.com/doc/5.3/security.html#roles), roles must start with **ROLE_** (otherwise, things won't work as expected)\n### Keycloak configuration\n\nTo configure keycloak to work with this bundle, [here](./Resources/docs/keycloak-config-guide.md) is a step by step documentation for a basic configuration of keycloak.\n\n### Compatibility\n\n\n| Bundle Version                                        | Symfony Version    |\n| ------------------------------------------------------|--------------------|\n| V1.0.1                                                | \u003e=4.0.0   \u003c5.0.0   |\n| V1.1.* (uses old authentication systeme with guard)   | \u003e=5.0.0   \u003c6.0.0   |\n| V1.2.* (uses new authentication systeme)              | \u003e=5.3.0   \u003c6.0.0   |\n| V1.3.*                                                | \u003e=6.0.0   \u003c7.0.0   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fel-abdel%2Fabelkeycloakbeareronlyadapterbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fel-abdel%2Fabelkeycloakbeareronlyadapterbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fel-abdel%2Fabelkeycloakbeareronlyadapterbundle/lists"}