SpringSecurity/Grails如何在运行时动态更改LoginUrlAuthenticationEntryPoint中的loginFormUrl? [英] SpringSecurity/Grails how to change loginFormUrl in LoginUrlAuthenticationEntryPoint dynamically at runtime?

查看:236
本文介绍了SpringSecurity/Grails如何在运行时动态更改LoginUrlAuthenticationEntryPoint中的loginFormUrl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在运行时动态地将后缀附加到配置值"grails.plugin.springsecurity.auth.loginFormUrl =/login/auth".因此,我认为我必须在类"LoginUrlAuthenticationEntryPoint"中更改字段"loginFormUrl".不赞成使用方法"setLoginFormUrl",所以我想知道如何在运行时更改它?我是否应该每次都需要注入/创建一个新的"LoginUrlAuthenticationEntryPoint"?我将如何/在何处这样做?

I need to append a suffix to the config value "grails.plugin.springsecurity.auth.loginFormUrl = /login/auth" dynamically at runtime. So I think I would have to change the field "loginFormUrl" in class "LoginUrlAuthenticationEntryPoint". The method "setLoginFormUrl" is deprecated so I wonder how can I change that at runtime? Should I inject/create a new "LoginUrlAuthenticationEntryPoint" everytime I need to do that? How/where would I do that?

推荐答案

因此,解决方案非常简单.我实现了自己的AuthenticationEntryPoint,它与LoginUrlAuthenticationEntryPoint非常相似,但是对defineUrlToUseForThisRequest方法具有不同的实现.

So the solution is quite simple. I implemented my own AuthenticationEntryPoint which is pretty much like the LoginUrlAuthenticationEntryPoint but has a different implementation of the determineUrlToUseForThisRequest method.

然后,您只需将其添加到您的资源.groovy:

Then you only have to add this to your resources.groovy:

authenticationEntryPoint(MyCustomEntryPoint) {}

这篇关于SpringSecurity/Grails如何在运行时动态更改LoginUrlAuthenticationEntryPoint中的loginFormUrl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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