Skip to content
Permalink
Browse files

[Slim] Distinction between basicBasic and basicBearer authentication (#…

…3621)

* [Slim] Distinction between basicBasic and basicBearer authentication

* [Slim] Update Petstore samples
  • Loading branch information...
chawax authored and wing328 committed Aug 13, 2019
1 parent b936d72 commit 99d85a39a3d29f0114ffa8698a6e19a589061005
@@ -71,18 +71,29 @@ class SlimRouter
{{#hasAuthMethods}}
{{#authMethods}}
// {{type}} security schema named '{{name}}'
{{#isBasic}}
{{#isBasicBasic}}
[
'type' => '{{type}}',
'isBasic' => true,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => false,
],
{{/isBasic}}
{{/isBasicBasic}}
{{#isBasicBearer}}
[
'type' => '{{type}}',
'isBasic' => true,
'isBearer' => true,
'isApiKey' => false,
'isOAuth' => false,
],
{{/isBasicBearer}}
{{#isApiKey}}
[
'type' => '{{type}}',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => true,
'isOAuth' => false,
'keyParamName' => '{{keyParamName}}',
@@ -95,6 +106,7 @@ class SlimRouter
[
'type' => '{{type}}',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -167,7 +179,7 @@ class SlimRouter

$middlewares[] = new TokenAuthentication($this->getTokenAuthenticationOptions([
'authenticator' => $basicAuthenticator,
'regex' => '/Basic\s+(.*)$/i',
'regex' => $authMethod['isBearer'] ? '/Bearer\s+(.*)$/i' : '/Basic\s+(.*)$/i',
'header' => 'Authorization',
'parameter' => null,
'cookie' => null,
@@ -266,4 +278,4 @@ class SlimRouter
return $this->slimApp;
}
}
{{/apiInfo}}
{{/apiInfo}}
@@ -160,6 +160,7 @@ class SlimRouter
[
'type' => 'http',
'isBasic' => true,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => false,
],
@@ -222,6 +223,7 @@ class SlimRouter
[
'type' => 'apiKey',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => true,
'isOAuth' => false,
'keyParamName' => 'api_key_query',
@@ -244,6 +246,7 @@ class SlimRouter
[
'type' => 'oauth2',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -266,6 +269,7 @@ class SlimRouter
[
'type' => 'oauth2',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -288,6 +292,7 @@ class SlimRouter
[
'type' => 'oauth2',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -310,6 +315,7 @@ class SlimRouter
[
'type' => 'oauth2',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -332,6 +338,7 @@ class SlimRouter
[
'type' => 'oauth2',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -354,6 +361,7 @@ class SlimRouter
[
'type' => 'apiKey',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => true,
'isOAuth' => false,
'keyParamName' => 'api_key',
@@ -376,6 +384,7 @@ class SlimRouter
[
'type' => 'oauth2',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -398,6 +407,7 @@ class SlimRouter
[
'type' => 'oauth2',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -420,6 +430,7 @@ class SlimRouter
[
'type' => 'oauth2',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => false,
'isOAuth' => true,
'scopes' => [
@@ -442,6 +453,7 @@ class SlimRouter
[
'type' => 'apiKey',
'isBasic' => false,
'isBearer' => false,
'isApiKey' => true,
'isOAuth' => false,
'keyParamName' => 'api_key',
@@ -625,7 +637,7 @@ public function __construct($settings = [])
$middlewares[] = new TokenAuthentication($this->getTokenAuthenticationOptions([
'authenticator' => $basicAuthenticator,
'regex' => '/Basic\s+(.*)$/i',
'regex' => $authMethod['isBearer'] ? '/Bearer\s+(.*)$/i' : '/Basic\s+(.*)$/i',
'header' => 'Authorization',
'parameter' => null,
'cookie' => null,

0 comments on commit 99d85a3

Please sign in to comment.
You can’t perform that action at this time.