All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.AuthenticationSection-CEzcDulC.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as e,jsxs as b,Fragment as _}from"react/jsx-runtime";import{n as $e,u as T,a as S,g as D,f as N,c as k,M as Q,h as v,B as F,r as oe,F as M,y as K,j as R,d as Ue,q as se,k as Ie,v as re,A as B,Q as ce,S as de,a3 as ue,a4 as te,a5 as z,a6 as Te,a7 as Ee,a8 as _e,a9 as Re,C as Ke,aa as ke,Z as ae,$ as Be,P as $,x as Y,s as Fe,ab as je,ac as H,ad as q,ae as ne,R as pe,af as he,ag as ze,ah as Ge,ai as Ne,aj as We,ak as Ye,al as be,am as Xe,an as ye,ao as Qe,ap as Ze,aq as Je,b as Oe,a0 as et,a1 as tt,a2 as xe,ar as at,as as nt,V as it,K as lt,W as ot,U as st,at as rt,au as ct,i as fe,L as De,av as dt,o as ut,w as mt}from"./index-C1LIsRX7.js";import{useEffect as j,useState as E,useMemo as Me}from"react";import{u as pt}from"./ConfirmDialog-B5qjiAuo.js";import{L as ht}from"./PaginatingTableToolbar-CpMLQtqt.js";import{R as bt,u as yt}from"./RoutableTabs-j5CUH0-6.js";import{K as Ve}from"./KeycloakDataTable-jyvvxdb8.js";import{V as ft}from"./ViewHeader-qjLr6U82.js";import{u as ie}from"./useToggle-K3Kx99tM.js";import{N as gt}from"./NameDescription-CQ_fNXVs.js";import{D as At}from"./DraggableTable-BwAWTeWo.js";import{D as wt}from"./DynamicComponents-CIZcko9u.js";import{T as vt}from"./trash-icon-DDaN0w_B.js";import{f as Pt}from"./AddRoleMappingModal-Ds4yp8lg.js";import{F as Z}from"./FormAccess-BcY70QlP.js";import{T as Le}from"./TimeSelectorControl-BQB3aFfv.js";import{E as Ct,a as St,b as It}from"./EmptyStateFooter-Cm2IMTi1.js";import{E as Tt,a as Et,b as _t}from"./EmptyStateActions-DBSnfkAA.js";import{M as ge}from"./MultiLineInput-AcwuO_FT.js";import{Q as Rt}from"./question-circle-icon-Dbt6ViOg.js";import{T as kt,a as O,b as x}from"./Tabs-CNBvRApH.js";import{T as Ft}from"./Trans-DZTM8FLp.js";import{s as Nt}from"./sortBy-L-dz5MSQ.js";const Ot={name:"CogIcon",height:512,width:512,svgPath:"M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z",yOffset:0,xOffset:0},xt=$e(Ot),Dt=({flowAlias:n,onClose:a})=>{const{adminClient:o}=T(),{t}=S(),i=D(),{addAlert:s,addError:c}=N(),{realm:d}=k(),m=async({bindingType:u})=>{const g=await o.realms.findOne({realm:d});try{await o.realms.update({realm:d},{...g,[u]:n}),s(t("updateFlowSuccess"),R.success)}catch(P){c("updateFlowError",P)}a(!0)},f=Array.from(X.keys());return e(Q,{title:t("bindFlow"),variant:"small",onClose:()=>a(),actions:[e(v,{"data-testid":"save",type:"submit",form:"bind-form",children:t("save")},"confirm"),e(v,{"data-testid":"cancel",variant:F.link,onClick:()=>a(),children:t("cancel")},"cancel")],isOpen:!0,children:e(oe,{id:"bind-form",isHorizontal:!0,onSubmit:i.handleSubmit(m),children:e(M,{...i,children:e(K,{id:"chooseBindingType",name:"bindingType",label:t("chooseBindingType"),options:f.filter(u=>u!=="dockerAuthenticationFlow").map(u=>({key:u,value:t(`flow.${X.get(u)}`)})),controller:{defaultValue:f[0]},menuAppendTo:"parent","aria-label":t("chooseBindingType")})})})})},Mt=({name:n,description:a,toggleDialog:o,onComplete:t})=>{const{adminClient:i}=T(),{t:s}=S(),c=D({mode:"onChange"}),{setValue:d,getValues:m,handleSubmit:f}=c,{addAlert:u,addError:g}=N(),P=Ue(),{realm:p}=k();j(()=>{d("alias",s("copyOf",{name:n})),d("description",a)},[n,a]);const y=async()=>{const w=m();try{await i.authenticationManagement.copyFlow({flow:n,newName:w.alias});const l=(await i.authenticationManagement.getFlows()).find(A=>A.alias===w.alias);w.description!==a&&(l.description=w.description,await i.authenticationManagement.updateFlow({flowId:l.id},l)),u(s("copyFlowSuccess"),R.success),P(Ie({realm:p,id:l.id,usedBy:"notInUse",builtIn:l.builtIn?"builtIn":void 0}))}catch(l){g("copyFlowError",l)}t()};return e(Q,{title:s("duplicateFlow"),onClose:o,variant:se.small,actions:[e(v,{"data-testid":"confirm",type:"submit",form:"duplicate-flow-form",children:s("duplicate")},"confirm"),e(v,{"data-testid":"cancel",variant:F.link,onClick:o,children:s("cancel")},"cancel")],isOpen:!0,children:e(M,{...c,children:e(oe,{id:"duplicate-flow-form",onSubmit:f(y),isHorizontal:!0,children:e(gt,{})})})})},Vt=({requiredAction:n,onClose:a})=>{const{adminClient:o}=T(),{t}=S(),{addAlert:i,addError:s}=N(),[c,d]=E(),m=D(),{setValue:f,handleSubmit:u}=m,g=p=>{ce(p||{},f)};re(async()=>{const p=await o.authenticationManagement.getRequiredActionConfigDescription({alias:n.alias}),y=await o.authenticationManagement.getRequiredActionConfig({alias:n.alias});return p.properties=[...p.properties],{configDescription:p,config:y}},({configDescription:p,config:y})=>{d(p),g(y)},[]);const P=async p=>{const y=de(p);try{await o.authenticationManagement.updateRequiredActionConfig({alias:n.alias},y),g(y),i(t("configSaveSuccess"),R.success),a()}catch(w){s("configSaveError",w)}};return e(Q,{variant:se.small,isOpen:!0,title:t("requiredActionConfig",{name:n.name}),onClose:a,children:b(oe,{id:"required-action-config-form",onSubmit:u(P),children:[e(M,{...m,children:e(wt,{stringify:!0,properties:c?.properties||[]})}),b(B,{children:[e(v,{"data-testid":"save",variant:"primary",type:"submit",children:t("save")}),e(v,{"data-testid":"cancel",variant:F.link,onClick:a,children:t("cancel")}),b(v,{className:"pf-v5-u-ml-3xl","data-testid":"clear",variant:F.link,onClick:async()=>{await o.authenticationManagement.removeRequiredActionConfig({alias:n.alias}),m.reset({}),a()},children:[t("clear")," ",e(vt,{})]})]})]})})},Lt=()=>{const{adminClient:n}=T(),{t:a}=S(),{addAlert:o,addError:t}=N(),[i,s]=E(),[c,d]=E(),[m,f]=E(0),u=()=>f(m+1),{realm:g}=k(),P=async()=>await(await Te(`${_e(n.baseUrl)}admin/realms/${g}/ui-ext/authentication-management/required-actions`,{method:"GET",headers:Ee(await n.getAccessToken())})).json();re(async()=>{const[l,A]=await Promise.all([P(),n.authenticationManagement.getUnregisteredRequiredActions()]);return[...l.map(r=>({name:r.name,enabled:r.enabled,defaultAction:r.defaultAction,data:r})),...A.map(r=>({name:r.name,enabled:!1,defaultAction:!1,data:r}))]},l=>s(l),[m]);const p=l=>!("alias"in l),y=async(l,A)=>{try{A in l?(l[A]=!l[A],delete l.configurable,await n.authenticationManagement.updateRequiredAction({alias:l.alias},l)):p(l)&&await n.authenticationManagement.registerRequiredAction({name:l.name,providerId:l.providerId}),u(),o(a("updatedRequiredActionSuccess"),R.success)}catch(r){t("updatedRequiredActionError",r)}},w=async(l,A)=>{try{const r=l.alias;for(let h=0;h0?await n.authenticationManagement.lowerRequiredActionPriority({alias:r}):await n.authenticationManagement.raiseRequiredActionPriority({alias:r});u(),o(a("updatedRequiredActionSuccess"),R.success)}catch(r){t("updatedRequiredActionError",r)}};return i?b(_,{children:[c&&e(Vt,{requiredAction:c,onClose:()=>d(void 0)}),e(At,{keyField:"name",onDragFinish:async(l,A)=>{const r=i.map(C=>C.name),h=A.indexOf(l),I=r.indexOf(l),V=i[I].data;if(!V.alias)return;const J=h-I;w(V,J)},columns:[{name:"name",displayKey:"action",width:50},{name:"enabled",displayKey:"enabled",cellRenderer:l=>e(te,{id:`enable-${z(l.name)}`,label:a("on"),labelOff:a("off"),isChecked:l.enabled,onChange:()=>{y(l.data,"enabled")},"aria-label":z(l.name)}),width:20},{name:"default",displayKey:"setAsDefaultAction",thTooltipText:"authDefaultActionTooltip",cellRenderer:l=>e(te,{id:`default-${z(l.name)}`,label:a("on"),isDisabled:!l.enabled,labelOff:l.enabled?a("off"):a("disabledOff"),isChecked:l.defaultAction,onChange:()=>{y(l.data,"defaultAction")},"aria-label":z(l.name)}),width:20},{name:"config",displayKey:"configure",cellRenderer:l=>l.data.configurable?e(v,{variant:"plain","aria-label":a("settings"),onClick:()=>d(l.data),children:e(xt,{})}):void 0,width:10}],data:i})]}):e(ue,{})},Ht="_label_1u2bs_1",le={label:Ht},ee=({label:n})=>b(_,{children:[e(Ke,{className:le.label})," ",n]}),qt=({id:n,isSpecificClient:a,onClose:o})=>{const{adminClient:t}=T(),{t:i}=S(),s=async(c,d,m)=>(await Pt(t,{id:n,type:a?"clients":"idp",first:c||0,max:d||10,search:m})).map(u=>({name:u}));return e(Q,{header:b(ke,{children:[e(ae,{component:Be.h1,children:i("flowUsedBy")}),e(ae,{children:i("flowUsedByDescription",{value:i(a?"clients":"identiyProviders")})})]}),variant:se.medium,isOpen:!0,onClose:o,actions:[e(v,{"data-testid":"cancel",id:"modal-cancel",onClick:o,children:i("close")},"cancel")],children:e(Ve,{loader:s,isPaginated:!0,ariaLabelKey:"usedBy",searchPlaceholderKey:"search",columns:[{name:"name"}]})})},$t=({authType:{id:n,usedBy:a},realm:o})=>{const{t}=S(),[i,s]=ie(),c=Object.entries(o).find(d=>d[1]===a?.values[0])?.[0];return b(_,{children:[i&&e(qt,{id:n,onClose:s,isSpecificClient:a?.type==="SPECIFIC_CLIENTS"}),(a?.type==="SPECIFIC_PROVIDERS"||a?.type==="SPECIFIC_CLIENTS")&&(a.values.length<=8?e(Re,{"aria-label":t("usedBy"),bodyContent:b("div",{children:[t("appliedBy"+(a.type==="SPECIFIC_CLIENTS"?"Clients":"Providers"))," ",a.values.map((d,m)=>b(_,{children:[e("strong",{children:d}),m{const{adminClient:o}=T(),{t}=S(),i=D({mode:"onChange"}),{realm:s}=k(),{addAlert:c,addError:d}=N(),m=u=>ce(u,i.setValue);j(()=>m(n),[]);const f=async u=>{try{await o.realms.update({realm:s},de(u));const g=await o.realms.findOne({realm:s});a(g),m(g),c(t("updateCibaSuccess"),R.success)}catch(g){d("updateCibaError",g)}};return e($,{variant:"light",children:b(Z,{role:"manage-realm",isHorizontal:!0,onSubmit:i.handleSubmit(f),children:[b(M,{...i,children:[e(K,{name:"attributes.cibaBackchannelTokenDeliveryMode",label:t("cibaBackchannelTokenDeliveryMode"),labelIcon:t("cibaBackchannelTokenDeliveryModeHelp"),options:Ut.map(u=>({key:u,value:t(`cibaBackhannelTokenDeliveryModes.${u}`)})),controller:{defaultValue:""}}),e(Y,{name:"attributes.cibaExpiresIn",type:"number",min:G,max:W,label:t("cibaExpiresIn"),labelIcon:t("cibaExpiresInHelp"),rules:{min:{value:G,message:t("greaterThan",{value:G})},max:{value:W,message:t("lessThan",{value:W})},required:{value:!0,message:t("required")}}}),e(Y,{name:"attributes.cibaInterval",type:"number",min:G,max:W,label:t("cibaInterval"),labelIcon:t("cibaIntervalHelp"),rules:{min:{value:Ae,message:t("greaterThan",{value:Ae})},max:{value:we,message:t("lessThan",{value:we})},required:{value:!0,message:t("required")}}}),e(K,{name:"attributes.cibaAuthRequestedUserHint",label:t("cibaAuthRequestedUserHint"),labelIcon:t("cibaAuthRequestedUserHintHelp"),options:["login_hint","id_token_hint","login_hint_token"],controller:{defaultValue:""},isDisabled:!0})]}),b(B,{children:[e(v,{"data-testid":"save",variant:"primary",type:"submit",isDisabled:!i.formState.isValid||!i.formState.isDirty,children:t("save")}),e(v,{"data-testid":"reload",variant:F.link,onClick:()=>m({...n}),children:t("reload")})]})]})})},L=["totp","hotp"],ve=["SHA1","SHA256","SHA512"],Pe=[6,8],Bt=({realm:n,realmUpdated:a})=>{const{adminClient:o}=T(),{t}=S(),i=D({mode:"onChange",defaultValues:n}),{control:s,reset:c,handleSubmit:d,formState:{isValid:m,isDirty:f}}=i,{realm:u}=k(),{addAlert:g,addError:P}=N(),p=Fe(),y=je({name:"otpPolicyType",control:s,defaultValue:L[0]}),w=r=>c(r);j(()=>w(n),[]);const l=Me(()=>{const r=(n.otpSupportedApplications??[]).map(h=>t(`otpSupportedApplications.${h}`));return p(r,h=>h)},[n.otpSupportedApplications]);return e($,{variant:"light",children:e(Z,{role:"manage-realm",isHorizontal:!0,onSubmit:d(async r=>{try{await o.realms.update({realm:u},r);const h=await o.realms.findOne({realm:u});a(h),w(h),g(t("updateOtpSuccess"),R.success)}catch(h){P("updateOtpError",h)}}),className:"keycloak__otp_policies_authentication__form",children:b(M,{...i,children:[e(H,{label:t("otpType"),labelIcon:e(q,{helpText:t("otpTypeHelp"),fieldLabelId:"otpType"}),hasNoPaddingTop:!0,children:e(ne,{name:"otpPolicyType","data-testid":"otpPolicyType",defaultValue:L[0],control:s,render:({field:r})=>e(_,{children:L.map(h=>e(pe,{id:h,"data-testid":h,isChecked:r.value===h,name:"otpPolicyType",onChange:()=>r.onChange(h),label:t(`policyType.${h}`),className:"keycloak__otp_policies_authentication__policy-type"},h))})})}),e(K,{name:"otpPolicyAlgorithm",label:t("otpHashAlgorithm"),labelIcon:t("otpHashAlgorithmHelp"),options:ve.map(r=>({key:`Hmac${r}`,value:r})),controller:{defaultValue:`Hmac${ve[0]}`}}),e(H,{label:t("otpPolicyDigits"),labelIcon:e(q,{helpText:t("otpPolicyDigitsHelp"),fieldLabelId:"otpPolicyDigits"}),hasNoPaddingTop:!0,children:e(ne,{name:"otpPolicyDigits","data-testid":"otpPolicyDigits",defaultValue:Pe[0],control:s,render:({field:r})=>e(_,{children:Pe.map(h=>e(pe,{id:`digit-${h}`,"data-testid":`digit-${h}`,isChecked:r.value===h,name:"otpPolicyDigits",onChange:()=>r.onChange(h),label:h,className:"keycloak__otp_policies_authentication__number-of-digits"},h))})})}),e(he,{name:"otpPolicyLookAheadWindow",label:t("lookAround"),labelIcon:t("lookAroundHelp"),controller:{defaultValue:1,rules:{min:0}}}),y===L[0]&&e(Le,{name:"otpPolicyPeriod",label:t("otpPolicyPeriod"),labelIcon:t("otpPolicyPeriodHelp"),units:["second","minute"],controller:{defaultValue:30,rules:{min:1,max:{value:120,message:t("maxLength",{length:"2 "+t("minutes")})}}}}),y===L[1]&&e(he,{name:"otpPolicyInitialCounter",label:t("initialCounter"),labelIcon:t("initialCounterHelp"),controller:{defaultValue:30,rules:{min:1,max:120}}}),e(H,{label:t("supportedApplications"),labelIcon:e(q,{helpText:t("supportedApplicationsHelp"),fieldLabelId:"supportedApplications"}),children:e("span",{"data-testid":"supportedApplications",children:e(ze,{children:l.map(r=>e(Ge,{isReadOnly:!0,children:r},r))})})}),y===L[0]&&e(Ne,{name:"otpPolicyCodeReusable",label:t("otpPolicyCodeReusable"),labelIcon:t("otpPolicyCodeReusableHelp"),labelOn:t("on"),labelOff:t("off")}),b(B,{children:[e(v,{"data-testid":"save",variant:"primary",type:"submit",isDisabled:!m||!f,children:t("save")}),e(v,{"data-testid":"reload",variant:F.link,onClick:()=>c({...n}),children:t("reload")})]})]})})})},jt=({policy:{id:n,configType:a,defaultValue:o,displayName:t},onRemove:i})=>{const{t:s}=S(),{control:c,register:d,formState:{errors:m}}=We(),f=m[n];return b(H,{label:t,fieldId:n,isRequired:!0,labelIcon:e(q,{helpText:s(`passwordPoliciesHelp.${n}`),fieldLabelId:n}),children:[b(Ye,{children:[b(be,{isFilled:!0,children:[a&&a!=="int"&&e(Xe,{id:n,"data-testid":n,...d(n,{required:!0}),defaultValue:o,validated:f?ye.error:ye.default}),a==="int"&&e(ne,{name:n,defaultValue:Number.parseInt(o||"0"),control:c,render:({field:u})=>{const P=y=>u.onChange(Math.max(y,0)),p=Number(u.value);return e(Qe,{id:n,value:p,min:0,onPlus:()=>P(p+1),onMinus:()=>P(p-1),onChange:y=>{const w=Number(y.currentTarget.value);P(isNaN(w)?0:w)},className:"keycloak__policies_authentication__number-field"})}}),!a&&e(te,{id:n,label:s("on"),labelOff:s("off"),isChecked:!0,isDisabled:!0,"aria-label":t})]}),e(be,{children:e(v,{"data-testid":`remove-${n}`,variant:"link",className:"keycloak__policies_authentication__minus-icon",onClick:()=>i(n),"aria-label":s("remove"),children:e(Ze,{})})})]}),f&&e(Je,{message:s("required")})]})},He=" and ",zt=(n,a)=>n.map(o=>`${o.id}(${a[o.id]})`).join(He),Gt=(n,a)=>n.split(He).map(Wt).reduce((o,{id:t,value:i})=>{const s=a.find(c=>c.id===t);return s?o.concat({...s,value:i}):o},[]);function Wt(n){const a=n.indexOf("(");if(a===-1)return{id:n.trim()};const o=n.substring(0,a).trim(),t=n.lastIndexOf(")");if(t===-1)return{id:o};const i=n.substring(a+1,t).trim();return{id:o,value:i}}const Ce=({onSelect:n,selectedPolicies:a})=>{const{t:o}=S(),{passwordPolicies:t}=Oe(),[i,s]=E(!1),c=Me(()=>t?.filter(d=>a.find(m=>m.id===d.id)===void 0),[a]);return e(it,{onSelect:(d,m)=>{n(m),s(!1)},toggle:d=>e(lt,{ref:d,onClick:()=>s(!i),isExpanded:i,isDisabled:c?.length===0,style:{width:"300px"},"data-testid":"add-policy",children:o("addPolicy")}),isOpen:i,children:e(ot,{children:c?.map(d=>e(st,{value:d,children:d.displayName},d.id))})})},Yt=({realm:n,realmUpdated:a})=>{const{adminClient:o}=T(),{t}=S(),{passwordPolicies:i}=Oe(),{addAlert:s,addError:c}=N(),{realm:d}=k(),[m,f]=E([]),u=r=>{f([...m,r]),p(r.id,r.defaultValue,{shouldDirty:!0})},g=D({defaultValues:{}}),{handleSubmit:P,setValue:p,reset:y,formState:{isDirty:w}}=g,l=r=>{y();const h=Gt(r.passwordPolicy||"",i);h.forEach(I=>{p(I.id,I.value)}),f(h)};j(()=>l(n),[]);const A=async r=>{const h={...n,passwordPolicy:zt(m,r)};try{await o.realms.update({realm:d},h),a(h),l(h),s(t("updatePasswordPolicySuccess"),R.success)}catch(I){c("updatePasswordPolicyError",I)}};return b($,{variant:"light",className:"pf-v5-u-p-0",children:[(m.length!==0||n.passwordPolicy)&&b(_,{children:[e(et,{children:e(tt,{children:e(xe,{children:e(Ce,{onSelect:u,selectedPolicies:m})})})}),e(at,{}),e($,{variant:"light",children:e(M,{...g,children:b(Z,{className:"keycloak__policies_authentication__form",role:"manage-realm",isHorizontal:!0,onSubmit:P(A),children:[m.map((r,h)=>e(jt,{policy:r,onRemove:I=>{f(m.filter(V=>V.id!==I)),p(r.id,"",{shouldDirty:!0})}},`${r.id}-${h}`)),b(B,{children:[e(v,{"data-testid":"save",variant:"primary",type:"submit",isDisabled:!w,children:t("save")}),e(v,{"data-testid":"reload",variant:F.link,onClick:()=>l(n),children:t("reload")})]})]})})})]}),!m.length&&!n.passwordPolicy&&b(Ct,{"data-testid":"empty-state",variant:"lg",children:[e(Tt,{titleText:e(_,{children:t("noPasswordPolicies")}),icon:e(Et,{icon:nt}),headingLevel:"h1"}),e(St,{children:t("noPasswordPoliciesInstructions")}),e(It,{children:e(_t,{children:e(Ce,{onSelect:u,selectedPolicies:[]})})})]})]})},Xt=["ES256","ES384","ES512","RS256","RS384","RS512","Ed25519","RS1"],Qt=["not specified","none","indirect","direct"],Zt=["not specified","platform","cross-platform"],Jt=["not specified","Yes","No"],ea=["not specified","required","preferred","discouraged"],U=({name:n,label:a,options:o,labelPrefix:t,isMultiSelect:i=!1})=>{const{t:s}=S();return e(K,{name:n,label:s(a),variant:i?"typeaheadMulti":"single",controller:{defaultValue:o[0]},options:o.map(c=>({key:c,value:t?s(`${t}.${c}`):c}))})},Se=({realm:n,realmUpdated:a,isPasswordLess:o=!1})=>{const{adminClient:t}=T(),{t:i}=S(),{addAlert:s,addError:c}=N(),{realm:d}=k(),{enabled:m}=rt(),f=D({mode:"onChange"}),{setValue:u,handleSubmit:g,formState:{isDirty:P}}=f,p=o?"webAuthnPolicyPasswordless":"webAuthnPolicy",y=l=>ce(l,u);j(()=>y(n),[]);const w=async l=>{const A=de(l);try{await t.realms.update({realm:d},A),a(A),y(A),s(i("webAuthnUpdateSuccess"),R.success)}catch(r){c("webAuthnUpdateError",r)}};return b($,{variant:"light",children:[m&&e(Re,{bodyContent:i(`${p}FormHelp`),children:e(ke,{className:"keycloak__section_intro__help",children:b(ae,{children:[e(Rt,{})," ",i("webauthnIntro")]})})}),b(Z,{role:"manage-realm",isHorizontal:!0,onSubmit:g(w),className:"keycloak__webauthn_policies_authentication__form",children:[b(M,{...f,children:[e(Y,{name:`${p}RpEntityName`,label:i("webAuthnPolicyRpEntityName"),labelIcon:i("webAuthnPolicyRpEntityNameHelp"),rules:{required:{value:!0,message:i("required")}}}),e(U,{name:`${p}SignatureAlgorithms`,label:"webAuthnPolicySignatureAlgorithms",options:Xt,isMultiSelect:!0}),e(Y,{name:`${p}RpId`,label:i("webAuthnPolicyRpId"),labelIcon:i("webAuthnPolicyRpIdHelp")}),e(U,{name:`${p}AttestationConveyancePreference`,label:"webAuthnPolicyAttestationConveyancePreference",options:Qt,labelPrefix:"attestationPreference"}),e(U,{name:`${p}AuthenticatorAttachment`,label:"webAuthnPolicyAuthenticatorAttachment",options:Zt,labelPrefix:"authenticatorAttachment"}),e(U,{name:`${p}RequireResidentKey`,label:"webAuthnPolicyRequireResidentKey",options:Jt,labelPrefix:"residentKey"}),e(U,{name:`${p}UserVerificationRequirement`,label:"webAuthnPolicyUserVerificationRequirement",options:ea,labelPrefix:"userVerify"}),e(Le,{name:`${p}CreateTimeout`,label:i("webAuthnPolicyCreateTimeout"),labelIcon:i("otpPolicyPeriodHelp"),units:["second","minute","hour"],controller:{defaultValue:0,rules:{min:0,max:{value:31536,message:i("webAuthnPolicyCreateTimeoutHint")}}}}),e(Ne,{name:`${p}AvoidSameAuthenticatorRegister`,label:i("webAuthnPolicyAvoidSameAuthenticatorRegister"),labelIcon:i("webAuthnPolicyAvoidSameAuthenticatorRegisterHelp"),labelOn:i("on"),labelOff:i("off")}),e(H,{label:i("webAuthnPolicyAcceptableAaguids"),fieldId:"webAuthnPolicyAcceptableAaguids",labelIcon:e(q,{helpText:i("webAuthnPolicyAcceptableAaguidsHelp"),fieldLabelId:"webAuthnPolicyAcceptableAaguids"}),children:e(ge,{name:`${p}AcceptableAaguids`,"aria-label":i("webAuthnPolicyAcceptableAaguids"),addButtonLabel:"addAaguids"})}),e(H,{label:i("webAuthnPolicyExtraOrigins"),fieldId:"webAuthnPolicyExtraOrigins",labelIcon:e(q,{helpText:i("webAuthnPolicyExtraOriginsHelp"),fieldLabelId:"webAuthnPolicyExtraOrigins"}),children:e(ge,{name:`${p}ExtraOrigins`,"aria-label":i("webAuthnPolicyExtraOrigins"),addButtonLabel:"addOrigins"})})]}),b(B,{children:[e(v,{"data-testid":"save",variant:"primary",type:"submit",isDisabled:!P,children:i("save")}),e(v,{"data-testid":"reload",variant:F.link,onClick:()=>y(n),children:i("reload")})]})]})]})},ta=()=>{const{adminClient:n}=T(),{t:a}=S(),[o,t]=E(1),{realm:i}=k(),[s,c]=E();return re(async()=>{const d=await n.realms.findOne({realm:i});if(!d)throw new Error(a("notFound"));return d},d=>{c(d)},[]),s?b(kt,{activeKey:o,onSelect:(d,m)=>t(m),mountOnEnter:!0,unmountOnExit:!0,children:[e(O,{id:"passwordPolicy",eventKey:1,title:e(x,{children:a("passwordPolicy")}),children:e(Yt,{realm:s,realmUpdated:c})}),e(O,{id:"otpPolicy",eventKey:2,title:e(x,{children:a("otpPolicy")}),children:e(Bt,{realm:s,realmUpdated:c})}),e(O,{id:"webauthnPolicy",eventKey:3,title:e(x,{children:a("webauthnPolicy")}),children:e(Se,{realm:s,realmUpdated:c})}),e(O,{id:"webauthnPasswordlessPolicy",eventKey:4,title:e(x,{children:a("webauthnPasswordlessPolicy")}),children:e(Se,{realm:s,realmUpdated:c,isPasswordLess:!0})}),e(O,{"data-testid":"tab-ciba-policy",eventKey:5,title:e(x,{children:a("cibaPolicy")}),children:e(Kt,{realm:s,realmUpdated:c})})]}):e(ue,{})},X=new Map([["browserFlow","browser"],["registrationFlow","registration"],["directGrantFlow","direct grant"],["resetCredentialsFlow","reset credentials"],["clientAuthenticationFlow","clients"],["dockerAuthenticationFlow","docker auth"],["firstBrokerLoginFlow","firstBrokerLogin"]]),aa=({id:n,alias:a,usedBy:o,builtIn:t})=>{const{t:i}=S(),{realm:s}=k();return b(_,{children:[e(De,{to:Ie({realm:s,id:n,usedBy:o?.type||"notInUse",builtIn:t?"builtIn":void 0}),children:a},`link-${n}`)," ",t&&e(ut,{children:i("buildIn")},`label-${n}`)]})};function na(){const{adminClient:n}=T(),{t:a}=S(),{realm:o,realmRepresentation:t}=k(),[i,s]=E(0),c=()=>s(i+1),{addAlert:d,addError:m}=N(),f=Fe(),[u,g]=E(),[P,p]=ie(),[y,w]=ie(),l=async()=>{const me=await(await Te(`${_e(n.baseUrl)}admin/realms/${o}/ui-ext/authentication-management/flows`,{method:"GET",headers:Ee(await n.getAccessToken())})).json();return me?Nt(f(me,mt("alias")),qe=>qe.usedBy?.type):[]},A=C=>yt(fe({realm:o,tab:C})),r=A("flows"),h=A("required-actions"),I=A("policies"),[V,J]=pt({titleKey:"deleteConfirmFlow",children:b(Ft,{i18nKey:"deleteConfirmFlowMessage",children:[" ",e("strong",{children:{flow:u?u.alias:""}}),"."]}),continueButtonLabel:"delete",continueButtonVariant:F.danger,onConfirm:async()=>{try{await n.authenticationManagement.deleteFlow({flowId:u.id}),c(),d(a("deleteFlowSuccess"),R.success)}catch(C){m("deleteFlowError",C)}}});return t?b(_,{children:[e(J,{}),P&&e(Mt,{name:u?u.alias:"",description:u?.description,toggleDialog:p,onComplete:()=>{c(),p()}}),y&&e(Dt,{onClose:()=>{w(),c()},flowAlias:u?.alias}),e(ft,{titleKey:"titleAuthentication",subKey:"authenticationExplain",helpUrl:ct.authenticationUrl,divider:!1}),e($,{variant:"light",className:"pf-v5-u-p-0",children:b(bt,{isBox:!0,defaultLocation:fe({realm:o,tab:"flows"}),children:[e(O,{"data-testid":"flows",title:e(x,{children:a("flows")}),...r,children:e(Ve,{loader:l,ariaLabelKey:"titleAuthentication",searchPlaceholderKey:"searchForFlow",toolbarItem:e(xe,{children:e(v,{component:C=>e(De,{...C,to:dt({realm:o})}),children:a("createFlow")})}),actionResolver:({data:C})=>[{title:a("duplicate"),onClick:()=>{p(),g(C)}},...C.usedBy?.type!=="DEFAULT"?[{title:a("bindFlow"),onClick:()=>{w(),g(C)}}]:[],...!C.builtIn&&!C.usedBy?[{title:a("delete"),onClick:()=>{g(C),V()}}]:[]],columns:[{name:"alias",displayKey:"flowName",cellRenderer:C=>e(aa,{...C})},{name:"usedBy",displayKey:"usedBy",cellRenderer:C=>e($t,{authType:C,realm:t})},{name:"description",displayKey:"description"}],emptyState:e(ht,{message:a("emptyEvents"),instructions:a("emptyEventsInstructions")})},i)}),e(O,{"data-testid":"requiredActions",title:e(x,{children:a("requiredActions")}),...h,children:e(Lt,{})}),e(O,{"data-testid":"policies",title:e(x,{children:a("policies")}),...I,children:e(ta,{})})]})})]}):e(ue,{})}const Ea=Object.freeze(Object.defineProperty({__proto__:null,REALM_FLOWS:X,default:na},Symbol.toStringTag,{value:"Module"}));export{Ea as A,Dt as B,xt as C,Mt as D};
//# sourceMappingURL=AuthenticationSection-CEzcDulC.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy