argo-cd: SSO for Existing OIDC Provider returning 401 because of missing client secret
My setup is running Argocd 1.3.6. I’m able to login via the web browser via SSO with no problem. However, when I attempt to login using the CLI, I get the following error:
$ argocd login argocd-dev.mycompany.com --sso --username me@mycompany.com
WARNING: server certificate had error: x509: certificate is valid for ... Proceed insecurely (y/n)? y
Opening browser for authentication
INFO[0003] RequestedClaims: map[groups:essential:true ]
Performing authorization_code flow login: https://login.windows.net/.../oauth2/authorize?access_type=offline&claims=%7B%22id_token%22%3A%7B%22groups%22%3A%7B%22essential%22%3Atrue%7D%7D%7D&client_id=...&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2Fauth%2Fcallback&response_type=code&scope=openid+profile+email+groups&state=SACdbDdlaC
FATA[0005] oauth2: cannot fetch token: 401 Unauthorized
Response: {"error":"invalid_client","error_description":"AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.\r\nTrace ID: 0e3cc8df-2a95-4440-b71a-2d21ca860000\r\nCorrelation ID: adbccf25-c119-4f4f-9dec-c425acbbdd5e\r\nTimestamp: 2019-12-31 02:45:49Z","error_codes":[7000218],"timestamp":"2019-12-31 02:45:49Z","trace_id":"0e3cc8df-2a95-4440-b71a-2d21ca860000","correlation_id":"adbccf25-c119-4f4f-9dec-c425acbbdd5e","error_uri":"https://login.windows.net/error?code=7000218"}
I followed the documentation here: https://argoproj.github.io/argo-cd/operator-manual/sso/#existing-oidc-provider
config:
url: https://argocd-dev.mycompany.com
oidc.config: |
name: Azure
clientID: ...
cliClientID: ...
clientSecret: ...
issuer: https://sts.windows.net/.../
# Optional set of OIDC claims to request on the ID token.
requestedIDTokenClaims: {"groups": {"essential": true}}
Being able to login via the UI, but not via the CLI leads me to believe this is a bug. Am I missing anything obvious in my config? I’m happy to provide any config that maybe useful for debug.
Version details
argocd: v1.3.6+89be1c9
BuildDate: 2019-12-10T22:48:19Z
GitCommit: 89be1c9ce6db0f727c81277c1cfdfb1e385bf248
GitTreeState: clean
GoVersion: go1.12.6
Compiler: gc
Platform: darwin/amd64
argocd-server: v1.3.6+89be1c9
BuildDate: 2019-12-10T22:47:48Z
GitCommit: 89be1c9ce6db0f727c81277c1cfdfb1e385bf248
GitTreeState: clean
GoVersion: go1.12.6
Compiler: gc
Platform: linux/amd64
Ksonnet Version: v0.13.1
Kustomize Version: Version: {Version:kustomize/v3.2.1 GitCommit:d89b448c745937f0cf1936162f26a5aac688f840 BuildDate:2019-09-27T00:10:52Z GoOs:linux GoArch:amd64}
Helm Version: v2.15.2
Kubectl Version: v1.14.0
In commands/login.go, it appears oauth2conf.ClientSecret is never getting populated.
func oauth2Login(ctx context.Context, port int, oidcSettings *settingspkg.OIDCConfig, oauth2conf *oauth2.Config, provider *oidc.Provider) (string, string) { ...
I’ve just verified this bug doesn’t appear in v1.2.0, but does in 1.3.0.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 19 (8 by maintainers)
Commits related to this issue
- fix: support for PKCE for cli login (#2932) — committed to chanzuckerberg/argo-cd by mbarrien 4 years ago
- fix: support for PKCE for cli login (#2932) (#4067) — committed to argoproj/argo-cd by mbarrien 4 years ago
- fix: support for PKCE for cli login (#2932) (#4067) — committed to argoproj/argo-cd by mbarrien 4 years ago
- [ArgoCD] Improve Keycloak documentation for command line sign-in Documenting what is discussed in #2932 Signed-off-by: Antoine Pultier <antoine.pultier@sintef.no> — committed to fungiboletus/argo-cd by fungiboletus 2 years ago
- docs: Improve Keycloak documentation for command line sign-in (#8758) Documenting what is discussed in #2932 Signed-off-by: Antoine Pultier <antoine.pultier@sintef.no> Signed-off-by: Antoine Pu... — committed to argoproj/argo-cd by fungiboletus 2 years ago
- docs: Improve Keycloak documentation for command line sign-in (#8758) Documenting what is discussed in #2932 Signed-off-by: Antoine Pultier <antoine.pultier@sintef.no> Signed-off-by: Antoine Pu... — committed to argoproj/argo-cd by fungiboletus 2 years ago
- docs: Improve Keycloak documentation for command line sign-in (#8758) Documenting what is discussed in #2932 Signed-off-by: Antoine Pultier <antoine.pultier@sintef.no> Signed-off-by: Antoine Pultie... — committed to emirot/argo-cd by fungiboletus 2 years ago
- docs: Improve Keycloak documentation for command line sign-in (#8758) Documenting what is discussed in #2932 Signed-off-by: Antoine Pultier <antoine.pultier@sintef.no> Signed-off-by: Antoine Pultie... — committed to schakrad/argo-cd by fungiboletus 2 years ago
- test(server): add test for list repositories (#11035) * feature: allow a custom labels on any resource to surface in the UI (tree view node tags) (#11153) * feature: allow a custom label on any re... — committed to argoproj/argo-cd by emirot a year ago
- test(server): add test for list repositories (#11035) * feature: allow a custom labels on any resource to surface in the UI (tree view node tags) (#11153) * feature: allow a custom label on any re... — committed to alexec/argo-cd by emirot a year ago
- feat: Container statuses on summary tab of pod and detailed info in tooltip for pod on resource tree (#11513) * docs: Improve Keycloak documentation for command line sign-in (#8758) Documenting w... — committed to argoproj/argo-cd by schakrad a year ago
- test(server): add test for list repositories (#11035) * feature: allow a custom labels on any resource to surface in the UI (tree view node tags) (#11153) * feature: allow a custom label on any re... — committed to yyzxw/argo-cd by emirot a year ago
Maybe this will save someone some time. In my case the problem was with Azure AD. Starting from v.1.3.x argocd-cli will perform
authorization_code
flow if provider supports it. In case of Azure AD (the same is true for Google), there are two kinds of platforms supported: web applications and mobile and desktop applications (so calledpublic
in terms of Google). Inauthorization_code
flow you need to specifyclient_secret
when requesting the token (second phase), but argocd-cli aren’t doing that (because they don’t want to show that in console) for web application platform. So for Azure AD, you just need to add mobile and desktop applications platform with Redirect URI:http://localhost:8085/auth/callback
, or create separate one and usecliClientID
with it’s id in argocd configmap.I had this issue and it drove me nuts. What I discovered was that I had to restart the argo-server pod after creating a new key-value pair in the secret configuration:
I started the pod with a reference to the non-existed $oidc.keycloak.clientSecret:
I then followed the instructions here to set up keycloak, adding the new key-value pair to the secret config file. However, the logs of the argo server showed it was not finding the key at all.
I deleted the pod, triggering a restart, and everything worked.
I’m also facing this issue. See my post in the slack channel https://argoproj.slack.com/archives/CASHNF6MS/p1577923783162400
@jl431 Thanks for making an issue!
solved it for me.
so, as far as I can tell… if you want the CLI to work… access_type == public in the keycloak client.
You may consider that dangerous but keycloak argues
https://www.keycloak.org/docs/latest/server_admin/#_oidc-auth-flows
See follow-up comment below
Similarly when trying to do this via Okta, I followed @Subreptivus 's advice for making a public client. ~In Okta speak its an SPA app.~ Its a native app. Only issue I’m encountering is Okta requires PKCE for public clients to do the auth code flow, but it seems the CLI does not support it:
I’m trying to figure out to disable PKCE for public clients in Okta, but is this on the roadmap for the CLI? Should I open a separate issue for PKCE support?
@zeph If you don’t mind, may I know how you have this fix(or workaround) for Keycloak.
Do you mean we need to create a “public” client-scope for the realm? and add this client-scope to client(which I did, but still not working)
I also have added “http://localhost:8085/auth/callback” to the “Valid Redirect URIs”. Give the user “offline_access” realm role.
but seems it didn’t generate the offline token
login via UI is fine but always failed from CLI