Fix totp manual link for proxy mode

Closes #11774
This commit is contained in:
Robert Dey 2022-08-02 14:06:00 +02:00 committed by Pedro Igor
parent 3e77a007b6
commit 4df73714e0

View file

@ -228,7 +228,7 @@ public class FreeMarkerLoginFormsProvider implements LoginFormsProvider {
switch (page) {
case LOGIN_CONFIG_TOTP:
attributes.put("totp", new TotpBean(session, realm, user, uriInfo.getRequestUriBuilder()));
attributes.put("totp", new TotpBean(session, realm, user, getTotpUriBuilder()));
break;
case LOGIN_RECOVERY_AUTHN_CODES_CONFIG:
attributes.put("recoveryAuthnCodesConfigBean", new RecoveryAuthnCodesBean());
@ -306,6 +306,18 @@ public class FreeMarkerLoginFormsProvider implements LoginFormsProvider {
return session.getProvider(UserProfileProvider.class).getConfiguration() != null;
}
/**
* Get sure that correct hostname and path is used for totp form.
* Relevant when running in proxy mode.
*
* @return UriBuilder with configured hostname and path set
*/
private UriBuilder getTotpUriBuilder() {
return uriInfo.getBaseUriBuilder()
.path(uriInfo.getRequestUri().getPath())
.replaceQuery(uriInfo.getRequestUri().getQuery());
}
@Override
public Response createForm(String form) {
Theme theme;