Skip to content

OAuth Flow Metadata Discovery & DCR inconsistent behavior per call for HTTP header allow origin #752

@symdeb

Description

@symdeb

Describe the bug

To set the response headers on a hosted website (with PHP) , setting the header
Header set Access-Control-Allow-Origin "*" result in that Metadata Discovery failure.
This same header MUST be set for /register call to pass (when not set it fails) when it send
OPTIONS to the site. This is a catch22. It's not possible to set different security headers per API call.

To Reproduce

A. On a local machine run the inspector
B. Install an OAUTH2 server that also supports DCR.
C. Run the inspector Oauth2 cycle (keep client ID empty otherwise inspector will not call the register endpoint)

  1. Add to .htaccess on the server (website) .htaccess
    Header set Access-Control-Allow-Origin "*"
    Inspector Metadiscovery fails with
    Error: Failed to discover OAuth metadata

  2. Remove the header.
    Inspector Metadiscovery passes, shows
    "OAuth Metadata Sources"

  3. Going next, client registration to API endpoint /register fails with
    Error: Failed to fetch

  4. Add to .htaccess on the website
    Header set Access-Control-Allow-Origin "*"
    Repeat next step for client registration
    call /register
    register passes

  5. From here next steps continue normally (login screen on the authentication site...etc..)

NO OTHER CHANGES THEN ADD/REMOVE THE HEADER IN .HTACCESS WERE MADE

It seems Inconsistent behavior/expectation of inspector for expected header per API call
While the call to /..well-known/ discovering the authorization server does not accept this header, the PREFLIGHT OPTIONS call to /register call requires it.

Expected behavior
consistent behavior of inspector for expected headers per API call.
suggest remove the requirement for inspector to check on the Access-Control-Allow-Origin header, it may cause multiple issues with different servers.

Logs
N/A

Additional context
[1] The MCP server is hosted on hostgator.
[2] For Header set Access-Control-Allow-Origin "*" only one option is allowed. Since the caller can be from any site , "*" is used here.
[3] the PHP set header () function has no effect on returned headers, only the one define in .htaccess or in server's configuration files works. These are STATIC values and CANNOT be dynamically changed based on the calling IP/hostm url or call (OPTION, GET or POST).
[3] Why does a returned Header set Access-Control-Allow-Origin "*" fail for the call to .welknown url ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    authIssues and PRs related to authorizationbugSomething isn't workingwaiting on submitterWaiting for the submitter to provide more info

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions