-
Notifications
You must be signed in to change notification settings - Fork 6
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility] #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amit-kumar8-sf
wants to merge
15
commits into
main
Choose a base branch
from
feature-W-20893800-add-stateful-auth-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e3f8631
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
amit-kumar8-sf 46c4f6f
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
amit-kumar8-sf b6ec707
Merge branch 'main' into feature-W-20893800-add-stateful-auth-support
amit-kumar8-sf ee34526
Merge branch 'main' into feature-W-20893800-add-stateful-auth-support
amit-kumar8-sf c747d62
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
amit-kumar8-sf 1fb22a6
Merge branch 'main' into feature-W-20893800-add-stateful-auth-support
amit-kumar8-sf 38ab575
Merge branch 'main' into feature-W-20893800-add-stateful-auth-support
amit-kumar8-sf 59b218d
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
amit-kumar8-sf 5576cb1
Merge branch 'main' into feature-W-20893800-add-stateful-auth-support
amit-kumar8-sf 38a43c3
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
amit-kumar8-sf ff3c5d3
Merge branch 'main' into feature-W-20893800-add-stateful-auth-support
amit-kumar8-sf 5009613
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
amit-kumar8-sf e06b1a2
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
amit-kumar8-sf 64de979
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
amit-kumar8-sf eca9a4f
Merge branch 'main' into feature-W-20893800-add-stateful-auth-support
amit-kumar8-sf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| '@salesforce/b2c-cli': minor | ||
| '@salesforce/b2c-tooling-sdk': minor | ||
| --- | ||
|
|
||
| # Stateful authentication support | ||
|
|
||
| Introduces stateful authentication commands and session management, enabling tokens to be persisted on disk and automatically reused across CLI commands — eliminating the need to pass credentials on every invocation. | ||
|
|
||
| ## New commands | ||
|
|
||
| - **`auth login`** – Log in via browser (implicit OAuth) and persist the session for stateful user auth. Only the flags relevant to the implicit flow are exposed (`--client-id`, `--account-manager-host`, `--auth-scope`). | ||
| - **`auth logout`** – Clear the stored session and return to stateless-only auth. | ||
| - **`auth client`** – Authenticate an API client using `client_credentials` or `password` grant (non-interactive). Use `--renew` to store credentials for later token renewal. | ||
| - **`auth client renew`** – Refresh the stored token using credentials saved with `--renew`. Supports `refresh_token` grant with automatic fallback to `client_credentials`. | ||
| - **`auth client token`** – Return the current stored token: raw to stdout (pipe-friendly) or full metadata with `--json`. | ||
|
|
||
| ## Session storage | ||
|
|
||
| Sessions are stored as a JSON file in the CLI's own data directory (e.g. `~/Library/Application Support/@salesforce/b2c-cli/auth-session.json` on macOS). | ||
|
|
||
| > **Note:** Sessions stored by `sfcc-ci` are no longer shared with the CLI. Re-authenticate using `b2c auth login` or `b2c auth client` after upgrading. | ||
| ## Auth precedence | ||
|
|
||
| When a valid stored session exists, all OAuth commands automatically use it — no flags required. The CLI falls back to stateless auth when: | ||
|
|
||
| - The stored token is **expired or invalid** — a warning suggests the appropriate renewal command. | ||
| - **Explicit stateless flags** are passed (`--client-secret`, `--user-auth`, or `--auth-methods`) — a warning lists the triggering flags. | ||
|
|
||
| Passing `--client-id` alone does not force stateless auth; the stored session is used if the client ID matches. | ||
|
|
||
| ## No breaking change | ||
|
|
||
| When no stateful session exists, behavior is identical to before (stateless auth). Existing environment variable and `dw.json` configuration continues to work without modification. |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changeset can just be a short paragraph (2-3 sentences max). Doesn't need to describe the feature.