dev
This commit is contained in:
@@ -68,16 +68,26 @@ class Auth
|
||||
$this->isResolvedUseNoAuth = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logged in succesfully.
|
||||
*/
|
||||
public function isResolved() : bool
|
||||
{
|
||||
return $this->isResolved;
|
||||
}
|
||||
|
||||
/**
|
||||
* No need to log in.
|
||||
*/
|
||||
public function isResolvedUseNoAuth() : bool
|
||||
{
|
||||
return $this->isResolvedUseNoAuth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which auth method to use. Fetches a username and password from headers and server parameters.
|
||||
* Then tries to log in.
|
||||
*/
|
||||
public function process(Request $request, Response $response)
|
||||
{
|
||||
$httpMethod = $request->getMethod();
|
||||
@@ -95,6 +105,8 @@ class Auth
|
||||
$authenticationMethod = 'Hmac';
|
||||
} else if ($request->hasHeader('X-Api-Key')) {
|
||||
$authenticationMethod = 'ApiKey';
|
||||
} else if ($request->hasHeader('X-Auth-Method')) {
|
||||
$authenticationMethod = $request->getHeader('X-Auth-Method');
|
||||
}
|
||||
|
||||
if (!$authenticationMethod) {
|
||||
|
||||
@@ -146,6 +146,13 @@ class Auth
|
||||
) : ?array {
|
||||
$isByTokenOnly = false;
|
||||
|
||||
if ($authenticationMethod) {
|
||||
if (!$this->metadata->get(['authenticationMethods', $authenticationMethod, 'api'])) {
|
||||
$GLOBALS['log']->warning("AUTH: Trying to use not allowed authentication method '{$authenticationMethod}'.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$authenticationMethod) {
|
||||
if ($request->getHeader('Espo-Authorization-By-Token') === 'true') {
|
||||
$isByTokenOnly = true;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"api": true
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
|
||||
"settings": {
|
||||
"isAvailable": true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"api": true
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
|
||||
"settings": {
|
||||
"isAvailable": true,
|
||||
"layout": {
|
||||
|
||||
Reference in New Issue
Block a user