You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "mehrdadbn9 (via GitHub)" <gi...@apache.org> on 2026/08/28 05:44:16 UTC
[PR] fix(basic-auth): keep colons in password when parsing auth header [apisix]
mehrdadbn9 opened a new pull request, #13895:
URL: https://github.com/apache/apisix/pull/13895
### Description
Fixes #13835 — RFC 7617 allows colons in credentials, but the basic-auth plugin split the decoded `user:password` header on **every** colon. A password such as `john:key` was truncated to `john`, so authentication failed.
### Root cause
`apisix/plugins/basic-auth.lua` used `ngx_re.split(decoded, ":")` (no limit), producing `{"johndoe-colon", "john", "key"}` for `johndoe-colon:john:key`. `res[2]` then captured only `john`.
### Fix
Split only on the first colon using `ngx_re.split(decoded, ":", nil, nil, 2)`, so `res[1]` is the username and `res[2]` is the remainder (colons included).
Verified with the real OpenResty `ngx.re.split`:
- buggy (no max): `johndoe-colon:john:key` -> username=`johndoe-colon`, password=`john` (truncated)
- fixed (max=2): `johndoe-colon:john:key` -> username=`johndoe-colon`, password=`john:key`
### Test
Added `t/plugin/basic-auth.t` TEST 2 exercising a colon-containing password. Also exported `extract_auth_header` as `_M.extract_auth_header` so the parsing is unit-testable.
### Checklist
- [x] Signed-off (Apache ICLA)
- [x] Minimal, scoped change
- [x] No docs change needed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(basic-auth): keep colons in password when parsing auth header [apisix]
Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on PR #13895:
URL: https://github.com/apache/apisix/pull/13895#issuecomment-6357877883
This PR is a duplicate of #13836, so I've closed it for now. Thank you for your contribution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(basic-auth): keep colons in password when parsing auth header [apisix]
Posted by "janiussyafiq (via GitHub)" <gi...@apache.org>.
janiussyafiq commented on PR #13895:
URL: https://github.com/apache/apisix/pull/13895#issuecomment-5487807338
Thanks for your contribution but the issue has already been fixed by https://github.com/apache/apisix/pull/13836. Can close this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(basic-auth): keep colons in password when parsing auth header [apisix]
Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on PR #13895:
URL: https://github.com/apache/apisix/pull/13895#issuecomment-6357932219
Closing as a duplicate of #13836, which already merged the same fix for #13835 (split basic-auth credentials on the first colon only so passwords may contain `:`).
Thanks for the contribution — the approach here matches what landed. Please feel free to open a follow-up if anything is still broken on current `master`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(basic-auth): keep colons in password when parsing auth header [apisix]
Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop closed pull request #13895: fix(basic-auth): keep colons in password when parsing auth header
URL: https://github.com/apache/apisix/pull/13895
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org