私は以下のコードを適用しましたが、動作していませんでした。いずれか1つはこの解決策を教えてください。Spring @MVCコントローラにメソッドレベルのセキュリティを適用することは可能ですか?
コントローラ方法:
@Controller
public class UserController {
@Secured("ROLE_USER")
@RequestMapping(value="user/{userName}", method=RequestMethod.GET)
public @ResponseBody User getAvailability(@PathVariable String userName, HttpServletResponse response) { }
}
のApplicationContext-のsecurity.xml関連の設定:
<global-method-security secured-annotations="enabled" />
<http>
<intercept-url pattern="/user" requires-channel="https"/>
<http-basic/>
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<user-service>
<user password="password" name="manager" authorities="ROLE_MANAGER"/>
<user password="password" name="user" authorities="ROLE_USER"/>
</user-service>
</authentication-provider>
</authentication-manager>
こんにちは!あなたの返事に感謝します。私はそうしたやり方をしてきましたが、今では(新しいSpring Securityを使って)、同じアクセスを行うことができるようです。メソッドレベルで知っているのは、xml設定を直接行うのではなく、私たちはそれを特定の方法のために示すことができます。 – Channa