feat(account-api): support client credentials auth via env vars#918
Merged
Soner (shyim) merged 4 commits intomainfrom Mar 18, 2026
Merged
feat(account-api): support client credentials auth via env vars#918Soner (shyim) merged 4 commits intomainfrom
Soner (shyim) merged 4 commits intomainfrom
Conversation
…I/CD Allow non-interactive authentication using SHOPWARE_CLI_ACCOUNT_CLIENT_ID and SHOPWARE_CLI_ACCOUNT_CLIENT_SECRET environment variables, enabling OAuth2 client credentials flow for automated CI/CD pipelines.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds non-interactive authentication options for the Shopware Account API to better support CI/CD usage, primarily via OAuth2 client credentials sourced from environment variables, plus an override for the OIDC endpoint.
Changes:
- Add OAuth2 client-credentials login path in
NewApiusingSHOPWARE_CLI_ACCOUNT_CLIENT_ID/SHOPWARE_CLI_ACCOUNT_CLIENT_SECRET. - Add
SHOPWARE_CLI_OIDC_ENDPOINTenv var override for custom OIDC endpoints. - Add a unit test covering the client-credentials token request against a mock token server.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| internal/account-api/oidc.go | Adds client-credentials scope constant and OIDC endpoint override via env var. |
| internal/account-api/login.go | Introduces client-credentials login flow and integrates it into auth priority. |
| internal/account-api/login_test.go | Adds unit test validating client-credentials flow with a mock token server. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
internal/account-api/login_test.go
Outdated
Comment on lines
+13
to
+18
| tokenRequested := false | ||
|
|
||
| srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| if r.URL.Path == "/oauth2/token" { | ||
| tokenRequested = true | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Fail fast when only one of client ID/secret env vars is set - Set AuthStyle to AuthStyleInParams to match interactive OAuth2 flow - Use atomic.Bool for race-safe test assertions - Add test for incomplete credentials error
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
SHOPWARE_CLI_ACCOUNT_CLIENT_IDandSHOPWARE_CLI_ACCOUNT_CLIENT_SECRETenvironment variablesSHOPWARE_CLI_OIDC_ENDPOINTenv var override for custom OIDC endpointsAuth priority order
SHOPWARE_CLI_ACCOUNT_CLIENT_ID+SHOPWARE_CLI_ACCOUNT_CLIENT_SECRET(new)SHOPWARE_CLI_ACCOUNT_EMAIL+SHOPWARE_CLI_ACCOUNT_PASSWORDTest plan