Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: getBasicAuth #16668

Closed
qu0cster opened this issue Nov 26, 2024 · 2 comments · Fixed by #16717
Closed

[BUG]: getBasicAuth #16668

qu0cster opened this issue Nov 26, 2024 · 2 comments · Fixed by #16717
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@qu0cster
Copy link

Describe the bug
Basic auth with only username suddenly no longer working.

To Reproduce

  1. Use Postman or similar to call an endpoint with Basic Auth containing just username ("api key")
  2. Inside endpoint, call getBasicAuth and notice without the "password" it will return null instead of returning username and null as password

Provide minimal script to reproduce the issue

$apiKey = isset($this->request->getBasicAuth()['username']) ? $this->request->getBasicAuth()['username'] : '' ;
if (empty($apiKey)) {
    throw new \Exception('Api key is required');    
}

Expected behavior
Continue to pass along the username

Screenshots
If applicable, add screenshots to help explain your problem.

Details

  • Phalcon version: 5.8.0
  • PHP Version: 8.2.26
  • Operating System: Alpine
  • Installation type: pecl install phalcon
  • Zephir version (if any):
  • Server: Nginx
  • Other related info (Database, table schema): Mysql

Additional context
getBasicAuth been in the code for very long time; something recently change on Nov 19 2024 onward that doesn't match phalcon ChangeLog (maybe outside of Phalcon). The fix was to use getServer('PHP_AUTH_USER') instead of calling getBasicAuth

image

@qu0cster qu0cster added bug A bug report status: unverified Unverified labels Nov 26, 2024
@raicabogdan
Copy link
Contributor

raicabogdan commented Dec 12, 2024

I had some spare time to check this out, unfortunately I can not replicate this issue. Here's a screenshot of postman running the same exact minimal reproduction code provided

Screenshot from 2024-12-13 00-42-41

The fix you've mentioned doesn't exactly say much since under the hood, the same this->getServerArray() method is being used on both hasServer() and getServer() methods.

I will require more info on your setup. What version of nginx do you use? do you use it as a proxy to a backend web server or passing to php-fpm?

@niden niden mentioned this issue Mar 8, 2025
5 tasks
@niden niden linked a pull request Mar 8, 2025 that will close this issue
5 tasks
@niden
Copy link
Member

niden commented Mar 8, 2025

Resolved in #16717

Thank you @raicabogdan and @qu0cster

@niden niden closed this as completed Mar 8, 2025
@niden niden self-assigned this Mar 8, 2025
@niden niden added status: medium Medium 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels Mar 8, 2025
@niden niden added this to Phalcon v5 Mar 8, 2025
@niden niden moved this to Implemented in Phalcon v5 Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium
Projects
Status: Implemented
Development

Successfully merging a pull request may close this issue.

3 participants