Symfony로 만든 REST API에서 WSSE를 사용하여 사용자를 인증하려고 할 때 문제가 있습니다. 사이트 symfony wsse 인증 (http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html)에 대한 가이드를 따르고 튜토리얼 (http://obtao.com/blog/2013/06/configure-wsse-on-symfony-with-fosrestbundle/)을 완료했으며 사용자 관리가 FOSUserBundle로 처리됩니다.FOSUserBundle을 사용한 WSSE 인증
기본적으로 I wsse는 리소스/api에 액세스하는 요청을 인증합니다. 그래서 난 내 security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
wsse_secured:
pattern: /api/.*
stateless: true
wsse: true
anonymous : false
#dev:
# pattern: ^/(_(profiler|wdt)|css|images|js)/
# security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
그리고 액세스 할 수있는 내 자원/API/안녕, 내 요청 헤더에 추가 :
Authorization: Authorization profile=”UsernameToken”
x-wsse: UsernameToken Username="foo", PasswordDigest="9/dyW92Vp+mWEbyXeblRMqTQSJc=", Nonce="MDc1MGNkZjAwMjNmZjk2YQ==", Created="2014-04-17T16:18:34Z"
그러나 쿼리를 보낸 후 나는를 얻을 수 나에게 반환되는 오류 :
WSSE Login failed for foo. Why? No Authentication Provider found for token of class "Acme \ UserBundle \ Security \ Authentication \ Token \ WsseUserToken".
이 오류 메시지는 내 WsseListener 클래스에서 제기 예외입니다 :
try {
$authToken = $this->authenticationManager->authenticate($token);
$this->securityContext->setToken($authToken);
return;
} catch (AuthenticationException $failed) {
$failedMessage = 'WSSE Login failed for '.$token->getUsername().'. Why ? '.$failed->getMessage();
// Deny authentication with a '403 Forbidden' HTTP response
$response = new Response();
$response->setStatusCode(403);
$response->setContent($failedMessage);
$event->setResponse($response);
return;
}