diff --git a/src/common-messages.json b/src/common-messages.json index 12c1dfc791..33ba4f7e49 100644 --- a/src/common-messages.json +++ b/src/common-messages.json @@ -56,6 +56,14 @@ "required": "Required field", "maxLength": "Max length {{length}}", - "createRealm": "Create Realm" + "createRealm": "Create Realm", + + "Sunday": "Sunday", + "Monday": "Monday", + "Tuesday": "Tuesday", + "Wednesday": "Wednesday", + "Thursday": "Thursday", + "Friday": "Friday", + "Saturday": "Saturday" } } diff --git a/src/user-federation/KerberosSettingsCache.tsx b/src/user-federation/KerberosSettingsCache.tsx index e00a2b325f..d844b3ba5d 100644 --- a/src/user-federation/KerberosSettingsCache.tsx +++ b/src/user-federation/KerberosSettingsCache.tsx @@ -1,16 +1,55 @@ -import { Form, FormGroup, Select, SelectOption } from "@patternfly/react-core"; +import { + FormGroup, + Select, + SelectOption, + SelectVariant, + TextInput, +} from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; -import React from "react"; import { HelpItem } from "../components/help-enabler/HelpItem"; +import React, { useState } from "react"; +import { useForm, Controller } from "react-hook-form"; +import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation"; +import { FormAccess } from "../components/form-access/FormAccess"; export const KerberosSettingsCache = () => { const { t } = useTranslation("user-federation"); const helpText = useTranslation("user-federation-help").t; + const [isCachePolicyDropdownOpen, setIsCachePolicyDropdownOpen] = useState( + false + ); + const [isEvictionHourDropdownOpen, setIsEvictionHourDropdownOpen] = useState( + false + ); + const [ + isEvictionMinuteDropdownOpen, + setIsEvictionMinuteDropdownOpen, + ] = useState(false); + const [isEvictionDayDropdownOpen, setIsEvictionDayDropdownOpen] = useState( + false + ); + + const { control, register } = useForm(); + + const hourOptions = [ + , + ]; + for (let index = 1; index <= 24; index++) { + hourOptions.push(); + } + + const minuteOptions = [ + , + ]; + for (let index = 1; index <= 60; index++) { + minuteOptions.push(); + } + return ( <> {/* Cache settings */} -
+ { } fieldId="kc-cache-policy" > - + ( + + )} + > - + + {/* TODO: Field shows only if cache policy is EVICT_WEEKLY */} + + } + fieldId="kc-eviction-day" + > + ( + + )} + > + + + {/* TODO: Field shows only if cache policy is EVICT_WEEKLY or EVICT_DAILY */} + {/* TODO: Investigate whether this should be a number field instead of a dropdown/text field */} + + } + fieldId="kc-eviction-hour" + > + ( + + )} + > + + + {/* TODO: Field shows only if cache policy is EVICT_WEEKLY or EVICT_DAILY */} + {/* TODO: Investigate whether this should be a number field instead of a dropdown/text field */} + + } + fieldId="kc-eviction-minute" + > + ( + + )} + > + + + {/* TODO: Field shows only if cache policy is MAX_LIFESPAN */} + + } + fieldId="kc-max-lifespan" + > + + +
); }; diff --git a/src/user-federation/KerberosSettingsRequired.tsx b/src/user-federation/KerberosSettingsRequired.tsx index eb61e0af63..5d973c034d 100644 --- a/src/user-federation/KerberosSettingsRequired.tsx +++ b/src/user-federation/KerberosSettingsRequired.tsx @@ -1,23 +1,29 @@ import { - Form, FormGroup, Select, SelectOption, + SelectVariant, Switch, TextInput, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; -import React from "react"; import { HelpItem } from "../components/help-enabler/HelpItem"; +import React, { useState } from "react"; +import { useForm, Controller } from "react-hook-form"; +import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation"; +import { FormAccess } from "../components/form-access/FormAccess"; export const KerberosSettingsRequired = () => { const { t } = useTranslation("user-federation"); const helpText = useTranslation("user-federation-help").t; + const [isEditModeDropdownOpen, setIsEditModeDropdownOpen] = useState(false); + const { register, control } = useForm(); + return ( <> {/* Required settings */} -
+ { isRequired type="text" id="kc-console-display-name" - name="kc-console-display-name" - // value={value1} - // onChange={this.handleTextInputChange1} + name="consoleDisplayName" + ref={register} /> @@ -56,9 +61,8 @@ export const KerberosSettingsRequired = () => { isRequired type="text" id="kc-kerberos-realm" - name="kc-kerberos-realm" - // value={value1} - // onChange={this.handleTextInputChange1} + name="kerberosRealm" + ref={register} /> @@ -78,9 +82,8 @@ export const KerberosSettingsRequired = () => { isRequired type="text" id="kc-server-principal" - name="kc-server-principal" - // value={value1} - // onChange={this.handleTextInputChange1} + name="serverPrincipal" + ref={register} /> @@ -100,9 +103,8 @@ export const KerberosSettingsRequired = () => { isRequired type="text" id="kc-key-tab" - name="kc-key-tab" - // value={value1} - // onChange={this.handleTextInputChange1} + name="keyTab" + ref={register} /> @@ -118,14 +120,22 @@ export const KerberosSettingsRequired = () => { fieldId="kc-debug" hasNoPaddingTop > - undefined as any} - label={t("common:on")} - labelOff={t("common:off")} - /> + {" "} + ( + + )} + > { fieldId="kc-allow-password-authentication" hasNoPaddingTop > - undefined as any} - label={t("common:on")} - labelOff={t("common:off")} - /> + ( + + )} + > + {/* TODO: Field shows only if allowPasswordAuthentication is TRUE */} } fieldId="kc-edit-mode" > - + {" "} + ( + + )} + > { fieldId="kc-update-first-login" hasNoPaddingTop > - undefined as any} - label={t("common:on")} - labelOff={t("common:off")} - /> + ( + + )} + > - +
); }; diff --git a/src/user-federation/LdapSettingsSearching.tsx b/src/user-federation/LdapSettingsSearching.tsx index e96750db6c..95cef95bd3 100644 --- a/src/user-federation/LdapSettingsSearching.tsx +++ b/src/user-federation/LdapSettingsSearching.tsx @@ -22,7 +22,7 @@ export const LdapSettingsSearching = () => { label={t("editMode")} labelIcon={ diff --git a/src/user-federation/help.json b/src/user-federation/help.json index b4cfa10f9f..db410c9a67 100644 --- a/src/user-federation/help.json +++ b/src/user-federation/help.json @@ -13,7 +13,7 @@ "bindDnHelp": "DN of the LDAP admin, which will be used by Keycloak to access LDAP server", "bindCredentialsHelp": "Password of LDAP admin. This field is able to obtain its value from vault, use ${vault.ID} format.", - "editModeHelp": "READ_ONLY is a read-only LDAP store. WRITABLE means data will be synced back to LDAP on demand. UNSYNCED means user data will be imported, but not synced back to LDAP.", + "editModeLdapHelp": "READ_ONLY is a read-only LDAP store. WRITABLE means data will be synced back to LDAP on demand. UNSYNCED means user data will be imported, but not synced back to LDAP.", "usersDNHelp": "Full DN of LDAP tree where your users are. This DN is the parent of LDAP users. It could be for example 'ou=users,dc=example,dc=com' assuming that your typical user will have DN like 'uid='john',ou=users,dc=example,dc=com'", "usernameLdapAttributeHelp": "Name of LDAP attribute, which is mapped as Keycloak username. For many LDAP server vendors it can be 'uid'. For Active directory it can be 'sAMAccountName' or 'cn'. The attribute should be filled for all LDAP user records you want to import from LDAP to Keycloak.", "rdnLdapAttributeHelp": "Name of LDAP attribute, which is used as RDN (top attribute) of typical user DN. Usually it's the same as Username LDAP attribute, however it is not required. For example for Active directory, it is common to use 'cn' as RDN attribute when username attribute might be 'sAMAccountName'.", @@ -33,6 +33,10 @@ "useKerberosForPasswordAuthenticationHelp": "User Kerberos login module for authenticate username/password against Kerberos server instead of authenticating against LDAP server with Directory Service API", "cachePolicyHelp": "Cache Policy for this storage provider. 'DEFAULT' is whatever the default settings are for the global cache. 'EVICT_DAILY' is a time of day every day that the cache will be invalidated. 'EVICT_WEEKLY' is a day of the week and time the cache will be invalidated. 'MAX_LIFESPAN' is the time in milliseconds that will be the lifespan of a cache entry.", + "evictionDayHelp": "Day of the week the entry will become invalid", + "evictionHourHelp": "Hour of the day the entry will become invalid", + "evictionMinuteHelp": "Minute of the hour the entry will become invalid", + "maxLifespanHelp": "Max lifespan of cache entry in milliseconds", "enableLdapv3PasswordHelp": "Use the LDAPv3 Password Modify Extended Operation (RFC-3062). The password modify extended operation usually requires that LDAP user already has password in the LDAP server. So when this is used with 'Sync Registrations', it can be good to add also 'Hardcoded LDAP attribute mapper' with randomly generated initial password.", "validatePasswordPolicyHelp": "Determines if Keycloak should validate the password with the realm password policy before updating it", @@ -46,6 +50,7 @@ "keyTabHelp": "Location of Kerberos KeyTab file containing the credentials of server principal. For example, /etc/krb5.keytab", "debugHelp": "Enable/disable debug logging to standard output for Krb5LoginModule", "allowPasswordAuthenticationHelp": "Enable/disable possibility of username/password authentication against Kerberos database", + "editModeKerberosHelp": "READ_ONLY means that password updates are not allowed and user always authenticates with Kerberos password. UNSYNCED means that the user can change the password in the Keycloak database and this one will be used instead of the Kerberos password", "updateFirstLoginHelp": "Update profile on first login" } } diff --git a/src/user-federation/messages.json b/src/user-federation/messages.json index b485d4c2cc..58b446d2c8 100644 --- a/src/user-federation/messages.json +++ b/src/user-federation/messages.json @@ -52,6 +52,10 @@ "cacheSettings": "Cache settings", "cachePolicy": "Cache policy", + "evictionDay": "Eviction day", + "evictionHour": "Eviction hour", + "evictionMinute": "Eviction minute", + "maxLifespan": "Max lifespan", "advancedSettings": "Advanced settings", "enableLdapv3Password": "Enable the LDAPv3 password modify extended operation",