CAS、Spring Security 和未受保护的页面
我在我的网站中使用 Spring Security + CAS,有些页面在不同的登录状态下显示不同的信息。
例如,链接:foo.com/index
匿名用户 - 通用页面布局+登录元素
经过身份验证的用户 - 自定义布局+注销元素
由于 Spring Security 目前不支持 CAS 网关功能,是否有任何解决方法来解决此问题?
谢谢, 威尔逊
I'm using Spring Security + CAS in my website and there are some pages present different information in different login status.
For example, link: foo.com/index
anonymous user - common page layout + login elements
authenticated user - customized layout + logout elements
Since Spring Security does not support CAS gateway feature at this moment, is there any workaround to resolve this problem?
Thanks,
Wilson
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 jsps 作为视图,则可以使用 Spring Security 的标记库来实现此目的(Spring Security 文档 - JSP 标签库)。
如果用户已登录,只需自定义登录/注销元素并使用不同的样式表来更改布局。
此讨论可能会有所帮助: http://forum.springsource.org/archive/ index.php/t-87737.html
If you are using jsps for your view you can use Spring Security's tag library to achieve this (Spring Security Docs - JSP Tag Libraries).
If the user is logged in just customize the login/logout elements and use a different style sheet to change layout.
This discussion may help: http://forum.springsource.org/archive/index.php/t-87737.html
Spring Security 标签库不适用于这种情况。在非安全页面中,登录用户将具有匿名用户角色 - 因此无法执行诸如用注销链接替换登录链接之类的操作。
请参阅:如何在通过 Spring Security 和 CAS 登录后在非安全 JSP 页面上显示登录的用户详细信息? 了解该问题的更详细说明。
Spring Security tag library does not work for this situation. Logged in user will have the anonymous user role when in a non-secured page - so doing something like replacing the login link with logout link is not possible.
See: How to show logged in user details on non-secured JSP page after login via Spring Security and CAS? for a more detailed explanation of the problem.