Pass totp.policy.getAlgorithmKey() to the freemarker template
This commit is contained in:
parent
a9dc11c60d
commit
f2fcb553a5
@ -254,6 +254,17 @@
|
|||||||
<#attempt>
|
<#attempt>
|
||||||
return "${url.getLogoutUrl()}";
|
return "${url.getLogoutUrl()}";
|
||||||
<#recover>
|
<#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>
|
</#attempt>
|
||||||
};
|
};
|
||||||
</#if>
|
</#if>
|
||||||
|
@ -419,6 +419,7 @@ export declare namespace KcContext {
|
|||||||
algorithm: "HmacSHA1" | "HmacSHA256" | "HmacSHA512";
|
algorithm: "HmacSHA1" | "HmacSHA256" | "HmacSHA512";
|
||||||
digits: number;
|
digits: number;
|
||||||
lookAheadWindow: number;
|
lookAheadWindow: number;
|
||||||
|
getAlgorithmKey: () => string;
|
||||||
} & (
|
} & (
|
||||||
| {
|
| {
|
||||||
type: "totp";
|
type: "totp";
|
||||||
|
@ -17,14 +17,6 @@ export default function LoginConfigTotp(props: PageProps<Extract<KcContext, { pa
|
|||||||
|
|
||||||
const { msg, msgStr } = i18n;
|
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 (
|
return (
|
||||||
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("loginTotpTitle")}>
|
<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}`)}
|
{msg("loginTotpType")}: {msg(`loginTotp.${totp.policy.type}`)}
|
||||||
</li>
|
</li>
|
||||||
<li id="kc-totp-algorithm">
|
<li id="kc-totp-algorithm">
|
||||||
{msg("loginTotpAlgorithm")}: {algToKeyUriAlg?.[totp.policy.algorithm] ?? totp.policy.algorithm}
|
{msg("loginTotpAlgorithm")}: {totp.policy.getAlgorithmKey()}
|
||||||
</li>
|
</li>
|
||||||
<li id="kc-totp-digits">
|
<li id="kc-totp-digits">
|
||||||
{msg("loginTotpDigits")}: {totp.policy.digits}
|
{msg("loginTotpDigits")}: {totp.policy.digits}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user