@W-23235332 fix(slas): drive PKCE for registered login on private clients#538
Open
clavery wants to merge 1 commit into
Open
@W-23235332 fix(slas): drive PKCE for registered login on private clients#538clavery wants to merge 1 commit into
clavery wants to merge 1 commit into
Conversation
…35332) `b2c slas token --shopper-login/--shopper-password` failed against a PRIVATE SLAS client with `HTTP 400 code_verifier is required`. The registered flow's `/oauth2/login` step always presents a `code_challenge`, but the private-client token exchange downgraded to `grant_type=authorization_code` and omitted `code_verifier`, so SLAS rejected it. Unify the registered token exchange: always use `authorization_code_pkce` with the matching `code_verifier` for both public and private clients; a private client additionally authenticates with its secret via HTTP Basic. This matches commerce-sdk-isomorphic's `loginRegisteredUserB2C`. Guest and `client_credentials` flows unchanged. - Rewrite SDK `getRegisteredToken` token exchange (single PKCE path). - Fix SDK test that had codified the buggy `authorization_code` contract; it now asserts PKCE + `code_verifier` + Basic auth. - Update slas docs flow table + b2c-slas skill. - Changeset (patch, @salesforce/b2c-tooling-sdk).
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
Fixes
b2c slas tokenregistered-customer login failing against a private SLAS client (one with a secret) with:Root cause: the registered flow's
/oauth2/loginstep always presents a PKCEcode_challenge, but the SDK'sgetRegisteredTokendowngraded the private-client token exchange togrant_type=authorization_codeand omitted thecode_verifier. Having received the challenge at login, SLAS then rejects the exchange.Fix: unify the registered token exchange so it always uses
grant_type=authorization_code_pkcewith the matchingcode_verifierfor both public and private clients; a private client additionally authenticates with its secret via HTTP Basic. This matches the canonical behavior incommerce-sdk-isomorphic'sloginRegisteredUserB2C. Guest andclient_credentialsflows are unchanged.Registered login now works on both public and private clients.
Also fixes the SDK unit test that had codified the buggy
authorization_codecontract (which is why CI stayed green while the live server failed); it now asserts the PKCE +code_verifier+ Basic-auth wire contract. Docs (docs/cli/slas.mdflow table) and theb2c-slasskill are updated.Testing
Verified live against a private SLAS client (
mystorefront-zzpq-019,Private: true) on instancezzpq-019:--shopper-login/--shopper-password) against the private client returnedHTTP 400 code_verifier is required.sty: Userandisb: ...upn:<shopper>...(a genuine registered login, not guest).client_credentialson the same private client still issues a token successfully.To reproduce manually:
Dependencies