mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-03 18:51:53 +05:30
Variable name fixes + little changes to support unit tests
This commit is contained in:
parent
e563230f10
commit
3481ec8aa2
@ -134,7 +134,7 @@ class AuthServer
|
||||
'invalid_scope' => 400,
|
||||
'server_error' => 500,
|
||||
'temporarily_unavailable' => 400,
|
||||
'unsupported_grant_type' => 400,
|
||||
'unsupported_grant_type' => 501,
|
||||
'invalid_client' => 401,
|
||||
'invalid_grant' => 400,
|
||||
'invalid_credentials' => 400,
|
||||
@ -173,25 +173,27 @@ class AuthServer
|
||||
// respond with an HTTP 401 (Unauthorized) status code and
|
||||
// include the "WWW-Authenticate" response header field
|
||||
// matching the authentication scheme used by the client.
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($error === 'invalid_client') {
|
||||
$auth_scheme = null;
|
||||
$authScheme = null;
|
||||
$request = new Request();
|
||||
if ($request->server('PHP_AUTH_USER') !== null) {
|
||||
$auth_scheme = 'Basic';
|
||||
$authScheme = 'Basic';
|
||||
} else {
|
||||
$auth_header = $request->header('Authorization');
|
||||
if ($auth_header !== null) {
|
||||
if (strpos($auth_header, 'Bearer') === 0) {
|
||||
$auth_scheme = 'Bearer';
|
||||
} elseif (strpos($auth_header, 'Basic') === 0) {
|
||||
$auth_scheme = 'Basic';
|
||||
$authHeader = $request->header('Authorization');
|
||||
if ($authHeader !== null) {
|
||||
if (strpos($authHeader, 'Bearer') === 0) {
|
||||
$authScheme = 'Bearer';
|
||||
} elseif (strpos($authHeader, 'Basic') === 0) {
|
||||
$authScheme = 'Basic';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($auth_scheme !== null) {
|
||||
$headers[] = "WWW-Authenticate: $auth_scheme realm=\"\"";
|
||||
if ($authScheme !== null) {
|
||||
$headers[] = 'WWW-Authenticate: '.$authScheme.' realm=""';
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user