CAS认证并限制指定用户的访问
我在 tomcat 6 服务器上运行的客户端 JSF 应用程序中使用 Jasig 的 CAS(中央身份验证服务)。我想仅限制数据库中指定的用户对应用程序的访问,而不是可以使用 CAS 服务进行身份验证的所有用户。当用户尝试登录时,我需要检查他的用户名是否也在我的数据库的表用户中,如果是,则允许访问该应用程序。否则,我想将用户重定向到页面“您无权访问应用程序的这一部分”。所以我也需要授权。 jsf 2.0 有没有好的方法来授权用户?预先感谢您的任何帮助/建议。
I'm using CAS (Central Authentication Service) from Jasig in a client JSF app running on tomcat 6 server. I would like to limit the access to the app just for the users specified in my database rather than all the users which can be authenticated using that CAS service. When the user attempts to log in, I need to check if his username is also in my database's table user and if it is - allow the access to the app. Otherwise, I would like to redirect user to a page "You don't have permission to access this part of the application". So I need authorization as well. Is there a good way to authorize the users in jsf 2.0? Thanks in advance for any help/suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您需要在 CAS 中设计一个自定义的身份验证处理程序类。理论上,您的处理程序将扩展此[1],执行所有必要的检查和数据库查找,然后能够返回一个信号,指示用户是否可以进行身份验证。
然后,您应该在 deploerConfigContext.xml 文件中引用您的自定义处理程序。
为了显示消息,您可以使用正确的消息代码抛出异常,以便消息出现在登录表单上方,或者您可以更改 spring webflow 并生成用户将被重定向到的新视图状态,如果他们无法访问。第一种方法更容易实现。
另一种方法是使用 persondir api 来利用 isUserInRole() 方法 [2]。
[1] http://developer.jasig.org/projects/cas/cas-server-core/cas-server/cas-server-core/apidocs/org/jasig/cas/身份验证/handler/support/AbstractUsernamePasswordAuthenticationHandler.html
[2] https:/ /wiki.jasig.org/pages/viewpage.action?pageId=47874068
Sounds like you need to design a custom Authentication Handler class in CAS. In theory, your handler would extend this [1], perform all the necessary checks and database look ups and will then be able to return a signal that indicates whether or not the user could authN.
You should then reference your custom handler in the deploerConfigContext.xml file.
For displaying the message, you could either throw an exception with the proper messages code, such that the message would appear above the login form, or you could alter the spring webflow and generate a new view-state which the user would be redirected to, if they fail to get access. The first approach is much easier to implement.
Another approach would be to take advantage of the isUserInRole() method [2] using the persondir api.
[1] http://developer.jasig.org/projects/cas/cas-server-core/cas-server/cas-server-core/apidocs/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.html
[2] https://wiki.jasig.org/pages/viewpage.action?pageId=47874068