SuiteCRM-Core/core/backend/Security/AppJsonLoginAuthenticator.php
Clemente Raposo 0c79491581 Use new symfony authenticator mechanism
- Add auth success listener to initialize legacy session
- Add password encoder to support legacy style encoding
- Add xsrf-token check to json_login
- enable authenticator_manager
2022-09-09 12:46:22 +01:00

50 lines
2.1 KiB
PHP

<?php
/**
* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
* Copyright (C) 2022 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
* "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display
* the words "Supercharged by SuiteCRM".
*/
namespace App\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Authenticator\JsonLoginAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
class AppJsonLoginAuthenticator extends JsonLoginAuthenticator
{
/**
* @param Request $request
* @return PassportInterface
*/
public function authenticate(Request $request): PassportInterface
{
$passport = parent::authenticate($request);
$csrfToken = $request->headers->get('x-xsrf-token');
$passport->addBadge(new CsrfTokenBadge('angular', $csrfToken));
return $passport;
}
}