This issue has been created
There is 1 update.
 
 
OpenId Connect / cid:jira-generated-image-avatar-35573891-c010-42fc-a4b1-e83682e654fe OIDC-315 Open

OAuth authorization-server metadata is unreachable at the RFC 8414 issuer-derived path when XWiki runs under a context path

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-b6937267-bcf9-463e-af0f-0741c5502d74 Vincent Massol created this issue on 04/Sep/26 19:28
 
Summary: OAuth authorization-server metadata is unreachable at the RFC 8414 issuer-derived path when XWiki runs under a context path
Issue Type: cid:jira-generated-image-avatar-35573891-c010-42fc-a4b1-e83682e654fe Bug
Affects Versions: 2.25.4
Assignee: Unassigned
Components: Provider
Created: 04/Sep/26 19:28
Priority: cid:jira-generated-image-static-major-0c0850b4-dfca-41f2-86e5-d8867627cf6c Major
Reporter: Vincent Massol
Description:

An OAuth 2.0 client that discovers the authorization server the way RFC 8414 prescribes cannot reach XWiki's metadata when XWiki is deployed under a context path (/xwiki), which is the default for the standard WAR.

What happens

For the issuer http://localhost:8080/xwiki/oidc, RFC 8414 section 3.1 puts the metadata at the host root with the issuer's path components appended:

http://localhost:8080/.well-known/oauth-authorization-server/xwiki/oidc

That URL is answered by the servlet container's ROOT context, which 302-redirects it to http://localhost:8080/xwiki/xwiki, which in turn 302-redirects to itself. A client following redirects gives up. The same happens for /.well-known/openid-configuration/xwiki/oidc.

Only the provider-relative form answers 200:

http://localhost:8080/xwiki/oidc/.well-known/oauth-authorization-server

which is what OIDC-303 added. That form is what an OpenID Connect Discovery client built from a base URL finds, but it is not the path RFC 8414 defines for an issuer that has a path component.

Why it matters

MCP (Model Context Protocol) clients do exactly this discovery. With the LLM Application's MCP server, the chain is correct up to this point:

  • .../aiLLM/mcp/.well-known/oauth-protected-resource returns 200 with authorization_servers: ["http://localhost:8080/xwiki/oidc"] (RFC 9728), and the unauthenticated endpoint returns 401 with WWW-Authenticate: Bearer realm="XWiki MCP", resource_metadata=....
  • The client then resolves that issuer per RFC 8414 and hits the redirect loop.

opencode mcp auth xwiki (OpenCode 1.18.4) fails with "The response redirected too many times", before a browser is ever opened.

Reproduction

With XWiki 18.6.0 and oidc-provider 2.25.4 on http://localhost:8080/xwiki:

curl -i http://localhost:8080/xwiki/oidc/.well-known/oauth-authorization-server
# 200

curl -i http://localhost:8080/.well-known/oauth-authorization-server/xwiki/oidc
# 302 -> /xwiki/xwiki, then 302 -> itself

Confirmation that this is the whole bug

Putting a reverse proxy in front that answers only /.well-known/oauth-authorization-server/xwiki/oidc from the provider-relative URL, and forwards everything else unchanged, makes the whole flow complete: dynamic client registration, the consent screen, the token, and a connected MCP server. Nothing else had to change, so the unreachable path is the only defect.

Notes

Dynamic client registration itself works (OIDC-21, OIDC-154): with the provider in Dynamic mode, registration_endpoint is advertised and POST /xwiki/oidc/register returns 201.

A deployment where XWiki is the ROOT context (issuer http://host/oidc) does not hit this, since there is no context path to collide with.

 
 

1 update

 
cid:jira-generated-image-avatar-b6937267-bcf9-463e-af0f-0741c5502d74 Changes by Vincent Massol on 04/Sep/26 19:28
 
Description: An OAuth 2.0 client that discovers the authorization server the way RFC 8414 prescribes cannot reach XWiki's metadata when XWiki is deployed under a context path \ ({{/xwiki}} \ ), which is the default for the standard WAR.

h2. What happens

For the issuer {{http://localhost:8080/xwiki/oidc}}, RFC 8414 section 3.1 puts the metadata at the host root with the issuer's path components appended:

{code}
http://localhost:8080/.well-known/oauth-authorization-server/xwiki/oidc
{code}

That URL is answered by the servlet container's ROOT context, which 302
\ -redirects it to {{http://localhost:8080/xwiki/xwiki}}, which in turn 302 \ -redirects to itself. A client following redirects gives up. The same happens for {{/.well \ -known/openid \ -configuration/xwiki/oidc}}.

Only the provider
\ -relative form answers 200:

{code}
http://localhost:8080/xwiki/oidc/.well-known/oauth-authorization-server
{code}

which is what OIDC
\ -303 added. That form is what an OpenID Connect Discovery client built from a base URL finds, but it is not the path RFC 8414 defines for an issuer that has a path component.

h2. Why it matters

MCP \ (Model Context Protocol \ ) clients do exactly this discovery. With the LLM Application's MCP server, the chain is correct up to this point:

* {{.../aiLLM/mcp/.well
\ -known/oauth \ -protected \ -resource}} returns 200 with {{ authorization\_servers authorization_servers : \ ["http://localhost:8080/xwiki/oidc" \ ]}} \ (RFC 9728 \ ), and the unauthenticated endpoint returns 401 with {{WWW \ -Authenticate: Bearer realm="XWiki MCP", resource\_metadata resource_metadata =...}}.
* The client then resolves that issuer per RFC 8414 and hits the redirect loop.

{{opencode mcp auth xwiki}}
\ (OpenCode 1.18.4 \ ) fails with "The response redirected too many times", before a browser is ever opened.

h2. Reproduction

With XWiki 18.6.0 and oidc \ -provider 2.25.4 on {{http://localhost:8080/xwiki}}:

{code}
curl -i http://localhost:8080/xwiki/oidc/.well-known/oauth-authorization-server
# 200

curl -i http://localhost:8080/.well-known/oauth-authorization-server/xwiki/oidc
# 302 -> /xwiki/xwiki, then 302 -> itself
{code}

h2. Confirmation that this is the whole bug

Putting a reverse proxy in front that answers only {{/.well \ -known/oauth \ -authorization \ -server/xwiki/oidc}} from the provider \ -relative URL, and forwards everything else unchanged, makes the whole flow complete: dynamic client registration, the consent screen, the token, and a connected MCP server. Nothing else had to change, so the unreachable path is the only defect.

h2. Notes

Dynamic client registration itself works \ (OIDC \ -21, OIDC \ -154 \ ): with the provider in Dynamic mode, {{ registration\_endpoint registration_endpoint }} is advertised and {{POST /xwiki/oidc/register}} returns 201.

A deployment where XWiki is the ROOT context
\ (issuer {{http://host/oidc}} \ ) does not hit this, since there is no context path to collide with.