feat(oauth): support generic OIDC/OAuth providers and fix misleading errors (closes #1247)#1659
Open
emanuelbesliu wants to merge 1 commit into
Open
Conversation
…errors Fixes smallstep#1247. `step oauth --provider` accepted an HTTPS issuer URL in addition to `google`/`github`, but rejected plaintext `http://` providers, the validation error still claimed only "google or github" were valid, and endpoint discovery only ever tried the OpenID Connect `/.well-known/openid-configuration` path (a long-standing in-code TODO). This made `step oauth` awkward to use with a self-hosted or local identity provider such as Keycloak. Changes: - Validate(): accept an OIDC/OAuth issuer URL and report it in the error message instead of the misleading "google or github" text. - Allow plaintext `http://` providers (e.g. a local test IdP) when the `--insecure` flag is set, matching the existing implicit-flow gating. - disco(): resolve the TODO by falling back to the RFC 8414 OAuth 2.0 authorization server metadata document (`/.well-known/oauth-authorization-server`) when OIDC discovery fails, and honor a provider URL that already points at a `/.well-known/` document. - fetchDiscovery(): check the HTTP status code so a 404/HTML response yields a clear "unexpected status code" error instead of "unsupported format". - Update --provider usage text accordingly. - Add command/oauth/cmd_test.go covering Validate() and disco() (OIDC, RFC 8414 fallback, explicit well-known URL, non-200, invalid JSON). Signed-off-by: Emanuel Besliu <32497562+emanuelbesliu@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Name of feature:
Generic OIDC/OAuth provider support for
step oauth(closes #1247)Pain or issue this feature alleviates:
step oauth --providerwas awkward to use with a self-hosted or local identity provider such as Keycloak:http://provider (a common local test setup) was rejected outright — the exact scenario reported in Support non-tls providers for the oauth commandhttp://#1247.googleorgithubwere valid, even though anhttps://issuer URL already worked, so the message was misleading:/.well-known/openid-configurationpath (a long-standing in-codeTODO), so OAuth 2.0 authorization servers that only publish RFC 8414 metadata could not be discovered.unsupported formaterror instead of reporting the HTTP status.Why is this important to the project (if not answered above):
It makes
step oauthusable with any standards-compliant OIDC/OAuth provider (Keycloak, Authentik, Dex, etc.) — including local test instances — without requiring users to hand-supply--authorization-endpoint/--token-endpoint. This is a frequent homelab/self-hosted CA workflow (Keycloak as the OIDC provisioner forstep-ca).Is there documentation on how to use this feature? If so, where?
The
--providerusage text instep oauth --helpis updated to describe OIDC + RFC 8414 discovery and the--insecurerequirement for plaintexthttp://providers.In what environments or workflows is this feature supported?
https://issuer URLs (unchanged default behavior).http://issuer URLs only with--insecure(matching the existing implicit-flow gating) — intended for local test IdPs./.well-known/...URL.In what environments or workflows is this feature explicitly NOT supported (if any)?
Plaintext
http://providers without--insecureare still rejected, so the default behavior remains TLS-only.Supporting links/other PRs/issues:
http://#1247Implementation notes
Validate(): accept OIDC/OAuth issuer URLs; clearer error message.oauthCmd: gate plaintexthttp://behind--insecureviaerrs.RequiredInsecureFlag.disco(): try OIDC discovery, then fall back to RFC 8414 OAuth metadata; honor a URL already pointing at a/.well-known/document.fetchDiscovery(): surface non-200 status codes.command/oauth/cmd_test.go(the package previously had no tests) coveringValidate()and alldisco()paths.Tested with
go test ./command/oauth/;gofmtandgo vetclean.