Grails Spring Security - 登录后总是重定向到特定页面? [英] Grails Spring Security - Always redirect to specific page after login?

查看:155
本文介绍了Grails Spring Security - 登录后总是重定向到特定页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用spring security插件进行认证的grails应用程序。如果我的会话过期了,并且我点击了应用程序中的一个链接,它会将我带到登录屏幕,然后尝试重定向到我之前所在的页面。



我想将弹簧安全性配置为始终重定向到主页而不是用户点击的最后一页。有没有一种设置可以控制这种行为?

除了设置 defaultTargetUrl 您还需要告知Spring Security 强制使用该默认目标URL。你的 Config.groovy 应该看起来像这样:

  grails.plugins .springsecurity.successHandler.alwaysUseDefault = true 
grails.plugins.springsecurity.successHandler.defaultTargetUrl ='/ home'

您可以使用Spring Security API文档进一步研究 SavedRequestAwareAuthenticationSuccessHandler ,您是否需要它们。


$ b

更新:
插件的更新版本使用 grails.plugin 而不是 grails.plugins


I have a grails application that is using the spring security plugin for authentication. If my session expires, and I click a link in the application it takes me to the login screen then tries to redirect to the page I was on previously.

I would like to configure spring security to always redirect to the home page instead of the last page the user clicked on. Is there a setting that controls this behavior?

解决方案

Beyond setting the defaultTargetUrl you also need to tell Spring Security to force the use of that default target URL. Your Config.groovy should look something like this:

grails.plugins.springsecurity.successHandler.alwaysUseDefault = true
grails.plugins.springsecurity.successHandler.defaultTargetUrl = '/home'

You can research further options using the Spring Security API documentation for the SavedRequestAwareAuthenticationSuccessHandler, should you need them.

UPDATE: Later versions of the plugin use grails.plugin and not grails.plugins

这篇关于Grails Spring Security - 登录后总是重定向到特定页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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