Repository navigation
fix: normalize Keycloak base URL to preserve realm path - #619
Open
aryarathoree wants to merge 1 commit into
Open
aryarathoree wants to merge 1 commit into
aryarathoree wants to merge 1 commit into
Conversation
Ensure realmURL path ends with a trailing slash in NewKeycloakClientWithContext so that net/url ResolveReference does not strip the realm path segment when requesting tokens or OIDC configuration. Fixes microcks#606
aryarathoree
requested review from
Caesarsage,
Harsh4902,
lbroudoux and
yada
as code owners
November 4, 2026 12:26
Member
|
@aryarathoree Please check the DCO onec. One of the commits dosen't have sign-off. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #606
In
NewKeycloakClientWithContext, normalizeskc.BaseURLso that its path always ends with a trailing slash (/).Under RFC 3986 relative URL resolution, resolving relative endpoints like
protocol/openid-connect/tokenor.well-known/openid-configurationagainst a base path lacking a trailing slash strips the final path segment (e.g./realms/microcksbecomes/realms/protocol/openid-connect/token). This change ensures standard Keycloak realm URLs passed by direct callers preserve their realm path when constructing requests.Changes
u.Pathandu.RawPathinNewKeycloakClientWithContext(keycloak_client.go).keycloak_client_test.go:TestNewKeycloakClient_NormalizesTrailingSlash: tests various realm URL variations (with slash, without slash, root, nested subpath).TestKeycloakClient_EndpointsPreserveRealmPath: verifies thatConnectAndGetToken,GetOIDCConfig, andConnectAndGetTokenAndRefreshTokenpreserve the realm path when resolving endpoints against a realm URL that lacks a trailing slash.