enable integration with external keycloak clients#1252
Open
GalMunGral wants to merge 3 commits into
Open
Conversation
Restore original /token endpoint unchanged. Add /token/external that accepts optional client_id, redirect_uri, server_url, realm_name, and client_secret_key, falling back to Clowder's own settings for any omitted params. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drop /token/external — the same Keycloak client supports multiple redirect URIs, so only redirect_uri needs to vary per caller. get_token now takes only redirect_uri as an override, using the module-level keycloak_openid instance directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
longshuicy
approved these changes
Jun 11, 2026
longshuicy
left a comment
Member
There was a problem hiding this comment.
The /token endpoint is currently only used by IDOT TREC, but it's designed to support similar auth flows in the future; so if other integrations need the same pattern, we can point them there as well.
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.
Summary
redirect_uriquery param to the existingGET /auth/tokenendpoint. If omitted, defaults to Clowder's ownsettings.auth_redirect_uri.get_tokeninutils.pyto acceptredirect_urias a keyword argument, using the module-levelkeycloak_openidinstance directly.Background
IDOT TREC shares the same Keycloak realm and client (
clowder2-backend) as Clowder. When a user logs in via IDOT TREC's login button, Keycloak redirects back to the IDOT TREC frontend with an authorization code. IDOT TREC's backend must then call Clowder's/auth/tokento exchange that code — not just hit Keycloak directly — because/auth/tokenupserts the user record into Clowder's MongoDB, which IDOT TREC relies on for group membership and permissions.Why
redirect_urimust be configurable:Keycloak requires that the
redirect_uripassed during the token exchange exactly matches the one used in the original authorization request. Since IDOT TREC's login flow redirects to the IDOT TREC frontend (not Clowder's backend), IDOT TREC must pass its own frontend URL when calling/auth/token. See ncsa/idot-pma@login-oidc: clowder/clowder.py#L305-310.Used by
ncsa/idot-pma#213 — calls
/auth/tokenpassing its ownredirect_urito support the OIDC authorization code flow from an external frontend.