@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]#167
Open
amit-kumar8-sf wants to merge 7 commits intomainfrom
Open
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]#167amit-kumar8-sf wants to merge 7 commits intomainfrom
amit-kumar8-sf wants to merge 7 commits intomainfrom
Conversation
Collaborator
|
Hi @amit-kumar8-sf . We definitely don't need the Compatibility with sfcc-ci here doesn't mean it needs to be compatible with sfcc-cis storage (there's no reason folks would be using both tools at once). It just needs to be compatible with the pattern of storing the auth state on disk for future commands. |
Collaborator
Author
@clavery Sure, if it doesn't needs to align with the sfcc-ci storage, then I will get rid of the conf package completely and move everything under oclif's control. Will share the updated PR by EOD today. |
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
Adds stateful authentication to the B2C CLI, compatible with sfcc-ci's stored session mechanism. Tokens are persisted on disk and reused across CLI commands without re-authentication.
New commands:
b2c auth client— Non-interactive auth viaclient_credentialsorpasswordgrant, with optional--renewfor auto-renewalb2c auth client renew— Refresh a stored token usingrefresh_tokenorclient_credentialsfallbackb2c auth client token— Return the stored token (raw to stdout, or full metadata with--json)b2c auth login/b2c auth logout— Browser-based login/logout with session persistenceStateful auth integration in existing commands:
getOAuthStrategy()inOAuthCommandprefers a valid stored session over stateless auth--client-secret,--user-auth,--auth-methods) are passedStorage:
confpackage with project namesfcc-ci, sharing the same keys (SFCC_CLIENT_ID,SFCC_CLIENT_TOKEN,SFCC_REFRESH_TOKEN,SFCC_CLIENT_RENEW_BASE,SFCC_USER) for cross-tool compatibilityNo breaking changes: When no stateful session exists or it is expired, behavior is unchanged.
Testing
stateful-store.ts: session CRUD,isStatefulTokenValid(expiry, scopes, client ID matching, invalid JWT)oauth-command.ts: stateful session preference, expired token warnings, explicit flag override, client ID matching passthroughauth client,auth client renew,auth client token): credential validation, grant type auto-detection, token storage, renewal flows, JSON/raw output, error handlingtrace()on stubbed loggerconfstore (sfcc-ci-testviaNODE_ENV=test) to avoid interference with real user configDependencies
3pl-approvedis set by a maintainerpnpm test)pnpm run format)