Skip to content

Add Bearer support - #8

Open
fishloa wants to merge 4 commits into
scottlamb:mainfrom
fishloa:bearer
Open

fishloa wants to merge 4 commits into
scottlamb:mainfrom
fishloa:bearer

Conversation

@fishloa

@fishloa fishloa commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

This adds a bearer module next to basic and digest, covering both sides of RFC 6750.

On the client side, bearer::Client reads a Bearer challenge, including resource_metadata from RFC 9728, which OAuth clients use to find the authorization server. respond (or bearer::encode_credentials) produces the Authorization value. It has no feature flag and no dependencies.

On the server side, behind server, bearer::ChallengeBuilder writes the challenge, bearer::ErrorCode covers the three RFC 6750 errors and their status codes, and bearer::Credentials::parse takes the token out of Authorization: Bearer ... using the same CredentialsSource types as the Basic parser.

Both sides use the same table of parameters and rules, so anything the builder writes the client accepts. The rules follow RFC 6750 section 3 and RFC 6749 appendix A in full: at least one parameter, no repeats, the scope and error character sets, error_uri as an absolute URI, and resource_metadata as an https URI with a host and no fragment. The URI check is a small RFC 3986 parser; a new fuzz target, bearer_uri, compares it against iri-string.

The server module used to need basic-scheme or digest-scheme as well; it now builds with server alone. The design note and the RFC text it follows are in design/20261023-bearer.md and design/20261023-bearer-rfc.md.

Adds a bearer module behind the server feature: a challenge builder
for RFC 6750 section 3 (plus RFC 9728's resource_metadata), the three
RFC 6750 error codes, and token parsing from Authorization: Bearer.
bearer::Client reads Bearer challenges and bearer::encode_credentials
sends the token. Client and ChallengeBuilder share one table of the
RFC 6750 and RFC 9728 parameters and their rules. error_uri and
resource_metadata are checked against the RFC 3986 URI grammar, fuzzed
against iri-string.
@fishloa fishloa changed the title Add server-side Bearer challenges and credentials Add Bearer support Oct 23, 2026
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.

1 participant