{"id":23376233,"url":"https://github.com/trustedshops-public/spring-boot-starter-keycloak-path-based-resolver","last_synced_at":"2026-04-28T11:02:29.175Z","repository":{"id":61409570,"uuid":"524078409","full_name":"trustedshops-public/spring-boot-starter-keycloak-path-based-resolver","owner":"trustedshops-public","description":"Spring Boot Starter making it easy to work with path based keycloak configuration","archived":false,"fork":false,"pushed_at":"2025-04-07T02:04:04.000Z","size":111,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T03:22:09.308Z","etag":null,"topics":["keycloak","spring-boot","spring-boot-starter","spring-starters","tslibraries"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/trustedshops-public.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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":"2022-08-12T12:25:53.000Z","updated_at":"2022-10-12T20:35:42.000Z","dependencies_parsed_at":"2024-04-16T00:31:41.781Z","dependency_job_id":"f613eeda-bed1-4e04-ac0f-0b737179275f","html_url":"https://github.com/trustedshops-public/spring-boot-starter-keycloak-path-based-resolver","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trustedshops-public%2Fspring-boot-starter-keycloak-path-based-resolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trustedshops-public%2Fspring-boot-starter-keycloak-path-based-resolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trustedshops-public%2Fspring-boot-starter-keycloak-path-based-resolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trustedshops-public%2Fspring-boot-starter-keycloak-path-based-resolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trustedshops-public","download_url":"https://codeload.github.com/trustedshops-public/spring-boot-starter-keycloak-path-based-resolver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773744,"owners_count":20993633,"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":["keycloak","spring-boot","spring-boot-starter","spring-starters","tslibraries"],"created_at":"2024-12-21T17:34:53.594Z","updated_at":"2026-04-28T11:02:24.139Z","avatar_url":"https://github.com/trustedshops-public.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"spring-boot-starter-keycloak-path-based-resolver\n===\n\n[![CircleCI Build Status](https://circleci.com/gh/trustedshops-public/spring-boot-starter-keycloak-path-based-resolver.svg?style=shield \"CircleCI Build Status\")](https://circleci.com/gh/trustedshops-public/spring-boot-starter-keycloak-path-based-resolver)\n[![GitHub License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/trustedshops-public/spring-boot-starter-keycloak-path-based-resolver/blob/main/LICENSE)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=trustedshops-public_spring-boot-starter-keycloak-path-based-resolver\u0026metric=security_rating)](https://sonarcloud.io/summary/new_code?id=trustedshops-public_spring-boot-starter-keycloak-path-based-resolver)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=trustedshops-public_spring-boot-starter-keycloak-path-based-resolver\u0026metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=trustedshops-public_spring-boot-starter-keycloak-path-based-resolver)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=trustedshops-public_spring-boot-starter-keycloak-path-based-resolver\u0026metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=trustedshops-public_spring-boot-starter-keycloak-path-based-resolver)\n[![Maven Central Version](https://maven-badges.herokuapp.com/maven-central/io.github.trustedshops-public/spring-boot-starter-keycloak-path-based-resolver/badge.svg)](https://search.maven.org/search?q=g:io.github.trustedshops-public%20AND%20a:spring-boot-starter-keycloak-path-based-resolver\u0026core=gav)\n[![codecov](https://codecov.io/github/trustedshops-public/spring-boot-starter-keycloak-path-based-resolver/branch/main/graph/badge.svg?token=H1AoyyjEdy)](https://codecov.io/github/trustedshops-public/spring-boot-starter-keycloak-path-based-resolver)\n\nSpring Boot Starter making it easy to use multiple Keycloak contexts for different parts of your service.\n\n## Usage\n\n### 1. Add to your dependencies\n\n\u003e As the starter adds **no dependencies**\n\u003e for [Spring Boot Security Starter](https://spring.io/guides/gs/securing-web/#initial)\n\u003e or [Keycloak Spring Boot Starters](https://www.keycloak.org/docs/latest/securing_apps/#_spring_boot_adapter)\n\u003e make sure to include them separately in your project.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.trustedshops-public\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-starter-keycloak-path-based-resolver\u003c/artifactId\u003e\n    \u003cversion\u003e${spring-boot-starter.keycloak-path-based-resolver.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### 2. Configure\n\nThe starter supports to ways of configuring:\n\n- using code - some kind of DSL\n- using spring properties\n\nWe strongly recommend using properties since it is less effort and more predictable.\n\n#### 2.1 Configure with config properties\n\n##### YAML\n\n```yaml\nkeycloak-path-based-resolve:\n   contexts:\n     b2b:\n       auth-server-url: https://my-auth-server.url/auth\n       realm: b2b\n       resource: b2b-billing-api\n       public-client: false\n       bearer-only: true\n     b2c:\n       auth-server-url: https://my-auth-server.url/auth\n       realm: b2c\n       resource: b2c-billing-api\n       public-client: false\n       bearer-only: true\n   mappings:\n     - ant-matcher:\n         - /b2b/**\n       context: b2b\n     - ant-matcher:\n         - /b2c/**\n       context: b2c\n```\n\n##### Properties\n\n```properties\nkeycloak-path-based-resolve.contexts.b2b.auth-server-url=https://my-auth-server.url/auth\nkeycloak-path-based-resolve.contexts.b2b.realm=b2b\nkeycloak-path-based-resolve.contexts.b2b.resource=b2b-billing-api\nkeycloak-path-based-resolve.contexts.b2b.public-client=false\nkeycloak-path-based-resolve.contexts.b2b.bearer-only=true\nkeycloak-path-based-resolve.contexts.b2c.auth-server-url=https://my-auth-server.url/auth\nkeycloak-path-based-resolve.contexts.b2c.realm=b2c\nkeycloak-path-based-resolve.contexts.b2c.resource=b2c-billing-api\nkeycloak-path-based-resolve.contexts.b2c.public-client=false\nkeycloak-path-based-resolve.contexts.b2c.bearer-only=true\nkeycloak-path-based-resolve.mappings.0.ant-matcher=[/b2b/**]\nkeycloak-path-based-resolve.mappings.0.context=b2b\nkeycloak-path-based-resolve.mappings.1.ant-matcher=[/b2c/**]\nkeycloak-path-based-resolve.mappings.1.context=b2c\n```\n\n#### 2.2 Configure with code\n\n##### Configure with Kotlin\n\n````kotlin\nclass KeycloakPathBasedContextResolverImpl : KeycloakPathBasedContextResolver {\n    private fun createKeycloakConfig(realm: String, client: String): KeycloakDeployment {\n        val config = AdapterConfig()\n        config.authServerUrl = \"https://my-auth-sever.url\"\n        config.realm = realm\n        config.resource = client\n        config.isBearerOnly = true\n        config.isPublicClient = false\n        return KeycloakDeploymentBuilder.build(config)\n    }\n\n    override fun configure(configuration: KeycloakPathContextConfigurationHolder) {\n        configuration\n            .antMatchers(\"/b2b/**\")\n            .useKeycloakDeployment(createKeycloakConfig(\"b2b\", \"b2b-billing-api\"))\n            .antMatchers(\"/b2c/**\")\n            .useKeycloakDeployment(createKeycloakConfig(\"b2c\", \"b2c-billing-api\"))\n    }\n}\n````\n\n##### Configure with Java\n\n```java\nclass KeycloakPathBasedContextResolverImpl implements KeycloakPathBasedContextResolver {\n    private KeycloakDeployment createKeycloakConfig(String realm, String client) {\n        AdapterConfig config = new AdapterConfig();\n        config.setAuthServerUrl(\"https://my-auth-sever.url\");\n        config.setRealm(realm);\n        config.setResource(client);\n        config.setPublicClient(false);\n        config.setBearerOnly(true);\n        return KeycloakDeploymentBuilder.build(config);\n    }\n\n    @Override\n    public void configure(KeycloakPathContextConfigurationHolder configuration) {\n        configuration\n                .antMatchers(\"/b2b/**\")\n                .useKeycloakDeployment(createKeycloakConfig(\"b2b\", \"b2b-billing-api\"))\n                .antMatchers(\"/b2c/**\")\n                .useKeycloakDeployment(createKeycloakConfig(\"b2c\", \"b2c-billing-api\"));\n    }\n}\n```\n\n## Notes about implementation\n\n- Ant matchers are sorted by length\n    - longest matcher is checked first\n    - first matcher that gives a positive result wins\n- DSL / Property files can in theory be used together but is strongly discouraged and not officially supported\n- Contains no additional automatic dependencies avoiding version locks in most cases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrustedshops-public%2Fspring-boot-starter-keycloak-path-based-resolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrustedshops-public%2Fspring-boot-starter-keycloak-path-based-resolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrustedshops-public%2Fspring-boot-starter-keycloak-path-based-resolver/lists"}