Skip to content

feat: Custom security schemes#1463

Merged
ernado merged 3 commits intoogen-go:mainfrom
jeanschmitt:custom-security-schemes
Sep 18, 2025
Merged

feat: Custom security schemes#1463
ernado merged 3 commits intoogen-go:mainfrom
jeanschmitt:custom-security-schemes

Conversation

@jeanschmitt
Copy link
Contributor

Summary

Addresses a FIXME (in parse_security.go) about a too strict authentication schemes enum validation.

This PR introduces a new configuration field, authentication_schemes, used to configure allowed authentication schemes.
By default, the ones defined in https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml are considered.

In addition, a security type is generated for custom securities, making it possible to access the Roles defined in the specification from custom security implementations (which is especially useful with non-standard authentication schemes).

Breaking change

This PR introduces a breaking change in the generated SecurityHandler signature for custom securities:

type SecurityHandler interface {
	HandleCustom(ctx context.Context, operationName OperationName, req *http.Request) (context.Context, error)
}

// becomes

type SecurityHandler interface {
	HandleCustom(ctx context.Context, operationName OperationName, t Custom) (context.Context, error)
}

type Custom struct {
	Request *http.Request
	Roles   []string
}

I think this change is worth it, because it has little impact (req => t.Request), and facilitates future extensions for custom securities.

@jeanschmitt jeanschmitt marked this pull request as draft May 22, 2025 19:59
@jeanschmitt jeanschmitt force-pushed the custom-security-schemes branch from d3251d3 to 9f4501f Compare May 22, 2025 20:04
@jeanschmitt jeanschmitt marked this pull request as ready for review May 22, 2025 20:07
@jeanschmitt jeanschmitt changed the title Custom security schemes feat: Custom security schemes May 22, 2025
@jeanschmitt jeanschmitt force-pushed the custom-security-schemes branch from 6e39e43 to a6beeb2 Compare June 15, 2025 09:07
@jeanschmitt jeanschmitt force-pushed the custom-security-schemes branch from a6beeb2 to fa69177 Compare July 16, 2025 09:23
@ernado ernado merged commit f96ae51 into ogen-go:main Sep 18, 2025
15 checks passed
@jeanschmitt jeanschmitt deleted the custom-security-schemes branch October 12, 2025 09:38
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.

2 participants