如何使用Java EE安全@CustomFormAuthenticationMechanismDefinition重定向到原始请求URL [英] How can I redirect to the original request url with Java EE Security @CustomFormAuthenticationMechanismDefinition

查看:160
本文介绍了如何使用Java EE安全@CustomFormAuthenticationMechanismDefinition重定向到原始请求URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用

@FormAuthenticationMechanismDefinition(
        loginToContinue = @LoginToContinue(
                loginPage = "/login.xhtml",
                useForwardToLogin = false))

然后,成功登录后,用户将被重定向到他们请求的原始页面.

then, after a successful login, the user gets redirected to the original page they requested.

但是我想对身份验证表单进行更多控制,所以我使用的是:

But I would like some more control over the authentication form, so instead I am using:

@CustomFormAuthenticationMechanismDefinition(
        loginToContinue = @LoginToContinue(
                loginPage = "/login.xhtml",
                useForwardToLogin = false))

我正在关注以下示例:

I was following this example: https://rieckpil.de/howto-simple-form-based-authentication-for-jsf-2-3-with-java-ee-8-security-api/

但是问题是,现在,成功登录后,总是将用户重定向到index.xhtml而不是他们请求的原始页面.

But the problem is that now, after successful login, the user is always redirected to index.xhtml instead of to the original page they requested.

是否可以通过CustomFormAuthenticationMechanismDefinition实现相同的行为?

Is there a way to achieve the same behavior with a CustomFormAuthenticationMechanismDefinition?

推荐答案

我通过将ajax="false"添加到我的p:commandButton使其正常工作. Java EE安全框架正确设置了重定向头,但PrimeFaces p:commandButton忽略了它.

I got it working by adding ajax="false" to my p:commandButton. The Java EE Security Framework was setting the redirect header correctly, but the PrimeFaces p:commandButton ignored it.

这篇关于如何使用Java EE安全@CustomFormAuthenticationMechanismDefinition重定向到原始请求URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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