2012-03-02 2 views
0

私は答えを探しましたが、それを見つけられませんでした。私がspring-security.xmlの<form-login>の中に<intercept-url pattern="/test*" access="ROLE_USER" />を追加すると、すべてが予想通りに機能します。この場合、両方のジョンには、まあ@RolesAllowedは機能しません

<http auto-config="true"> 
    <form-login login-page="/login.html" 
       default-target-url="/welcome.html" 
       authentication-failure-url="/loginfailed.html" /> 
    <logout logout-success-url="/logout.html" /> 
</http>   

<authentication-manager> 
    <authentication-provider> 
     <user-service> 
       <user name="john" password="doe" authorities="ROLE_ADMIN" /> 
       <user name="jane" password="doe" authorities="ROLE_USER" /> 
     </user-service> 
    </authentication-provider> 
</authentication-manager> 

<global-method-security secured-annotations="enabled" jsr250-annotations="enabled" /> 

:春のsecurity.xmlは、この(jsr250-注釈が有効になっている)ように見える場合

@RolesAllowed("ROLE_ADMIN") 
@RequestMapping(value="/test", method = RequestMethod.GET) 
public String test() { 
    return "test"; 
}   

をそして:しかし、私は@RolesAllowed("ROLE_ADMIN")は、メソッドのために行動したい場合Janeはテストページにアクセスできます。私は何か基本的なことを逃したと思う、ヘルプは高く評価されるだろう。

+0

ですか?かなり面白いです。私が自分の守備で言うことができるのは、私がロシア人だということだけです。 –

答えて

2

@RolesAllowed@PreAuthorize("hasAuthority('ROLE_ADMIN')")に変更し、global-method-securitypre-post-annotations="enabled"という属性で定義すると、機能しますか?

アプリケーションコンテキストの代わりにglobal-method-securityと他の構成をサーブレット構成で定義しているため、その動作もしないと考えています。

も同様の記事を参照してください:それは質問の文言についてのジョークhttps://stackoverflow.com/a/2525048/352708

関連する問題