간단한 해결책을 찾을 수있었습니다. 나는 단지 AuthenticationSuccessHandlerInterface
과 AuthenticationFailureHandlerInterface
을 구현하는 클래스를 작성해야했습니다.
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
class AuthenticationRestHandler implements AuthenticationSuccessHandlerInterface, AuthenticationFailureHandlerInterface {
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) {
return new Response('', Response::HTTP_UNAUTHORIZED);
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token) {
return new Response('', Response::HTTP_NO_CONTENT);
}
}
그런 다음 서비스로 등록하고 방화벽 용 처리기로 구성했습니다.
services:
security.authentication_rest_handler:
class: AuthenticationRestHandler
security:
firewalls:
rest:
pattern: ^rest
context: app
form_login:
check_path: /rest/login
provider: fos_userbundle
failure_handler: inspireon.security.authentication_rest_handler
success_handler: inspireon.security.authentication_rest_handler
username_parameter: login
password_parameter: password
문제를 해결하고 복잡한 인증 공급자 그래서
:-) 필요하지, 나는 완전히 새로운 사용자 지정 인증 공급자를 구현해야합니까?조금이라도 지나치다. 내가 바꾸어야 할 것은 전체 프로세스가 아닌 리다이렉트 대신 204/401을 보내는 청취자의 행동이다. –