Grails,SpringSecurity-如果未记录,则禁用重定向 [英] Grails, SpringSecurity - disable redirect if not logged

查看:71
本文介绍了Grails,SpringSecurity-如果未记录,则禁用重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何配置grails,使其在尝试访问安全资源时不将个人/用户重定向到登录页面.我只想发送401状态错误,指示重定向到首页.

How can I configure grails to not redirect person/user to login page if he try to access secure resource. I just want to send 401 status error insed of redirect to homepage.

推荐答案

您要配置的是authenticationEntryPoint,通常可以在spring/resources.groovy中完成.在Spring Security Core插件文档中很难找到它的符号,但这是引用它的Jira票证讨论:

What you want to do is configure the authenticationEntryPoint, which can usually be done in spring/resources.groovy. Having difficulty finding a notation for it in the Spring Security Core plugin documentation, but here's a Jira ticket discussion that references it:

https://github.com/alvarosanchez/grails-spring- security-rest/issues/51

在我们的一个项目中,我们希望发送回403响应,因此我们将此行添加到resources.groovy:

In one of our projects, we wanted to send back a 403 response, so we added this line to resources.groovy:

authenticationEntryPoint(org.springframework.security.web.authentication.Http403ForbiddenEntryPoint)

authenticationEntryPoint(org.springframework.security.web.authentication.Http403ForbiddenEntryPoint)

希望有帮助.

这篇关于Grails,SpringSecurity-如果未记录,则禁用重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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