Merge branch 'master' into PHRAS-2394-generate-subdef-for-mxf

This commit is contained in:
Nicolas Maillat
2019-01-24 01:15:29 +01:00
committed by GitHub
4 changed files with 30 additions and 8 deletions

View File

@@ -50,7 +50,7 @@
"alchemy/embed-bundle": "^0.3.4",
"alchemy/geonames-api-consumer": "~0.1.0",
"alchemy/mediavorus": "^0.4.4",
"alchemy/oauth2php": "1.0.0",
"alchemy/oauth2php": "1.1.0",
"alchemy/phlickr": "0.2.9",
"alchemy/phpexiftool": "^0.7.0",
"alchemy/rest-bundle": "^0.0.5",

12
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "253990d4c81f9ae5f78c6c1221d6cf29",
"content-hash": "adf4074eb26ea80d414430d4f7b61311",
"packages": [
{
"name": "alchemy-fr/tcpdf-clone",
@@ -337,16 +337,16 @@
},
{
"name": "alchemy/oauth2php",
"version": "1.0.0",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/alchemy-fr/oauth2-php.git",
"reference": "cb4fcb73e30ab54e0fb85a65b4d57147f7a0df15"
"reference": "801510972240555fa182813851efd96659d37a68"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/oauth2-php/zipball/cb4fcb73e30ab54e0fb85a65b4d57147f7a0df15",
"reference": "cb4fcb73e30ab54e0fb85a65b4d57147f7a0df15",
"url": "https://api.github.com/repos/alchemy-fr/oauth2-php/zipball/801510972240555fa182813851efd96659d37a68",
"reference": "801510972240555fa182813851efd96659d37a68",
"shasum": ""
},
"type": "library",
@@ -356,7 +356,7 @@
]
},
"notification-url": "https://packagist.org/downloads/",
"time": "2013-07-01T09:46:59+00:00"
"time": "2019-01-17T14:34:10+00:00"
},
{
"name": "alchemy/phlickr",

View File

@@ -7,6 +7,7 @@ main:
languages: []
key: ''
api_require_ssl: true
api_token_header: false
database:
host: 127.0.0.1
port: 3306

View File

@@ -537,7 +537,11 @@ class API_OAuth2_Adapter extends OAuth2
public function verifyAccessToken($scope = null, $exit_not_present = true, $exit_invalid = true, $exit_expired = true, $exit_scope = true, $realm = null)
{
$token_param = $this->getAccessTokenParams();
$apiTokenHeader = $this->app['conf']->get(['main', 'api_token_header']);
$useTokenHeader = $this->useTokenHeaderChoice($apiTokenHeader);
$token_param = $this->getAccessTokenParams($useTokenHeader);
// Access token was not provided
if ($token_param === false) {
@@ -808,4 +812,21 @@ class API_OAuth2_Adapter extends OAuth2
return false;
}
}
/**
* Get the correct constante to call on Oauth2
*
* @param $apiTokenHeader
* @return string
*/
private function useTokenHeaderChoice($apiTokenHeader)
{
if ($apiTokenHeader === true) {
return Oauth2::TOKEN_ONLY_IN_HEADER;
} elseif ($apiTokenHeader === false) {
return Oauth2::TOKEN_ONLY_IN_GETPOST;
} else {
return Oauth2::TOKEN_AUTO_FIND;
}
}
}