Skip to content

fix(analyzer): a security scheme the generator cannot use costs the whole client - #64

Merged
giraffesyo merged 1 commit into
canaryfrom
security-scheme-degrade
Aug 20, 2026
Merged

fix(analyzer): a security scheme the generator cannot use costs the whole client#64
giraffesyo merged 1 commit into
canaryfrom
security-scheme-degrade

Conversation

@giraffesyo

Copy link
Copy Markdown
Member

Closes #62.

Two shapes stopped generation entirely:

$ go run . generate --spec spec.yaml --out ./out
Error: analyzing spec: unsupported security scheme type "openIdConnect" for "oidc"
Error: analyzing spec: unsupported http scheme "Bearer" for security scheme "auth"

No client at all, over one declaration the caller may not even be authenticating with. Any API fronted by Keycloak, Auth0, or Entra declares OIDC, and scheme: Bearer with a capital B is equivalent to bearer under RFC 7235, which registers auth scheme names case-insensitively.

Behavior now

declaration before after
type: openIdConnect generation fails bearer provider
scheme: Bearer generation fails bearer provider
type: mutualTLS generation fails warning, no provider
scheme: digest generation fails warning, no provider
unrecognized type generation fails warning, no provider

OpenID Connect is a bearer token on the wire; the discovery document is the caller's concern, not the transport's. mutualTLS is configured on the http.Client, so there is nothing for a provider to add to a request.

Unsupported schemes warn rather than pass silently, since a client with no provider for a scheme the API requires would otherwise look like it authenticates and 401:

warning: security scheme "legacy": no provider generated for http scheme "digest"
warning: security scheme "mtls": mutualTLS is configured on the HTTP transport, so no provider is generated
warning: security scheme "weird": no provider generated for unrecognized type "somethingNew"

Warnings collect on ir.Package and the CLI prints them to stderr, so the analyzer stays free of output concerns. That channel is reusable for anything else the generator has to skip.

I did not carry openIdConnectUrl into the IR. Nothing renders per-scheme metadata today, so it would be a field with no reader.

Tests

internal/analyzer/security_test.go covers a spec declaring all five shapes at once: openIdConnect and Bearer produce bearer providers, digest, mutualTLS, and an unrecognized type produce no provider and one warning each, and analysis returns no error.

gofmt, go vet ./..., and go test ./... pass.

…hole client

A spec declaring openIdConnect or mutualTLS failed generation outright, as
did `scheme: Bearer` with a capital B, which RFC 7235 makes equivalent to
`bearer`. Any API behind Keycloak, Auth0, or Entra was unusable over one
declaration the caller may not even authenticate with.

OpenID Connect is a bearer token on the wire, so it generates the bearer
provider. mutualTLS is configured on the transport and gets none. Anything
else unrecognized, including an unknown http scheme, now warns on stderr
and generates the rest of the client.

Warnings ride on ir.Package so the analyzer stays free of output concerns.
@giraffesyo
giraffesyo merged commit 15a9c94 into canary Aug 20, 2026
7 checks passed
@giraffesyo
giraffesyo deleted the security-scheme-degrade branch August 20, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openIdConnect specs and capitalized http schemes fail generation instead of producing a client

1 participant