Pass totp.policy.getAlgorithmKey() to the freemarker template
This commit is contained in:
parent
699a3c8bf6
commit
21454b9168
@ -254,6 +254,17 @@
|
||||
<#attempt>
|
||||
return "${url.getLogoutUrl()}";
|
||||
<#recover>
|
||||
throw new Error("Failed to invoke url.getLogoutUrl() in the FreeMarker template");
|
||||
</#attempt>
|
||||
};
|
||||
</#if>
|
||||
|
||||
<#if pageId === "login-config-totp.ftl">
|
||||
out["totp"]["policy"]["getAlgorithmKey"] = function () {
|
||||
<#attempt>
|
||||
return "${totp.policy.getAlgorithmKey()}";
|
||||
<#recover>
|
||||
throw new Error("Failed to invoke totp.policy.getAlgorithmKey() in the FreeMarker template");
|
||||
</#attempt>
|
||||
};
|
||||
</#if>
|
||||
|
@ -419,6 +419,7 @@ export declare namespace KcContext {
|
||||
algorithm: "HmacSHA1" | "HmacSHA256" | "HmacSHA512";
|
||||
digits: number;
|
||||
lookAheadWindow: number;
|
||||
getAlgorithmKey: () => string;
|
||||
} & (
|
||||
| {
|
||||
type: "totp";
|
||||
|
@ -17,14 +17,6 @@ export default function LoginConfigTotp(props: PageProps<Extract<KcContext, { pa
|
||||
|
||||
const { msg, msgStr } = i18n;
|
||||
|
||||
// NOTE: We should edit the ftl_object_to_js_code_declaring_an_object.ftl
|
||||
// so that we have access to getAlgorithmKey()
|
||||
const algToKeyUriAlg: Record<(typeof kcContext)["totp"]["policy"]["algorithm"], string> = {
|
||||
"HmacSHA1": "SHA1",
|
||||
"HmacSHA256": "SHA256",
|
||||
"HmacSHA512": "SHA512"
|
||||
};
|
||||
|
||||
return (
|
||||
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("loginTotpTitle")}>
|
||||
<>
|
||||
@ -60,7 +52,7 @@ export default function LoginConfigTotp(props: PageProps<Extract<KcContext, { pa
|
||||
{msg("loginTotpType")}: {msg(`loginTotp.${totp.policy.type}`)}
|
||||
</li>
|
||||
<li id="kc-totp-algorithm">
|
||||
{msg("loginTotpAlgorithm")}: {algToKeyUriAlg?.[totp.policy.algorithm] ?? totp.policy.algorithm}
|
||||
{msg("loginTotpAlgorithm")}: {totp.policy.getAlgorithmKey()}
|
||||
</li>
|
||||
<li id="kc-totp-digits">
|
||||
{msg("loginTotpDigits")}: {totp.policy.digits}
|
||||
|
Loading…
x
Reference in New Issue
Block a user