mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
PHRAS-743 Fix Oauth with password grant
This commit is contained in:
@@ -16,9 +16,11 @@ use Alchemy\Phrasea\Authentication\Exception\RequireCaptchaException;
|
|||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
use Alchemy\Phrasea\Model\Entities\ApiApplication;
|
use Alchemy\Phrasea\Model\Entities\ApiApplication;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
|
use Alchemy\Phrasea\Model\Repositories\ApiApplicationRepository;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
class API_OAuth2_Adapter extends OAuth2
|
class API_OAuth2_Adapter extends OAuth2
|
||||||
{
|
{
|
||||||
@@ -684,9 +686,15 @@ class API_OAuth2_Adapter extends OAuth2
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OAUTH2_GRANT_TYPE_USER_CREDENTIALS:
|
case OAUTH2_GRANT_TYPE_USER_CREDENTIALS:
|
||||||
$application = ApiApplication::load_from_client_id($this->app, $client[0]);
|
/** @var ApiApplicationRepository $appRepository */
|
||||||
|
$appRepository = $this->app['repo.api-applications'];
|
||||||
|
$application = $appRepository->findByClientId($client[0]);
|
||||||
|
|
||||||
if ( ! $application->is_password_granted()) {
|
if (! $application) {
|
||||||
|
throw new NotFoundHttpException('Application not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $application->isPasswordGranted()) {
|
||||||
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_UNSUPPORTED_GRANT_TYPE, 'Password grant type is not enable for your client');
|
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_UNSUPPORTED_GRANT_TYPE, 'Password grant type is not enable for your client');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user