swagger-api / swagger-api/swagger-ui
Swagger does not set Authorization Bearer header in safari when page is secured by Http Auth
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: macOS
- Browser: safari, but not chrome
- Version: 14.0.3
- Method of installation: dist assets
- Swagger-UI version: 3.43.0
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
- I have installed Swagger UI Bundle under
/explorerURL and secured it with HTTP Auth. - API is secured with OAuth2 Authorization Code flow, but not HTTP Auth.
Example Swagger/OpenAPI definition:
openapi: 3.0.2
// ...
components:
securitySchemes:
oauth2:
type: oauth2
flows:
authorizationCode:
authorizationUrl: /auth/authorize
tokenUrl: /auth/token
refreshUrl: /auth/token
scopes: { } # No scopes in API for now
security:
- oauth2: []
Swagger-UI configuration options:
var swagger = SwaggerUIBundle({
dom_id: '#swagger-root',
url: '{{ apiDefinitionFilename }}',
oauth2RedirectUrl: '{{ url('api_swagger_oauth2_redirect') }}',
deepLinking: true,
filter: true,
displayRequestDuration: true,
persistAuthorization: true,
showMutatedRequest: true
});
swagger.initOAuth({
clientId: '{{ client.key }}',
clientSecret: '{{ client.secret }}',
usePkceWithAuthorizationCodeGrant: true
});
Describe the bug you're encountering
In Safari browser, Swagger UI Bundle does not send oauth token after valid authorization. Header Authorization is ovewritten by Authorization: Basic .... instead of Authorization: Bearer ...
Chome browser sends correct Authorization header at the same time.
To reproduce...
Steps to reproduce the behavior:
- Enter swagger UI URL secured by HTTP AUTH.
- Make an OAuth authorization in Swagger UI.
- Make an authorized request to API (secured by OAuth token).
- See inspector in web browser. The URL sent to server is different than generated curl request.
Expected behavior
Http Authorization header is not overriden by Authorization: Basic ... in case when Swagger is secured by HTTP AUTH.
Screenshots

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with Swagger UI 3.43.0 dist assets in Safari 14.0.3: secure the UI with HTTP Auth, authorize through the OpenAPI 3.0 OAuth2 authorization-code flow, and inspect the resulting API request. Compare Safari with Chrome and verify that the request sends the OAuth Bearer token rather than an HTTP Auth Basic header.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- authentication, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100