swagger-api / swagger-api/swagger-ui

Basic Authorization Header is not correctly encoded in requests to OIDC servers

Open
#8,073 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: Windows 10
  • Browser: Edge
  • Version: 102
  • Method of installation: Swashbuckle (ASP.NET Core)
  • Swagger-UI version: 4.10.3
  • Swagger/OpenAPI version: OpenAPI 3.0.1
Content & configuration
    "securitySchemes": {
      "oidc": {
        "type": "openIdConnect",
        "openIdConnectUrl": "https://example.com/.well-known/openid-configuration"
      }
    }
Describe the bug you're encountering

When using a ClientId or ClientSecret that contains non ASCII characters, then a compliant OIDC server will reject the Authorization Header from swagger-ui due to the clientid / clientsecret not being application/x-www-form-urlencoded, trying to interpret the unicode characters as ASCII. https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1

To reproduce...
  1. Open swagger
  2. Authenticate via client_credentials using a ClientSecret that contains § for example.
  3. OIDC server will respond with "invalid client credentials"
Expected behavior

If the OpenAPI specification states an openIdConnectUrl that specifies client_secret_basic, then the basic credentials should be application/x-www-form-urlencoded prior to base64 encoding. For OAuth2 servers, the most compatible option is probably the current behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named in the issue. Start by tracing Swagger UI's OpenID Connect client-credentials handling for the securitySchemes configuration, then compare Authorization-header encoding with RFC 6749 §2.3.1; done means the reported non-ASCII client secret works for OIDC client_secret_basic without changing OAuth2 behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.