Skip to content

Commit

Permalink
[dart] fix: Bearer and Basic auth interceptors case-insensitive schem…
Browse files Browse the repository at this point in the history
…e comparison (17073) (#17074)

* [dart] fix: Bearer and Basic auth interceptors case-insensitive scheme comparison

* Update samples
  • Loading branch information
karadzhov committed Mar 16, 2024
1 parent 3bd8974 commit 4f42373
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BasicAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'basic') || secure['type'] == 'basic');
for (final info in metadataAuthInfo) {
final authName = info['name'] as String;
final basicAuthInfo = authInfo[authName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BearerAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'bearer');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BasicAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'basic') || secure['type'] == 'basic');
for (final info in metadataAuthInfo) {
final authName = info['name'] as String;
final basicAuthInfo = authInfo[authName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BearerAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'bearer');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BasicAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'basic') || secure['type'] == 'basic');
for (final info in metadataAuthInfo) {
final authName = info['name'] as String;
final basicAuthInfo = authInfo[authName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BearerAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'bearer');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BasicAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'basic') || secure['type'] == 'basic');
for (final info in metadataAuthInfo) {
final authName = info['name'] as String;
final basicAuthInfo = authInfo[authName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BearerAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'bearer');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BasicAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'basic') || secure['type'] == 'basic');
for (final info in metadataAuthInfo) {
final authName = info['name'] as String;
final basicAuthInfo = authInfo[authName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BearerAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'bearer');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BasicAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'basic') || secure['type'] == 'basic');
for (final info in metadataAuthInfo) {
final authName = info['name'] as String;
final basicAuthInfo = authInfo[authName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BearerAuthInterceptor extends AuthInterceptor {
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme']?.toLowerCase() == 'bearer');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
Expand Down

0 comments on commit 4f42373

Please sign in to comment.