diff --git a/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl b/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl index 06e64ab3..96ae339a 100644 --- a/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +++ b/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl @@ -361,6 +361,10 @@ <#-- See: https://github.com/keycloakify/keycloakify/issues/534 --> are_same_path(path, ["login"]) && key == "password" + ) || ( + <#-- Remove realmAttributes added by https://github.com/jcputney/keycloak-theme-additional-info-extension for peace of mind. --> + are_same_path(path, []) && + key == "realmAttributes" ) > <#local out_seq += ["/*If you need '" + path?join(".") + "." + key + "' on " + pageId + ", please submit an issue to the Keycloakify repo*/"]> diff --git a/src/login/kcContext/KcContext.ts b/src/login/kcContext/KcContext.ts index 4e58f6da..be740d67 100644 --- a/src/login/kcContext/KcContext.ts +++ b/src/login/kcContext/KcContext.ts @@ -38,6 +38,8 @@ export type KcContext = | KcContext.SelectAuthenticator | KcContext.SamlPostForm; +assert(); + export declare namespace KcContext { export type Common = { themeVersion: string; @@ -172,7 +174,8 @@ export declare namespace KcContext { }; }; - export type Register = RegisterUserProfile.CommonWithLegacy & { + /* + export type Register_legacy = RegisterUserProfile.CommonWithLegacy & { pageId: "register.ftl"; register: { formData: { @@ -184,35 +187,44 @@ export declare namespace KcContext { }; }; }; + */ - export type RegisterUserProfile = RegisterUserProfile.CommonWithLegacy & { - pageId: "register-user-profile.ftl"; + export type Register = Common & { + pageId: "register.ftl"; profile: { - context: "REGISTRATION_PROFILE"; attributes: Attribute[]; attributesByName: Record; + html5DataAnnotations: Record; }; + /** + * Theses values are added by: https://github.com/jcputney/keycloak-theme-additional-info-extension + * A Keycloak Java extension used as dependency in Keycloakify. + */ + passwordPolicies?: PasswordPolicies; }; - export namespace RegisterUserProfile { - export type CommonWithLegacy = Common & { - url: { - registrationAction: string; - }; - passwordRequired: boolean; - recaptchaRequired: boolean; - recaptchaSiteKey?: string; - social: { - displayInfo: boolean; - providers?: { - loginUrl: string; - alias: string; - providerId: string; - displayName: string; - }[]; - }; + export type RegisterUserProfile = Common & { + pageId: "register-user-profile.ftl"; + profile: { + attributes: LegacyAttribute[]; + attributesByName: Record; }; - } + url: { + registrationAction: string; + }; + passwordRequired: boolean; + recaptchaRequired: boolean; + recaptchaSiteKey?: string; + social: { + displayInfo: boolean; + providers?: { + loginUrl: string; + alias: string; + providerId: string; + displayName: string; + }[]; + }; + }; export type Info = Common & { pageId: "info.ftl"; @@ -456,8 +468,8 @@ export declare namespace KcContext { export type UpdateUserProfile = Common & { pageId: "update-user-profile.ftl"; profile: { - attributes: Attribute[]; - attributesByName: Record; + attributes: LegacyAttribute[]; + attributesByName: Record; }; }; @@ -465,8 +477,8 @@ export declare namespace KcContext { pageId: "idp-review-user-profile.ftl"; profile: { context: "IDP_REVIEW"; - attributes: Attribute[]; - attributesByName: Record; + attributes: LegacyAttribute[]; + attributesByName: Record; }; }; @@ -516,13 +528,24 @@ export type Attribute = { displayName?: string; required: boolean; value?: string; - group?: string; - groupDisplayHeader?: string; - groupDisplayDescription?: string; + values?: string[]; + group?: { + html5DataAnnotations: Record; + displayHeader?: string; + name: string; + displayDescription?: string; + }; + html5DataAnnotations: Record; readOnly: boolean; validators: Validators; annotations: Record; - groupAnnotations: Record; + multivalued?: boolean; + /** + * NOTE: This is not a Keycloak attribute, it's a Keycloakify addition. + * usecase is to enable to hide the password confirmation if the theme is configured like that. + * SEE: https://github.com/keycloakify/keycloakify/issues/238#issuecomment-1874605774 + */ + hidden?: boolean; autocomplete?: | "on" | "off" @@ -580,6 +603,13 @@ export type Attribute = { | "photo"; }; +export type LegacyAttribute = Omit & { + group: string; + groupDisplayHeader?: string; + groupDisplayDescription?: string; + groupAnnotations: Record; +}; + export type Validators = Partial<{ length: Validators.DoIgnoreEmpty & Validators.Range; double: Validators.DoIgnoreEmpty & Validators.Range; @@ -639,4 +669,23 @@ export declare namespace Validators { assert>(); } -assert(); +export type PasswordPolicies = { + /** The minimum length of the password */ + length?: number; + /** The minimum number of digits required in the password */ + digits?: number; + /** The minimum number of lowercase characters required in the password */ + lowerCase?: number; + /** The minimum number of uppercase characters required in the password */ + upperCase?: number; + /** The minimum number of special characters required in the password */ + specialChars?: number; + /** Whether the password can contain the username */ + notUsername?: boolean; + /** Whether the password can contain the email address */ + notEmail?: boolean; + /** The number of previous passwords that cannot be reused */ + passwordHistory?: number; + /** The number of days before the password expires */ + forceExpiredPasswordChange?: number; +};