使用spring security根据用户ROLES设置自定义的登录后目标 [英] Setting custom Post-Login Destinations based on user ROLES using spring security

查看:181
本文介绍了使用spring security根据用户ROLES设置自定义的登录后目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中根据用户ROLES设置自定义的登录后目的地。例如:
如果尝试访问受保护资源不提示表单登录,我想根据不同的角色显示不同的页面。
使用target-url我不能这样做。
如何使用Spring安全性来做到这一点?

I want to set custom Post-Login Destinations based on user ROLES in my application. for example : If a form login isn't prompted by an attempt to access a protected resource, I want to show different pages, based on different roles. by using target-url I can't do this. how can I do this by using Spring security ?

推荐答案

在Spring Security 3.0中,您可以实现自定义< a href =http://static.springsource.org/spring-security/site/apidocs/org/springframework/security/web/authentication/AuthenticationSuccessHandler.html =noreferrer> AuthenticationSuccessHandler (通常通过扩展 SavedRequestAwareAuthenticationSuccessHandler ),并配置< form-login> 使用 authentication-success-handler-ref 属性。

In Spring Security 3.0, you can implement a custom AuthenticationSuccessHandler (usually by extending SavedRequestAwareAuthenticationSuccessHandler), and configure <form-login> to use it with authentication-success-handler-ref attribute.

这篇关于使用spring security根据用户ROLES设置自定义的登录后目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆