fix(utils): normalize URL to host before hashing credential storage key - #525
Closed
AntonYeromin wants to merge 1 commit into
Closed
fix(utils): normalize URL to host before hashing credential storage key#525AntonYeromin wants to merge 1 commit into
AntonYeromin wants to merge 1 commit into
Conversation
CredentialStore.getUrlStorageKey() only lowercased and trimmed a trailing slash, so the storage key depended on whatever URL path a caller happened to pass. CodeMieSSO.getStoredCredentials() (used by the proxy on startup) normalizes to protocol+host before deriving its lookup key, but CodeMieSSO.authenticate() stored credentials keyed by the raw, unnormalized URL. Running `codemie profile login --url <api-url-with-path>` therefore stored credentials under a key the proxy could never find, surfacing "SSO credentials not found" even immediately after a successful login. `codemie setup` avoided the bug only because it prompts for the bare portal URL. Normalizing inside getUrlStorageKey makes every caller (SSO store/ retrieve/clear and JWT store/retrieve/clear) agree on the same key regardless of path.
4 tasks
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
codemie profile login --url <api-url>andcodemie setupderived different SHA-256 storage keys for the same CodeMie origin, because credential storage hashed the raw URL while retrieval normalized it toprotocol//hostfirst. Logging in viacodemie profile login --url https://host/code-assistant-apistored credentials under one key, but the proxy's lookup (via the normalized host) used a different key, socodemie-claudereported "SSO credentials not found" immediately after a successful login.Changes
protocol//hostbefore hashing) intoCredentialStore.getUrlStorageKey()insrc/utils/security.ts, so it is the single point of normalization shared by every SSO and JWT store/retrieve/clear operation.Testing
tests/integration/sso-per-url-credentials.test.ts(23 tests) already covers per-URL storage/retrieval and passes against the fix.https://codemie-preview.lab.epam.com/code-assistant-api(previously mismatched).Checklist
npm run ci)main