theme.keycloak.v2.admin.resources.assets.UserFederationLdapForm-Dau3yBfR.js Maven / Gradle / Ivy
import{jsxs as u,jsx as e,Fragment as L}from"react/jsx-runtime";import{u as U,a as A,c as w,f as F,ab as N,F as D,y as d,ac as c,ad as p,ae as g,a4 as f,v as T,i as V,b5 as x,b6 as q,U as S,bq as R,k as K,cQ as _,aj as j,d as $,aH as B,b1 as M,aI as G,r as W,dY as Y}from"./main-C7ps2lmX.js";import{F as I,a as Q}from"./FormAccess-DyLNkc18.js";import{W as k,S as J}from"./SettingsCache-BECJJhg-.js";import{useState as E,useEffect as X}from"react";import{i as Z}from"./isEqual-BWOcMitS.js";const ee=["connectionUrl","bindDn","bindCredential","useTruststoreSpi","connectionTimeout","startTls","authType"],z=t=>{const l={};return ee.forEach(i=>{const a=_(t.getValues(),`config.${i}`);l[i]=Array.isArray(a)?a[0]:""}),l},ae=({form:t,id:l,showSectionHeading:i=!1,showSectionDescription:a=!1})=>{const{adminClient:o}=U(),{t:n}=A(),{realm:r}=w(),{addAlert:b,addError:h}=F(),C=!!l,s=async v=>{try{const P=z(t);await o.realms.testLDAPConnection({realm:r},{...P,action:v,componentId:l}),b(n("testSuccess"),K.success)}catch(P){h("testError",P)}},[m,y]=E(!1),H=N({control:t.control,name:"config.authType",defaultValue:["simple"]});return u(D,{...t,children:[i&&e(k,{title:n("connectionAndAuthenticationSettings"),description:n("ldapConnectionAndAuthorizationSettingsDescription"),showDescription:a}),u(I,{role:"manage-realm",isHorizontal:!0,children:[e(d,{name:"config.connectionUrl.0",label:n("connectionURL"),labelIcon:n("consoleDisplayConnectionUrlHelp"),type:"url",rules:{required:n("validateConnectionUrl")}}),e(c,{label:n("enableStartTls"),labelIcon:e(p,{helpText:n("enableStartTlsHelp"),fieldLabelId:"enableStartTls"}),fieldId:"kc-enable-start-tls",hasNoPaddingTop:!0,children:e(g,{name:"config.startTls",defaultValue:["false"],control:t.control,render:({field:v})=>e(f,{id:"kc-enable-start-tls","data-testid":"enable-start-tls",isDisabled:!1,onChange:(P,O)=>v.onChange([`${O}`]),isChecked:v.value[0]==="true",label:n("on"),labelOff:n("off"),"aria-label":n("enableStartTls")})})}),e(T,{id:"useTruststoreSpi",name:"config.useTruststoreSpi[0]",label:n("useTruststoreSpi"),labelIcon:n("useTruststoreSpiHelp"),controller:{defaultValue:"always"},options:[{key:"always",value:n("always")},{key:"never",value:n("never")}]}),e(c,{label:n("connectionPooling"),labelIcon:e(p,{helpText:n("connectionPoolingHelp"),fieldLabelId:"connectionPooling"}),fieldId:"kc-connection-pooling",hasNoPaddingTop:!0,children:e(g,{name:"config.connectionPooling",defaultValue:["false"],control:t.control,render:({field:v})=>e(f,{id:"kc-connection-pooling","data-testid":"connection-pooling",isDisabled:!1,onChange:(P,O)=>v.onChange([`${O}`]),isChecked:v.value[0]==="true",label:n("on"),labelOff:n("off"),"aria-label":n("connectionPooling")})})}),e(d,{name:"config.connectionTimeout.0",label:n("connectionTimeout"),labelIcon:n("connectionTimeoutHelp"),type:"number",min:0}),e(c,{fieldId:"kc-test-connection-button",children:e(V,{variant:"secondary",id:"kc-test-connection-button","data-testid":"test-connection-button",onClick:()=>s("testConnection"),children:n("testConnection")})}),e(c,{label:n("bindType"),labelIcon:e(p,{helpText:n("bindTypeHelp"),fieldLabelId:"bindType"}),fieldId:"kc-bind-type",isRequired:!0,children:e(g,{name:"config.authType[0]",defaultValue:"simple",control:t.control,render:({field:v})=>u(x,{toggleId:"kc-bind-type",onToggle:()=>y(!m),isOpen:m,onSelect:P=>{v.onChange(P),y(!1)},selections:v.value,variant:q.single,"data-testid":"ldap-bind-type","aria-label":n("selectBindType"),children:[e(S,{value:"simple",children:"simple"}),e(S,{value:"none",children:"none"})]})})}),Z(H,["simple"])&&u(L,{children:[e(d,{name:"config.bindDn.0",label:n("bindDn"),labelIcon:n("bindDnHelp"),rules:{required:n("validateBindDn")}}),e(R,{name:"config.bindCredential.0",label:n("bindCredentials"),labelIcon:n("bindCredentialsHelp"),hasReveal:!C,rules:{required:n("validateBindCredentials")}})]}),e(c,{fieldId:"kc-test-auth-button",children:e(V,{variant:"secondary",id:"kc-test-auth-button","data-testid":"test-auth-button",onClick:()=>s("testAuthentication"),children:n("testAuthentication")})})]})]})},ne="1.3.6.1.4.1.4203.1.11.1",te=({id:t,form:l,showSectionHeading:i=!1,showSectionDescription:a=!1})=>{const{adminClient:o}=U(),{t:n}=A(),{realm:r}=w(),{addAlert:b,addError:h}=F(),C=async()=>{if(await l.trigger())try{const s=z(l),m=await o.realms.ldapServerCapabilities({realm:r},{...s,componentId:t});b(n("testSuccess"));const y=m.filter(H=>H.oid===ne);l.setValue("config.usePasswordModifyExtendedOp",[(y.length>0).toString()])}catch(s){h("testError",s)}};return u(L,{children:[i&&e(k,{title:n("advancedSettings"),description:n("ldapAdvancedSettingsDescription"),showDescription:a}),u(I,{role:"manage-realm",isHorizontal:!0,children:[e(c,{label:n("enableLdapv3Password"),labelIcon:e(p,{helpText:n("enableLdapv3PasswordHelp"),fieldLabelId:"enableLdapv3Password"}),fieldId:"kc-enable-ldapv3-password",hasNoPaddingTop:!0,children:e(g,{name:"config.usePasswordModifyExtendedOp",defaultValue:["false"],control:l.control,render:({field:s})=>e(f,{id:"kc-enable-ldapv3-password","data-testid":"ldapv3-password",isDisabled:!1,onChange:(m,y)=>s.onChange([`${y}`]),isChecked:s.value[0]==="true",label:n("on"),labelOff:n("off"),"aria-label":n("enableLdapv3Password")})})}),e(c,{label:n("validatePasswordPolicy"),labelIcon:e(p,{helpText:n("validatePasswordPolicyHelp"),fieldLabelId:"validatePasswordPolicy"}),fieldId:"kc-validate-password-policy",hasNoPaddingTop:!0,children:e(g,{name:"config.validatePasswordPolicy",defaultValue:["false"],control:l.control,render:({field:s})=>e(f,{id:"kc-validate-password-policy","data-testid":"password-policy",isDisabled:!1,onChange:(m,y)=>s.onChange([`${y}`]),isChecked:s.value[0]==="true",label:n("on"),labelOff:n("off"),"aria-label":n("validatePasswordPolicy")})})}),e(c,{label:n("trustEmail"),labelIcon:e(p,{helpText:n("trustEmailHelp"),fieldLabelId:"trustEmail"}),fieldId:"kc-trust-email",hasNoPaddingTop:!0,children:e(g,{name:"config.trustEmail",defaultValue:["false"],control:l.control,render:({field:s})=>e(f,{id:"kc-trust-email","data-testid":"trust-email",isDisabled:!1,onChange:(m,y)=>s.onChange([`${y}`]),isChecked:s.value[0]==="true",label:n("on"),labelOff:n("off"),"aria-label":n("trustEmail")})})}),e(c,{fieldId:"query-extensions",children:e(V,{variant:"secondary",id:"query-extensions","data-testid":"query-extensions",onClick:C,children:n("queryExtensions")})})]})]})},le=({form:t,showSectionHeading:l=!1,showSectionDescription:i=!1,vendorEdit:a=!1})=>{const{t:o}=A(),{realm:n,realmRepresentation:r}=w();X(()=>t.setValue("parentId",r?.id),[]);const[b,h]=E(!1),C=()=>{switch(t.getValues("config.vendor[0]")){case"ad":t.setValue("config.usernameLDAPAttribute[0]","cn"),t.setValue("config.rdnLDAPAttribute[0]","cn"),t.setValue("config.uuidLDAPAttribute[0]","objectGUID"),t.setValue("config.krbPrincipalAttribute[0]","userPrincipalName"),t.setValue("config.userObjectClasses[0]","person, organizationalPerson, user");break;case"rhds":t.setValue("config.usernameLDAPAttribute[0]","uid"),t.setValue("config.rdnLDAPAttribute[0]","uid"),t.setValue("config.uuidLDAPAttribute[0]","nsuniqueid"),t.setValue("config.krbPrincipalAttribute[0]","krbPrincipalName"),t.setValue("config.userObjectClasses[0]","inetOrgPerson, organizationalPerson");break;case"tivoli":t.setValue("config.usernameLDAPAttribute[0]","uid"),t.setValue("config.rdnLDAPAttribute[0]","uid"),t.setValue("config.uuidLDAPAttribute[0]","uniqueidentifier"),t.setValue("config.krbPrincipalAttribute[0]","krb5PrincipalName"),t.setValue("config.userObjectClasses[0]","inetOrgPerson, organizationalPerson");break;case"edirectory":t.setValue("config.usernameLDAPAttribute[0]","uid"),t.setValue("config.rdnLDAPAttribute[0]","uid"),t.setValue("config.uuidLDAPAttribute[0]","guid"),t.setValue("config.krbPrincipalAttribute[0]","krb5PrincipalName"),t.setValue("config.userObjectClasses[0]","inetOrgPerson, organizationalPerson");break;case"other":t.setValue("config.usernameLDAPAttribute[0]","uid"),t.setValue("config.rdnLDAPAttribute[0]","uid"),t.setValue("config.uuidLDAPAttribute[0]","entryUUID"),t.setValue("config.krbPrincipalAttribute[0]","krb5PrincipalName"),t.setValue("config.userObjectClasses[0]","inetOrgPerson, organizationalPerson");break;default:return""}};return u(D,{...t,children:[l&&e(k,{title:o("generalOptions"),description:o("ldapGeneralOptionsSettingsDescription"),showDescription:i}),u(I,{role:"manage-realm",isHorizontal:!0,children:[e("input",{type:"hidden",defaultValue:"ldap",...t.register("providerId")}),e("input",{type:"hidden",defaultValue:"org.keycloak.storage.UserStorageProvider",...t.register("providerType")}),e("input",{type:"hidden",defaultValue:n,...t.register("parentId")}),e(d,{name:"name",label:o("uiDisplayName"),labelIcon:o("uiDisplayNameHelp"),defaultValue:"ldap",rules:{required:o("validateName")}}),e(c,{label:o("vendor"),labelIcon:e(p,{helpText:o("vendorHelp"),fieldLabelId:"vendor"}),fieldId:"kc-vendor",isRequired:!0,children:e(g,{name:"config.vendor[0]",defaultValue:"ad",control:t.control,render:({field:s})=>u(x,{isDisabled:!!a,toggleId:"kc-vendor",onToggle:()=>h(!b),isOpen:b,onSelect:m=>{s.onChange(m),h(!1),C()},selections:s.value,variant:q.single,"aria-label":o("selectVendor"),children:[e(S,{value:"ad",children:"Active Directory"},0),e(S,{value:"rhds",children:"Red Hat Directory Server"},1),e(S,{value:"tivoli",children:"Tivoli"},2),e(S,{value:"edirectory",children:"Novell eDirectory"},3),e(S,{value:"other",children:"Other"},4)]})})})]})]})},ie=({form:t,showSectionHeading:l=!1,showSectionDescription:i=!1})=>{const{t:a}=A(),o=N({control:t.control,name:"config.allowKerberosAuthentication",defaultValue:["false"]});return u(D,{...t,children:[l&&e(k,{title:a("kerberosIntegration"),description:a("ldapKerberosSettingsDescription"),showDescription:i}),u(I,{role:"manage-realm",isHorizontal:!0,children:[e(c,{label:a("allowKerberosAuthentication"),labelIcon:e(p,{helpText:a("allowKerberosAuthenticationHelp"),fieldLabelId:"allowKerberosAuthentication"}),fieldId:"kc-allow-kerberos-authentication",hasNoPaddingTop:!0,children:e(g,{name:"config.allowKerberosAuthentication",defaultValue:["false"],control:t.control,render:({field:n})=>e(f,{id:"kc-allow-kerberos-authentication","data-testid":"allow-kerberos-auth",isDisabled:!1,onChange:(r,b)=>n.onChange([`${b}`]),isChecked:n.value[0]==="true",label:a("on"),labelOff:a("off"),"aria-label":a("allowKerberosAuthentication")})})}),o[0]==="true"&&u(L,{children:[e(d,{name:"config.kerberosRealm.0",label:a("kerberosRealm"),labelIcon:a("kerberosRealmHelp"),rules:{required:a("validateRealm")}}),e(d,{name:"config.serverPrincipal.0",label:a("serverPrincipal"),labelIcon:a("serverPrincipalHelp"),rules:{required:a("validateServerPrincipal")}}),e(d,{name:"config.keyTab.0",label:a("keyTab"),labelIcon:a("keyTabHelp"),rules:{required:a("validateKeyTab")}}),e(d,{name:"config.krbPrincipalAttribute.0",label:a("krbPrincipalAttribute"),labelIcon:a("krbPrincipalAttributeHelp")}),e(c,{label:a("debug"),labelIcon:e(p,{helpText:a("debugHelp"),fieldLabelId:"debug"}),fieldId:"kc-debug",hasNoPaddingTop:!0,children:e(g,{name:"config.debug",defaultValue:["false"],control:t.control,render:({field:n})=>e(f,{id:"kc-debug","data-testid":"debug",isDisabled:!1,onChange:(r,b)=>n.onChange([`${b}`]),isChecked:n.value[0]==="true",label:a("on"),labelOff:a("off"),"aria-label":a("debug")})})})]}),e(c,{label:a("useKerberosForPasswordAuthentication"),labelIcon:e(p,{helpText:a("useKerberosForPasswordAuthenticationHelp"),fieldLabelId:"useKerberosForPasswordAuthentication"}),fieldId:"kc-use-kerberos-password-authentication",hasNoPaddingTop:!0,children:e(g,{name:"config.useKerberosForPasswordAuthentication",defaultValue:["false"],control:t.control,render:({field:n})=>e(f,{id:"kc-use-kerberos-password-authentication","data-testid":"use-kerberos-pw-auth",isDisabled:!1,onChange:(r,b)=>n.onChange([`${b}`]),isChecked:n.value[0]==="true",label:a("on"),labelOff:a("off"),"aria-label":a("useKerberosForPasswordAuthentication")})})})]})]})},re=({form:t,showSectionHeading:l=!1,showSectionDescription:i=!1})=>{const{t:a}=A();return u(D,{...t,children:[l&&e(k,{title:a("ldapSearchingAndUpdatingSettings"),description:a("ldapSearchingAndUpdatingSettingsDescription"),showDescription:i}),u(I,{role:"manage-realm",isHorizontal:!0,children:[e(T,{id:"editMode",name:"config.editMode[0]",label:a("editMode"),labelIcon:a("editModeLdapHelp"),controller:{defaultValue:"",rules:{required:{value:!0,message:a("validateEditMode")}}},options:["","READ_ONLY","WRITABLE","UNSYNCED"]}),e(d,{name:"config.usersDn.0",label:a("usersDN"),labelIcon:a("usersDNHelp"),rules:{required:a("validateUsersDn")}}),e(d,{name:"config.usernameLDAPAttribute.0",label:a("usernameLdapAttribute"),labelIcon:a("usernameLdapAttributeHelp"),defaultValue:"cn",rules:{required:a("validateUsernameLDAPAttribute")}}),e(d,{name:"config.rdnLDAPAttribute.0",label:a("rdnLdapAttribute"),labelIcon:a("rdnLdapAttributeHelp"),defaultValue:"cn",rules:{required:a("validateRdnLdapAttribute")}}),e(d,{name:"config.uuidLDAPAttribute.0",label:a("uuidLdapAttribute"),labelIcon:a("uuidLdapAttributeHelp"),defaultValue:"objectGUID",rules:{required:a("validateUuidLDAPAttribute")}}),e(d,{name:"config.userObjectClasses.0",label:a("userObjectClasses"),labelIcon:a("userObjectClassesHelp"),defaultValue:"person, organizationalPerson, user",rules:{required:a("validateUserObjectClasses")}}),e(d,{name:"config.customUserSearchFilter.0",label:a("userLdapFilter"),labelIcon:a("userLdapFilterHelp"),rules:{pattern:{value:/(\(.*\))$/,message:a("validateCustomUserSearchFilter")}}}),e(T,{id:"kc-search-scope",name:"config.searchScope[0]",label:a("searchScope"),labelIcon:a("searchScopeHelp"),controller:{defaultValue:"1"},options:[{key:"1",value:a("oneLevel")},{key:"2",value:a("subtree")}]}),e(d,{name:"config.readTimeout.0",label:a("readTimeout"),labelIcon:a("readTimeoutHelp"),type:"number",min:0}),e(c,{label:a("pagination"),labelIcon:e(p,{helpText:a("paginationHelp"),fieldLabelId:"pagination"}),fieldId:"kc-ui-pagination",hasNoPaddingTop:!0,children:e(g,{name:"config.pagination",defaultValue:["false"],control:t.control,render:({field:o})=>e(f,{id:"kc-ui-pagination","data-testid":"ui-pagination",isDisabled:!1,onChange:(n,r)=>o.onChange([`${r}`]),isChecked:o.value[0]==="true",label:a("on"),labelOff:a("off"),"aria-label":a("pagination")})})}),e(T,{name:"config.referral.0",label:a("referral"),labelIcon:a("referralHelp"),controller:{defaultValue:""},options:["ignore","follow"]})]})]})},oe=({form:t,showSectionHeading:l=!1,showSectionDescription:i=!1})=>{const{t:a}=A(),o=t.watch("config.periodicFullSync",!1),n=t.watch("config.periodicChangedUsersSync",!1);return u(D,{...t,children:[l&&e(k,{title:a("synchronizationSettings"),description:a("ldapSynchronizationSettingsDescription"),showDescription:i}),u(I,{role:"manage-realm",isHorizontal:!0,children:[e(c,{hasNoPaddingTop:!0,label:a("importUsers"),labelIcon:e(p,{helpText:a("importUsersHelp"),fieldLabelId:"importUsers"}),fieldId:"kc-import-users",children:e(g,{name:"config.importEnabled",defaultValue:["true"],control:t.control,render:({field:r})=>e(f,{id:"kc-import-users","data-testid":"import-users",name:"importEnabled",label:a("on"),labelOff:a("off"),onChange:(b,h)=>r.onChange([`${h}`]),isChecked:r.value[0]==="true",isDisabled:!1,"aria-label":a("importUsers")})})}),e(c,{hasNoPaddingTop:!0,label:a("syncRegistrations"),labelIcon:e(p,{helpText:a("syncRegistrations"),fieldLabelId:"syncRegistrations"}),fieldId:"syncRegistrations",children:e(g,{name:"config.syncRegistrations",defaultValue:["true"],control:t.control,render:({field:r})=>e(f,{id:"syncRegistrations","data-testid":"syncRegistrations",label:a("on"),labelOff:a("off"),onChange:(b,h)=>r.onChange([`${h}`]),isChecked:r.value[0]==="true","aria-label":a("syncRegistrations")})})}),e(d,{name:"config.batchSizeForSync.0",type:"number",min:0,label:a("batchSize"),labelIcon:a("batchSizeHelp")}),e(c,{label:a("periodicFullSync"),labelIcon:e(p,{helpText:a("periodicFullSyncHelp"),fieldLabelId:"periodicFullSync"}),fieldId:"kc-periodic-full-sync",hasNoPaddingTop:!0,children:e(g,{name:"config.periodicFullSync",defaultValue:!1,control:t.control,render:({field:r})=>e(f,{id:"kc-periodic-full-sync","data-testid":"periodic-full-sync",isDisabled:!1,onChange:(b,h)=>r.onChange(h),isChecked:r.value===!0,label:a("on"),labelOff:a("off"),"aria-label":a("periodicFullSync")})})}),o&&e(d,{name:"config.fullSyncPeriod.0",label:a("fullSyncPeriod"),labelIcon:a("fullSyncPeriodHelp"),type:"number",min:-1,defaultValue:604800}),e(c,{label:a("periodicChangedUsersSync"),labelIcon:e(p,{helpText:a("periodicChangedUsersSyncHelp"),fieldLabelId:"periodicChangedUsersSync"}),fieldId:"kc-periodic-changed-users-sync",hasNoPaddingTop:!0,children:e(g,{name:"config.periodicChangedUsersSync",defaultValue:!1,control:t.control,render:({field:r})=>e(f,{id:"kc-periodic-changed-users-sync","data-testid":"periodic-changed-users-sync",isDisabled:!1,onChange:(b,h)=>r.onChange(h),isChecked:r.value===!0,label:a("on"),labelOff:a("off"),"aria-label":a("periodicChangedUsersSync")})})}),n&&e(d,{name:"config.changedSyncPeriod.0",label:a("changedUsersSyncPeriod"),labelIcon:a("changedUsersSyncHelp"),type:"number",min:-1,defaultValue:86400})]})]})},ge=({id:t,onSubmit:l})=>{const{t:i}=A(),a=j(),o=$(),{realm:n}=w(),r=B();return u(L,{children:[e(M,{label:i("jumpToSection"),sections:[{title:i("generalOptions"),panel:e(le,{form:a,vendorEdit:!!t})},{title:i("connectionAndAuthenticationSettings"),panel:e(ae,{form:a,id:t})},{title:i("ldapSearchingAndUpdatingSettings"),panel:e(re,{form:a})},{title:i("synchronizationSettings"),panel:e(oe,{form:a})},{title:i("kerberosIntegration"),panel:e(ie,{form:a}),isHidden:!r(G.Kerberos)},{title:i("cacheSettings"),panel:e(J,{form:a})},{title:i("advancedSettings"),panel:e(te,{form:a,id:t})}]}),e(W,{onSubmit:a.handleSubmit(l),children:e(Q,{name:"ldap",isActive:a.formState.isDirty,isSubmit:!0,children:e(V,{variant:"link",onClick:()=>o(Y({realm:n})),"data-testid":"ldap-cancel",children:i("cancel")})})})]})};function he(t){const{config:l}=t;return l?.periodicChangedUsersSync!==void 0&&(l.periodicChangedUsersSync===!1&&(l.changedSyncPeriod=["-1"]),delete l.periodicChangedUsersSync),l?.periodicFullSync!==void 0&&(l.periodicFullSync===!1&&(l.fullSyncPeriod=["-1"]),delete l.periodicFullSync),t}export{ge as U,he as s};
//# sourceMappingURL=UserFederationLdapForm-Dau3yBfR.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy