Skip to content

fix: basic auth scheme supports case insensitivity#12539

Merged
Baoyuantop merged 9 commits into
apache:masterfrom
SkyeYoung:young/fix/basic-auth-case-insensitive
Aug 27, 2025
Merged

fix: basic auth scheme supports case insensitivity#12539
Baoyuantop merged 9 commits into
apache:masterfrom
SkyeYoung:young/fix/basic-auth-case-insensitive

Conversation

@SkyeYoung

@SkyeYoung SkyeYoung commented Aug 20, 2025

Copy link
Copy Markdown
Member

Description

The parsing part is reimplemented with reference to the following rfcs:

It should be noted that the original Http header field name part can handle case-insensitivity, so this PR focuses on processing the Http header field value part.

Which issue(s) this PR fixes:

Fixes #11837

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Aug 20, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements case-insensitive parsing for the "Basic" authentication scheme in HTTP Authorization headers, in compliance with RFC 7235, RFC 9110, and RFC 5234. The authentication scheme parsing now accepts various case combinations like "basic", "BASIC", "Basic", or "bASiC".

  • Replaced regex-based parsing with string splitting and case-insensitive comparison
  • Updated error messages for consistency
  • Added comprehensive test coverage for different case variations of the Basic auth scheme

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
apisix/plugins/basic-auth.lua Reimplemented auth header parsing with case-insensitive scheme detection
apisix/plugins/ldap-auth.lua Applied same case-insensitive parsing logic for consistency
t/plugin/basic-auth.t Added test cases for lowercase, uppercase, and mixed case auth schemes
t/plugin/ldap-auth.t Added test cases for lowercase, uppercase, and mixed case auth schemes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread apisix/plugins/basic-auth.lua Outdated
Comment thread apisix/plugins/ldap-auth.lua Outdated
Comment thread apisix/plugins/ldap-auth.lua
Comment thread t/plugin/basic-auth.t Outdated
@moonming

Copy link
Copy Markdown
Member

Totally agree with @bzp2010

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 25, 2025
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 25, 2025
@SkyeYoung
SkyeYoung requested a review from bzp2010 August 25, 2025 08:00

@bzp2010 bzp2010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Baoyuantop
Baoyuantop merged commit 08334a6 into apache:master Aug 27, 2025
43 of 47 checks passed
@SkyeYoung
SkyeYoung deleted the young/fix/basic-auth-case-insensitive branch August 27, 2025 03:47
jizhuozhi pushed a commit to jizhuozhi/apisix that referenced this pull request Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Basic authentication requests are case-insensitive both in scheme and parameters, but this isn't supported by APISIX

6 participants