Skip to content

[BUG]: getBasicAuth #16668

@qu0cster

Description

@qu0cster

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

Metadata

Metadata

Assignees

Labels

5.0The issues we want to solve in the 5.0 releasebugA bug reportstatus: mediumMedium

Type

Projects

Status

Released

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions