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

Open
qu0cster opened this issue Nov 26, 2024 · 1 comment
Open

[BUG]: getBasicAuth #16668

qu0cster opened this issue Nov 26, 2024 · 1 comment
Labels
bug A bug report status: unverified Unverified

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

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: unverified Unverified
Projects
None yet
Development

No branches or pull requests

2 participants