我使用escapewsseauthenticationbundle来保护我的API(使用FOSRestBundle和FOSUserBundle)时遇到问题。使用我的security.yml,登录总是失败并返回401状态代码。
我使用chrome rest控制台和Teria的wsse标头生成器来验证和访问我的资源。
应用程序/ security.yml
encoders:
FOS\UserBundle\Model\UserInterface: sha512
providers:
fos_userbundle:
id: fos_user.user_provider.username
wsse_secured:
pattern: ^/api/.*
wsse:
lifetime: 300 #lifetime of nonce
realm: "Secured API" #identifies the set of resources to which the authentication information will apply (WWW-Authenticate)
profile: "UsernameToken" #WSSE profile (WWW-Authenticate)
encoder: #digest algorithm
algorithm: sha512
encodeHashAsBase64: true
iterations: 1
anonymous: true
provider: fos_userbundle
access_control:
- { path: ^/api.*, role: ROLE_USER }
- { path: ^/, role: ROLE_USER }
有人知道如何解决它吗?
谢谢!