Skip to content

Use RFC-9728 OAuth 2.0 Protected Resource Metadata for auth discovery - #256

Merged
acoburn merged 5 commits into
mainfrom
oauth-rfc-9728
Oct 14, 2026
Merged

acoburn merged 5 commits into
mainfrom
oauth-rfc-9728

Conversation

@acoburn

@acoburn acoburn commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Resolves #236

At present, LWS Authentication builds on HTTP's existing Challenge and Response mechanism (i.e., WWW-Authenticate response headers).

In addition, the current LWS draft uses the realm parameter (with our own special definition) along with a parameter that comes from UMA and GNAP (as_uri) in order to facilitate authorization server discovery.

While this does work, there is a more standard OAuth2 approach: RFC-9728 OAuth 2.0 Protected Resource Metadata.

Given that OAuth 2.0 provides a baseline for authentication in LWS, it seems preferable to adopt an existing OAuth mechanism for this rather than inventing our own.

This PR also adds more bullet points to the Security Considerations section, as they relate to processing this metadata.


Preview | Diff

Comment on lines +101 to +104
{
"resource": "https://storage.example/storage_1/photos/img.jpg",
"authorization_servers": ["https://authorization.example"]
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we intend to support a possibility of a different AS per protected resource in LWS 1.0 baseline? I guess @termontwouter with his UMA experience may have an opinion.
Otherwise for a 1.0 baseline we could consider piggybacking on already required storage relation and simply advertise storage wide AS as service in the Storage Description. That should be pretty easy for clients to implement and we would have one less dependency for the 1.0 core spec and less for implementers to conform to.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While possible, it seems unlikely that there would be different AS values for each resource. And while it may be simpler, in a sense, to put this metadata in the storage description, the approach described here means that we are using an existing OAuth2 mechanism for OAuth2 AS discovery rather than inventing our own thing (which we should avoid as much as possible).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, at the same time we seem to be replacing a simple as_uri field in the response header with quite a bit of a ceremony and dependency on RFC-9728 which introduces another .well-known (which I understand LWS will not use) and layer of indirection.
As for inventing our own thing, we already have storage description and rely on storage relation in the Link header to be used as the aud and resource in tokens and request parameters. Replacing as_uri with an endpoint of a typed service in a Storage Description doesn't seem like we would be inventing a lot.
I'm not arguing that we should do it, I only suggest that we can at least entertain that option as something available and very likely simpler as long as we don't require different AS for different resources. It also doesn't prevent adding RFC9728 as an available option when needed.
I also see no issue with us merging this PR and waiting for some feedback from implementations.

Comment thread lws10-core/Security-Considerations.html Resolved
Comment thread lws10-core/Authorization.html Resolved
@acoburn

acoburn commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

The WG voted and approved this PR in the 2026-10-12 meeting. The consensus was to merge while marking this as something to get feedback on from implementers (b9b1e5e)

@acoburn
acoburn merged commit 9420b5d into main Oct 14, 2026
2 checks passed
@acoburn
acoburn deleted the oauth-rfc-9728 branch October 14, 2026 13:29
ebremer added a commit to ebremer/touchstone that referenced this pull request Oct 19, 2026
…the LWS profile, moving resources

W3C's WD-lws10-core-20261019 and the 15 October 2026 OpenID Connect, SAML and CID
WDs. The core catalog grows from 190 requirements to 215: a 401 names the
requested resource's protected resource metadata (RFC 9728) and links to the
storage a token is for (w3c/lws-protocol#256), only application/lws+json is
required of a container and the LWS profile must be RDF isomorphic to it (#253),
and clients may move resources by patching the up link (#237). The Approved seed
conneg-media-type-equivalence is retired with a Draft successor; the suites
changed words only.

Format 0.14.0: ${as.resource} replaces ${as.realm}, ${as.uri} comes from the
protected resource metadata (the earlier challenge is still read), sameOrigin,
rdfIsomorphicWith with the WG's built lws/v1 context bundled, and discoveryValid
for client rules. 221 server tests: protected resource metadata, the storage
link on a 401 as a MUST, content negotiation in the LWS profile, and twelve
move tests; the multiple-audiences test is retired. The reference server,
reference client, client sessions and the decoy follow the draft.
ebremer added a commit to ebremer/lws-drupal that referenced this pull request Oct 20, 2026
The drafts replaced the "as_uri" and "realm" of the 401 challenge with
OAuth 2.0 Protected Resource Metadata (w3c/lws-protocol#256). Every 401
in the LWS URL space now carries resource_metadata, the metadata URL of
the URL the client requested: the origin of the base URL, then
/.well-known/oauth-protected-resource, the base path, the raw path and
the query as sent. The Link to the storage stays; a storage without an
authorization server still answers 503.

as_uri and realm still follow by default, for clients of the earlier
drafts: lws_authz.settings:legacy_challenge (TRUE; on the authorization
settings form; update 11005) turns them off. Authentication's realm and
asUri are now storageUri and issuer, with the flag beside them, so lws
never reads lws_authz's config.

lws_authz serves the metadata at /.well-known/oauth-protected-resource
followed by any path, mapped onto one route by a path processor as
LwsPathProcessor does for the LWS URL space: resource, character for
character the requested URL; authorization_servers, the issuer of the
storage's authorization server; bearer_methods_supported, header only.
It is the same for every URL of a storage, existing or not, needs no
token (no Authorization header can make it fail), is readable cross-
origin and cached for 300 seconds, and answers 404 for a URL that names
no storage or one without an authorization server. A site below the
root of its host needs the web server to send the RFC 9728 URL there, as
for the authorization server's metadata; the status report fetches it
as a client would and says where.

An access token's aud now has to include the storage URI rather than be
it alone. The token exchange already required the storage URI as
resource; only its wording changed.

The LWS profile (w3c/lws-protocol#253): profile is read as a list of
URIs, quoted or not, with case-insensitive parameter names. Containers,
the notification service's listing and the access request and grant
listings answer ld+json with profile="https://www.w3.org/ns/lws/v1"
when it is asked for, and a range naming only other profiles does not
select ld+json. The listings in no profile never claim it. Turtle and
the other RDF syntaxes stay unoffered (406): lws-drupal has no JSON-LD
1.1 processor to derive them, and only lws+json is required.

DESIGN §6.7 and §12 rows 18-21 record the decisions. 39 more tests;
the suite passes on SQLite, MySQL 8.4, MariaDB 11.8 and PostgreSQL 17;
phpcs and phpstan are clean.
ebremer added a commit to halcyon-project/Halcyon that referenced this pull request Oct 20, 2026
The drafts of 19 October 2026 (w3c/lws-protocol#256) replace the as_uri/realm challenge with
OAuth 2.0 Protected Resource Metadata. A storage's 401 now carries

  WWW-Authenticate: Bearer resource_metadata="<metadata URL of the URL requested>",
                    as_uri="<issuer>", realm="<storage base URI>"[, error="invalid_token"]
  Link: <storage URI>; rel="https://www.w3.org/ns/lws#storage"

resource_metadata is RFC 9728 section 3.1 applied to the raw request URI, query kept: the origin of
:ProxyHostName, /.well-known/oauth-protected-resource, then :ProxyHostName's path and the request
path. The challenge is computed when the Problem is written, from the request it answers
(Problem.header(name, Function<HttpServletRequest, String>), LwsServlet writes with writeTo(req,
resp)), so the refusals deep in the handlers did not have to be given the request. No error code
when nothing was presented, the error after it when a token fails validation, as before.

as_uri and realm still follow resource_metadata for clients of the earlier drafts, behind the new
setting :LWSLegacyChallenge (default true).

oauth/ProtectedResourceMetadataServlet answers a storage's metadata URLs, mounted per storage on
/.well-known/oauth-protected-resource<storage path>/* (so the MCP endpoint's metadata at
/.well-known/oauth-protected-resource/mcp is not shadowed): GET/HEAD give {resource,
authorization_servers, bearer_methods_supported:["header"]} with Cache-Control public. resource is
:ProxyHostName plus the raw path after the well-known prefix (which a path-stripping proxy leaves
without :ProxyHostName's path) plus the query, the exact inverse of the challenge, so it is the URL
the client requested character for character, as RFC 9728 section 3.3 requires.
authorization_servers names the issuer CredentialChain names for the storage: the embedded
authorization server, or the discovered Keycloak issuer when it is off. Anonymous, never reads
Authorization, consults no store (no existence oracle); OPTIONS 204, other methods 405 with Allow,
a path outside the storage 404 problem+json, 503 until the storage servlet is initialised.

Token validation: an access token's aud now has to include the storage rather than be exactly it,
as the validation section now says, and the storage is named either as the storage URI the 401
links to (with its trailing slash) or as its base URI. The token endpoint mints aud as the client
spelled the resource, since aud MUST include the URI supplied; a resource taken from the Link
header now gets a token whose aud is that URI. The Keycloak verifier and a CID credential presented
directly accept the storage URI with its slash too.

Javadoc that described the as_uri/realm model is corrected. New: ProtectedResourceMetadataServlet-
Test (the two mappings as one round trip, with and without a path in :ProxyHostName, root, query,
encoded names; the document; HEAD, OPTIONS, 405, 404, 503; credentials never read) and
BearerTokenValidatorTest (challenge shape with and without credentials, legacy on and off).
TokenExchangeTest covers aud spelled as requested, aud including the storage among others, and
aud naming only others. LwsTestSuiteConformanceTest mounts the metadata servlet as the app does,
fetches the metadata of every challenge it checks, and runs discovery end to end: 401, Link,
resource_metadata, authorization server metadata, a did:key credential exchanged for the storage
URI, a token whose aud includes it, accepted by the storage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

realm and aud assumptions

4 participants