grails - SpringSecurity/Grails 如何在运行时动态更改 LoginUrlAuthenticationEntryPoint 中的 loginFormUrl?

标签 grails spring-security

我需要在运行时动态地为配置值“grails.plugin.springsecurity.auth.loginFormUrl =/login/auth”附加一个后缀。所以我想我必须更改“LoginUrlAuthenticationEntryPoint”类中的“loginFormUrl”字段。不推荐使用“setLoginFormUrl”方法,所以我想知道如何在运行时更改它?每次我需要这样做时,我是否应该注入(inject)/创建一个新的“LoginUrlAuthenticationEntryPoint”?我将如何/在哪里这样做?

最佳答案

所以解决方案非常简单。我实现了自己的 AuthenticationEntryPoint,它与 LoginUrlAuthenticationEntryPoint 非常相似,但对 determineUrlToUseForThisRequest 方法有不同的实现。

然后您只需将其添加到您的 resources.groovy 中:

authenticationEntryPoint(MyCustomEntryPoint) {}

关于grails - SpringSecurity/Grails 如何在运行时动态更改 LoginUrlAuthenticationEntryPoint 中的 loginFormUrl?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24953410/

相关文章:

java - Redis缓存主体对象问题

hibernate - Grails:如何区分一项交易与另一项交易?

grails - 使用UrlMappings重定向

grails - 在Intellij IDEA中重新创建Grails项目

grails - 使用指定的用户名登录int时获得 'Sorry, we were not able to find a user with that username and password.'消息

grails - 如何禁止在grails中访问 View 或 Controller

grails - LinkGenerator 对象在初始化 Grails 2.4.3 后为空

javascript - 直接在grails中获取angular js app-in-app的数据json文件

spring-boot - Spring Boot OAuth2 invalid_user_info_response

java - Spring Boot - @PreAuthorize 在测试中不起作用