OpenAPITools / OpenAPITools/openapi-generator
[BUG][Dart] Basic and Bearer auth interceptors case-sensitive scheme comparison
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The OpenAPI specification defines the "scheme" property as:
The name of the HTTP Authorization scheme to be used in the Authorization header as defined in RFC7235. The values used SHOULD be registered in the IANA Authentication Scheme registry.
According to RFC7235 the name of the HTTP Authorization scheme must be a case-insensitive token:
It uses a case-insensitive token as a means to identify the authentication scheme, followed by additional information necessary for achieving authentication via that scheme.
RFC7617 - Basic Auth also agrees that the scheme must be a case-insensitive token:
Note that both scheme and parameter names are matched case-insensitively.
RFC6750 - Bearer Auth is contradicting because:
Unless otherwise noted, all the protocol parameter names and values are case sensitive.
and it also defines it as "Bearer".
The BasicAuthInterceptor and BearerAuthInterceptor only compare with "basic" and "bearer" which is against the specification and does not work for example when the OpenAPI specification was generated by Smithy.
openapi-generator version
openapi-generator-cli-7.0.1.jar
OpenAPI declaration file content or url
{
"openapi": "3.0.2",
"info": {
"title": "Sample",
"version": "1.0.0"
},
"paths": {
"/hello": {
"get": {
"operationId": "Hello",
"parameters": [
{
"name": "Name",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Hello 200 response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"greeting": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Name": {
"type": "string"
},
"HelloResponseContent": {
"type": "object",
"properties": {
"greeting": {
"type": "string"
}
}
}
},
"securitySchemes": {
"smithy.api.httpBearerAuth": {
"type": "http",
"description": "HTTP Bearer authentication",
"scheme": "Bearer"
}
}
},
"security": [
{
"smithy.api.httpBearerAuth": []
}
]
}
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
In order to compare the strings in a case-insensitive manner, make sure that both values are in lowercase.
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
Start with modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/basic_auth.mustache and bearer_auth.mustache, then generate a Dart Dio client from the supplied OpenAPI declaration. Check how each interceptor compares the Authorization scheme; done means Basic and Bearer schemes work regardless of capitalization, with generated output covering the reported Smithy-style value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100