Add HelperWithoutCredentials for call-time-credential Keycloak login patterns - #105
Merged
github-actions[bot] merged 1 commit intoSep 17, 2026
Conversation
ambersun1234-bigstack
requested review from
a team and
raven-pan
as code owners
September 17, 2026 08:41
ambersun1234-bigstack
force-pushed
the
shawn.hsu/issue-1391/fix-keycloak-credential-check
branch
from
September 17, 2026 09:06
a4caecf to
23e9787
Compare
…patterns Helper.SetKeycloakClient (called internally by NewHelper) requires Options.Username/Password or Options.ClientID/ClientSecret to already be set, or it returns an error before ever building the underlying gocloak.Client. That's the right precondition for LoginAdmin and LoginServiceAccount, which both read those same Options fields at call time. It's the wrong precondition for Helper.CheckLoginUser(username, password, client ClientCredentials), whose whole point is to take login credentials as call-time parameters instead of pre-configured Options. A caller that builds a Helper via NewHelper with only network-location options (scheme/ip/port/path/realm) and supplies credentials later via CheckLoginUser's own client argument could never get past NewHelper, since Options never carried any credentials in that call pattern. Add HelperWithoutCredentials as a fully independent type for that call pattern, with its own constructor (NewHelperWithoutCredentials) and its own CheckLoginUser method, rather than reusing Helper or threading a bool through SetKeycloakClient. Helper/NewHelper/SetKeycloakClient stay byte-for-byte unchanged. Because HelperWithoutCredentials has no LoginAdmin or LoginServiceAccount methods, a caller that builds one can't accidentally try to log in with Options-level credentials that were never required to construct it -- that misuse is a compile error here instead of a runtime one, which a shared struct (with credential-requiring methods still attached) couldn't have prevented. This is the root-cause fix for cubecmp's self-service change-password endpoint returning 500 on every call regardless of whether the submitted password was correct (bigstack-oss/cubecmp#1391). Signed-off-by: Shawn Hsu <shawn.hsu@bigstack.co> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ambersun1234-bigstack
force-pushed
the
shawn.hsu/issue-1391/fix-keycloak-credential-check
branch
from
September 17, 2026 09:11
23e9787 to
e23fba1
Compare
lizzy-liang-bigstack
approved these changes
Sep 17, 2026
lizzy-liang-bigstack
left a comment
There was a problem hiding this comment.
Approved to keep things moving! I haven't done a deep dive into the logic since it's outside my domain, so please make sure to get a final check from the domain expert. Just approving to unblock the pipeline for now 👍🏻
github-actions
Bot
deleted the
shawn.hsu/issue-1391/fix-keycloak-credential-check
branch
September 17, 2026 14:49
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.
What type of PR is this?
/kind bug
What this PR does / why we need it
Helper.SetKeycloakClient(called internally byNewHelper) requiresOptions.Username+Options.PasswordorOptions.ClientID+Options.ClientSecretto already be set, or it returns an error before ever building the underlyinggocloak.Client. That's the right precondition forLoginAdminandLoginServiceAccount, which both read those sameOptionsfields at call time.It's the wrong precondition for
Helper.CheckLoginUser(username, password, client ClientCredentials), whose whole point is to take login credentials as call-time parameters instead of pre-configuredOptions. A caller that builds aHelperviaNewHelperwith only network-location options (scheme/ip/port/path/realm) and supplies credentials later viaCheckLoginUser's ownclientargument could never get pastNewHelper, sinceOptionsnever carried any credentials in that call pattern.This PR adds
HelperWithoutCredentialsas a fully independent type for that call pattern, with its own constructor (NewHelperWithoutCredentials) and its ownCheckLoginUsermethod, rather than reusingHelperor threading a bool throughSetKeycloakClient.Helper/NewHelper/SetKeycloakClientstay byte-for-byte unchanged. BecauseHelperWithoutCredentialshas noLoginAdminorLoginServiceAccountmethods, a caller that builds one can't accidentally try to log in withOptions-level credentials that were never required to construct it — that misuse is a compile error here instead of a runtime one, which a shared struct (with credential-requiring methods still attached) couldn't have prevented.Which issue(s) this PR fixes
Fixes bigstack-oss/cubecmp#1391
Special notes for your reviewer
Additional documentation