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

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

There is a newer version: 25.0.1
Show newest version
import{_ as Pe,r as I,k as we,I as pe,u as C,e as K,d as D,c as F,j as e,B as S,l as $,F as P,C as R,g as v,A as k,b as He,f as de,i as Te,q as ue,K as me,S as z,J as Q,M as Se,p as Ke,N as Ce,P as q,h as w,O as be,y as Ee,z as Re,Q as Be,V as _,a as _e,R as Ge,U as xe,W as Ne,X as ze,T as Ye,Y as We,Z as Xe,t as ye,L as ke,$ as Qe,o as Je,a0 as Ze,a1 as et}from"./index-831988f6.js";import{u as tt}from"./ConfirmDialog-927d61dd.js";import{L as at}from"./PaginatingTableToolbar-c55a17f1.js";import{R as nt,u as it}from"./RoutableTabs-8afbc312.js";import{K as Fe}from"./KeycloakDataTable-2267a354.js";import{V as ot}from"./ViewHeader-2b1ad3ef.js";import{g as st}from"./getAuthorizationHeaders-f2376d1a.js";import{u as Oe,m as lt}from"./useLocaleSort-6d6b4eec.js";import{u as Y}from"./useToggle-039c9b34.js";import{N as rt}from"./NameDescription-a4992444.js";import{M as he,a as Me}from"./Modal-5d8a3df4.js";import{F as Le,A as Z}from"./Form-bd3cf98e.js";import{D as ct}from"./DraggableTable-0dae323c.js";import{f as dt}from"./resource-edcf6e4d.js";import{T as se,a as ut}from"./Text-2a2c2dcc.js";import{F as ee}from"./FormAccess-589a8032.js";import{K as W}from"./KeycloakTextInput-ead44014.js";import{S as H,a as X,b as V,C as mt,c as ht}from"./Select-9c61d949.js";import{T as Ve}from"./TimeSelector-8c03a95f.js";import{R as fe}from"./Radio-94b05d7e.js";import{N as le}from"./NumberInput-25f268d9.js";import{M as pt}from"./minus-circle-icon-d374d13f.js";import{s as bt,E as xt,a as yt}from"./EmptyStateBody-dd392e69.js";import{T as ft,a as jt,b as De}from"./ToolbarContent-186be8fd.js";import{E as gt}from"./EmptyStateSecondaryActions-3d9f7969.js";import{P as At}from"./plus-circle-icon-3c14c705.js";import{M as vt}from"./MultiLineInput-6564e881.js";import{Q as It}from"./question-circle-icon-b8a84e76.js";import{T as Pt,a as M,b as L}from"./Tabs-f8972b46.js";import{T as wt}from"./Trans-a7161087.js";var J;(function(t){t.default="default",t.plain="plain"})(J||(J={}));const re=t=>{var{className:i="",component:a="span",children:n,variant:c=J.default}=t,l=Pe(t,["className","component","children","variant"]);const p=a;return I.createElement(p,Object.assign({className:we(pe.inputGroupText,c===J.plain&&pe.modifiers.plain,i)},l),n)};re.displayName="InputGroupText";const $e=t=>{var{children:i,className:a=""}=t,n=Pe(t,["children","className"]);return I.createElement("div",Object.assign({className:we(bt.emptyStatePrimary,a)},n),i)};$e.displayName="EmptyStatePrimary";const Tt=({flowAlias:t,onClose:i})=>{const{t:a}=C("authentication"),{control:n,handleSubmit:c}=K(),{addAlert:l,addError:p}=D(),{realm:d}=F(),[h,b]=Y(),f=async({bindingType:o})=>{const m=await v.realms.findOne({realm:d});try{await v.realms.update({realm:d},{...m,[o]:t}),l(a("updateFlowSuccess"),k.success)}catch(u){p("authentication:updateFlowError",u)}i()};return e.jsx(he,{title:a("bindFlow"),variant:"small",onClose:i,actions:[e.jsx(S,{"data-testid":"save",type:"submit",form:"bind-form",children:a("common:save")},"confirm"),e.jsx(S,{"data-testid":"cancel",variant:$.link,onClick:i,children:a("common:cancel")},"cancel")],isOpen:!0,children:e.jsx(Le,{id:"bind-form",isHorizontal:!0,onSubmit:c(f),children:e.jsx(P,{label:a("chooseBindingType"),fieldId:"chooseBindingType",children:e.jsx(R,{name:"bindingType",defaultValue:"browserFlow",control:n,render:({field:o})=>e.jsx(H,{toggleId:"chooseBindingType",onToggle:b,onSelect:(m,u)=>{o.onChange(u.toString()),b()},selections:o.value,variant:X.single,isOpen:h,menuAppendTo:"parent",children:[...G.keys()].filter(m=>m!=="dockerAuthenticationFlow").map(m=>{const u=G.get(m);return e.jsx(V,{selected:m===G.get(m),value:m,children:a(`flow.${u}`)},m)})})})})})})},St=({name:t,description:i,toggleDialog:a,onComplete:n})=>{const{t:c}=C("authentication"),l=K({mode:"onChange"}),{setValue:p,getValues:d,handleSubmit:h}=l,{addAlert:b,addError:f}=D(),o=He(),{realm:m}=F();I.useEffect(()=>{p("alias",c("copyOf",{name:t})),p("description",i)},[t,i]);const u=async()=>{const y=d();try{await v.authenticationManagement.copyFlow({flow:t,newName:y.alias});const x=(await v.authenticationManagement.getFlows()).find(T=>T.alias===y.alias);y.description!==i&&(x.description=y.description,await v.authenticationManagement.updateFlow({flowId:x.id},x)),b(c("copyFlowSuccess"),k.success),o(Te({realm:m,id:x.id,usedBy:"notInUse",builtIn:x.builtIn?"builtIn":void 0}))}catch(x){f("authentication:copyFlowError",x)}n()};return e.jsx(he,{title:c("duplicateFlow"),onClose:a,variant:Me.small,actions:[e.jsx(S,{"data-testid":"confirm",type:"submit",form:"duplicate-flow-form",children:c("duplicate")},"confirm"),e.jsx(S,{"data-testid":"cancel",variant:$.link,onClick:a,children:c("common:cancel")},"cancel")],isOpen:!0,children:e.jsx(de,{...l,children:e.jsx(Le,{id:"duplicate-flow-form",onSubmit:h(u),isHorizontal:!0,children:e.jsx(rt,{})})})})},Ct=()=>{const{t}=C("authentication"),{addAlert:i,addError:a}=D(),[n,c]=I.useState(),[l,p]=I.useState(0),d=()=>p(l+1);ue(async()=>{const[o,m]=await Promise.all([v.authenticationManagement.getRequiredActions(),v.authenticationManagement.getUnregisteredRequiredActions()]);return[...o.map(u=>({name:u.name,enabled:u.enabled,defaultAction:u.defaultAction,data:u})),...m.map(u=>({name:u.name,enabled:!1,defaultAction:!1,data:u}))]},o=>c(o),[l]);const h=o=>!("alias"in o),b=async(o,m)=>{try{m in o?(o[m]=!o[m],await v.authenticationManagement.updateRequiredAction({alias:o.alias},o)):h(o)&&await v.authenticationManagement.registerRequiredAction({name:o.name,providerId:o.providerId}),d(),i(t("updatedRequiredActionSuccess"),k.success)}catch(u){a("authentication:updatedRequiredActionError",u)}},f=async(o,m)=>{try{const u=o.alias;for(let y=0;y0?await v.authenticationManagement.lowerRequiredActionPriority({alias:u}):await v.authenticationManagement.raiseRequiredActionPriority({alias:u});d(),i(t("updatedRequiredActionSuccess"),k.success)}catch(u){a("authentication:updatedRequiredActionError",u)}};return n?e.jsx(ct,{keyField:"name",onDragFinish:async(o,m)=>{const u=n.map(j=>j.name),y=m.indexOf(o),x=u.indexOf(o),T=n[x].data;if(!T.alias)return;const g=y-x;f(T,g)},columns:[{name:"name",displayKey:"authentication:requiredActions"},{name:"enabled",displayKey:"common:enabled",cellRenderer:o=>e.jsx(z,{id:`enable-${Q(o.name)}`,label:t("common:on"),labelOff:t("common:off"),isChecked:o.enabled,onChange:()=>{b(o.data,"enabled")},"aria-label":Q(o.name)})},{name:"default",displayKey:"authentication:setAsDefaultAction",thTooltipText:"authentication-help:authDefaultActionTooltip",cellRenderer:o=>e.jsx(z,{id:`default-${Q(o.name)}`,label:t("common:on"),isDisabled:!o.enabled,labelOff:o.enabled?t("common:off"):t("disabledOff"),isChecked:o.defaultAction,onChange:()=>{b(o.data,"defaultAction")},"aria-label":Q(o.name)})}],data:n}):e.jsx(me,{})},Et="_label_1r9ky_1",ce={label:Et},te=({label:t})=>e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:ce.label})," ",t]}),Rt=({id:t,isSpecificClient:i,onClose:a})=>{const{t:n}=C("authentication"),c=async(l,p,d)=>(await dt({id:t,type:i?"clients":"idp",first:l||0,max:p||10,search:d})).map(b=>({name:b}));return e.jsx(he,{header:e.jsxs(Ce,{children:[e.jsx(se,{component:ut.h1,children:n("flowUsedBy")}),e.jsx(se,{children:n("flowUsedByDescription",{value:n(i?"clients":"identiyProviders")})})]}),variant:Me.medium,isOpen:!0,onClose:a,actions:[e.jsx(S,{"data-testid":"cancel",id:"modal-cancel",onClick:a,children:n("common:close")},"cancel")],children:e.jsx(Fe,{loader:c,isPaginated:!0,ariaLabelKey:"authentication:usedBy",searchPlaceholderKey:"common:search",columns:[{name:"name"}]})})},_t=({authType:{id:t,usedBy:i},realm:a})=>{const{t:n}=C("authentication"),[c,l]=Y(),p=Object.entries(a).find(d=>d[1]===i?.values[0])?.[0];return e.jsxs(e.Fragment,{children:[c&&e.jsx(Rt,{id:t,onClose:l,isSpecificClient:i?.type==="SPECIFIC_CLIENTS"}),(i?.type==="SPECIFIC_PROVIDERS"||i?.type==="SPECIFIC_CLIENTS")&&(i.values.length<=8?e.jsx(Se,{"aria-label":n("usedBy"),bodyContent:e.jsxs("div",{children:[n("appliedBy"+(i.type==="SPECIFIC_CLIENTS"?"Clients":"Providers"))," ",i.values.map((d,h)=>e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:d}),h{const{t:a}=C("authentication"),{control:n,register:c,handleSubmit:l,setValue:p,formState:{errors:d,isValid:h,isDirty:b}}=K({mode:"onChange"}),{realm:f}=F(),{addAlert:o,addError:m}=D(),[u,y]=I.useState(!1),[x,T]=I.useState(!1),g=s=>Ee(s,p);I.useEffect(()=>g(t),[]);const j=async s=>{try{await v.realms.update({realm:f},Re(s));const r=await v.realms.findOne({realm:f});i(r),g(r),o(a("updateCibaSuccess"),k.success)}catch(r){m("authentication:updateCibaError",r)}};return e.jsx(q,{variant:"light",children:e.jsxs(ee,{role:"manage-realm",isHorizontal:!0,onSubmit:l(j),children:[e.jsx(P,{fieldId:"cibaBackchannelTokenDeliveryMode",label:a("cibaBackchannelTokenDeliveryMode"),labelIcon:e.jsx(w,{helpText:a("authentication-help:cibaBackchannelTokenDeliveryMode"),fieldLabelId:"authentication:cibaBackchannelTokenDeliveryMode"}),children:e.jsx(R,{name:"attributes.cibaBackchannelTokenDeliveryMode",defaultValue:je[0],control:n,render:({field:s})=>e.jsx(H,{toggleId:"cibaBackchannelTokenDeliveryMode",onSelect:(r,E)=>{y(!1),s.onChange(E.toString())},selections:s.value,variant:X.single,isOpen:u,onToggle:r=>y(r),children:je.map(r=>e.jsx(V,{value:r,selected:r===s.value,children:a(`cibaBackhannelTokenDeliveryModes.${r}`)},r))})})}),e.jsx(P,{fieldId:"cibaExpiresIn",label:a("cibaExpiresIn"),labelIcon:e.jsx(w,{helpText:a("authentication-help:cibaExpiresIn"),fieldLabelId:"authentication:cibaExpiresIn"}),validated:d.attributes?.cibaExpiresIn?"error":"default",helperTextInvalid:d.attributes?.cibaExpiresIn?.message,isRequired:!0,children:e.jsxs(be,{children:[e.jsx(W,{id:"cibaExpiresIn",type:"number",min:ae,max:ne,...c("attributes.cibaExpiresIn",{min:{value:ae,message:a("common:greaterThan",{value:ae})},max:{value:ne,message:a("common:lessThan",{value:ne})},required:{value:!0,message:a("common:required")}}),validated:d.attributes?.cibaExpiresIn?"error":"default"}),e.jsx(re,{variant:"plain",children:a("common:times:seconds")})]})}),e.jsx(P,{fieldId:"cibaInterval",label:a("cibaInterval"),labelIcon:e.jsx(w,{helpText:a("authentication-help:cibaInterval"),fieldLabelId:"authentication:cibaInterval"}),validated:d.attributes?.cibaInterval?"error":"default",helperTextInvalid:d.attributes?.cibaInterval?.message,isRequired:!0,children:e.jsxs(be,{children:[e.jsx(W,{id:"cibaInterval",type:"number",min:ie,max:oe,...c("attributes.cibaInterval",{min:{value:ie,message:a("common:greaterThan",{value:ie})},max:{value:oe,message:a("common:lessThan",{value:oe})},required:{value:!0,message:a("common:required")}}),validated:d.attributes?.cibaInterval?"error":"default"}),e.jsx(re,{variant:"plain",children:a("common:times:seconds")})]})}),e.jsx(P,{fieldId:"cibaAuthRequestedUserHint",label:a("cibaAuthRequestedUserHint"),labelIcon:e.jsx(w,{helpText:a("authentication-help:cibaAuthRequestedUserHint"),fieldLabelId:"authentication:cibaAuthRequestedUserHint"}),children:e.jsxs(H,{toggleId:"cibaAuthRequestedUserHint",selections:"login_hint",isOpen:x,onToggle:s=>T(s),isDisabled:!0,children:[e.jsx(V,{value:"login_hint",children:"login_hint"}),e.jsx(V,{value:"id_token_hint",children:"id_token_hint"}),e.jsx(V,{value:"login_hint_token",children:"login_hint_token"})]})}),e.jsxs(Z,{children:[e.jsx(S,{"data-testid":"save",variant:"primary",type:"submit",isDisabled:!h||!b,children:a("common:save")}),e.jsx(S,{"data-testid":"reload",variant:$.link,onClick:()=>g({...t}),children:a("common:reload")})]})]})})};const U=["totp","hotp"],ge=["SHA1","SHA256","SHA512"],Ae=[6,8],kt=({realm:t,realmUpdated:i})=>{const{t:a}=C("authentication"),{control:n,reset:c,handleSubmit:l,formState:{isValid:p,isDirty:d,errors:h}}=K({mode:"onChange",defaultValues:t}),{realm:b}=F(),{addAlert:f,addError:o}=D(),m=Oe(),[u,y]=Y(),x=Be({name:"otpPolicyType",control:n,defaultValue:U[0]}),T=s=>c(s);I.useEffect(()=>T(t),[]);const g=I.useMemo(()=>{const s=(t.otpSupportedApplications??[]).map(r=>a(`otpSupportedApplications.${r}`));return m(s,r=>r)},[t.otpSupportedApplications]),j=async s=>{try{await v.realms.update({realm:b},s);const r=await v.realms.findOne({realm:b});i(r),T(r),f(a("updateOtpSuccess"),k.success)}catch(r){o("authentication:updateOtpError",r)}};return e.jsx(q,{variant:"light",children:e.jsxs(ee,{role:"manage-realm",isHorizontal:!0,onSubmit:l(j),className:"keycloak__otp_policies_authentication__form",children:[e.jsx(P,{label:a("otpType"),labelIcon:e.jsx(w,{helpText:a("authentication-help:otpType"),fieldLabelId:"authentication:otpType"}),hasNoPaddingTop:!0,children:e.jsx(R,{name:"otpPolicyType","data-testid":"otpPolicyType",defaultValue:U[0],control:n,render:({field:s})=>e.jsx(e.Fragment,{children:U.map(r=>e.jsx(fe,{id:r,"data-testid":r,isChecked:s.value===r,name:"otpPolicyType",onChange:()=>s.onChange(r),label:a(`policyType.${r}`),className:"keycloak__otp_policies_authentication__policy-type"},r))})})}),e.jsx(P,{label:a("otpHashAlgorithm"),labelIcon:e.jsx(w,{helpText:a("authentication-help:otpHashAlgorithm"),fieldLabelId:"authentication:otpHashAlgorithm"}),fieldId:"otpHashAlgorithm",children:e.jsx(R,{name:"otpPolicyAlgorithm",defaultValue:`Hmac${ge[0]}`,control:n,render:({field:s})=>e.jsx(H,{toggleId:"otpHashAlgorithm",onToggle:y,onSelect:(r,E)=>{s.onChange(E.toString()),y()},selections:s.value,variant:X.single,isOpen:u,children:ge.map(r=>e.jsx(V,{selected:`Hmac${r}`===s.value,value:`Hmac${r}`,children:r},r))})})}),e.jsx(P,{label:a("otpPolicyDigits"),labelIcon:e.jsx(w,{helpText:a("authentication-help:otpPolicyDigits"),fieldLabelId:"authentication:otpPolicyDigits"}),hasNoPaddingTop:!0,children:e.jsx(R,{name:"otpPolicyDigits","data-testid":"otpPolicyDigits",defaultValue:Ae[0],control:n,render:({field:s})=>e.jsx(e.Fragment,{children:Ae.map(r=>e.jsx(fe,{id:`digit-${r}`,"data-testid":`digit-${r}`,isChecked:s.value===r,name:"otpPolicyDigits",onChange:()=>s.onChange(r),label:r,className:"keycloak__otp_policies_authentication__number-of-digits"},r))})})}),e.jsx(P,{label:a("lookAround"),labelIcon:e.jsx(w,{helpText:a("authentication-help:lookAround"),fieldLabelId:"authentication:lookAround"}),fieldId:"lookAround",children:e.jsx(R,{name:"otpPolicyLookAheadWindow",defaultValue:1,control:n,render:({field:s})=>{const E=s.value??1,N=A=>s.onChange(Math.max(A,0));return e.jsx(le,{id:"lookAround",value:E,min:0,onPlus:()=>N(E+1),onMinus:()=>N(E-1),onChange:A=>{const O=Number(A.currentTarget.value);N(isNaN(O)?0:O)}})}})}),x===U[0]&&e.jsx(P,{label:a("otpPolicyPeriod"),fieldId:"otpPolicyPeriod",helperTextInvalid:a("otpPolicyPeriodErrorHint"),validated:h.otpPolicyPeriod?_.error:_.default,labelIcon:e.jsx(w,{helpText:a("authentication-help:otpPolicyPeriod"),fieldLabelId:"authentication:otpPolicyPeriod"}),children:e.jsx(R,{name:"otpPolicyPeriod",defaultValue:30,control:n,rules:{min:1,max:120},render:({field:s})=>{const r=s.value??30;return e.jsx(Ve,{id:"otpPolicyPeriod","data-testid":"otpPolicyPeriod",value:r,onChange:s.onChange,units:["second","minute"],validated:h.otpPolicyPeriod?_.error:_.default})}})}),x===U[1]&&e.jsx(P,{label:a("initialCounter"),fieldId:"initialCounter",helperTextInvalid:a("initialCounterErrorHint"),validated:h.otpPolicyInitialCounter?_.error:_.default,labelIcon:e.jsx(w,{helpText:a("authentication-help:initialCounter"),fieldLabelId:"authentication:initialCounter"}),children:e.jsx(R,{name:"otpPolicyInitialCounter",defaultValue:30,control:n,rules:{min:1,max:120},render:({field:s})=>{const E=s.value??30,N=A=>s.onChange(Math.max(A,1));return e.jsx(le,{id:"initialCounter",value:E,min:1,onPlus:()=>N(E+1),onMinus:()=>N(E-1),onChange:A=>{const O=Number(A.currentTarget.value);N(isNaN(O)?30:O)}})}})}),e.jsx(P,{label:a("supportedApplications"),labelIcon:e.jsx(w,{helpText:a("authentication-help:supportedApplications"),fieldLabelId:"authentication:supportedApplications"}),children:e.jsx(mt,{"data-testid":"supportedApplications",children:g.map(s=>e.jsx(ht,{isReadOnly:!0,children:s},s))})}),x===U[0]&&e.jsx(P,{label:a("otpPolicyCodeReusable"),fieldId:"otpPolicyCodeReusable",labelIcon:e.jsx(w,{helpText:a("authentication-help:otpPolicyCodeReusable"),fieldLabelId:"authentication:otpPolicyCodeReusable"}),children:e.jsx(R,{name:"otpPolicyCodeReusable",defaultValue:!0,control:n,render:({field:s})=>e.jsx(z,{id:"otpPolicyCodeReusable",label:a("common:on"),labelOff:a("common:off"),isChecked:s.value,onChange:s.onChange})})}),e.jsxs(Z,{children:[e.jsx(S,{"data-testid":"save",variant:"primary",type:"submit",isDisabled:!p||!d,children:a("common:save")}),e.jsx(S,{"data-testid":"reload",variant:$.link,onClick:()=>c({...t}),children:a("common:reload")})]})]})})};const Ft=({policy:{id:t,configType:i,defaultValue:a,displayName:n},onRemove:c})=>{const{t:l}=C("authentication"),{control:p,register:d,formState:{errors:h}}=_e();return e.jsx(P,{label:n,fieldId:t,isRequired:!0,helperTextInvalid:l("common:required"),validated:h[t]?_.error:_.default,labelIcon:e.jsx(w,{helpText:l(`authentication-help:passwordPolicies.${t}`),fieldLabelId:`authentication:${t}`}),children:e.jsxs(Ge,{children:[e.jsxs(xe,{isFilled:!0,children:[i&&i!=="int"&&e.jsx(W,{id:t,"data-testid":t,...d(t,{required:!0}),defaultValue:a,validated:h[t]?_.error:_.default}),i==="int"&&e.jsx(R,{name:t,defaultValue:Number.parseInt(a||"0"),control:p,render:({field:b})=>{const o=u=>b.onChange(Math.max(u,0)),m=Number(b.value);return e.jsx(le,{id:t,value:m,min:0,onPlus:()=>o(m+1),onMinus:()=>o(m-1),onChange:u=>{const y=Number(u.currentTarget.value);o(isNaN(y)?0:y)},className:"keycloak__policies_authentication__number-field"})}}),!i&&e.jsx(z,{id:t,label:l("common:on"),labelOff:l("common:off"),isChecked:!0,isDisabled:!0,"aria-label":n})]}),e.jsx(xe,{children:e.jsx(S,{"data-testid":`remove-${t}`,variant:"link",className:"keycloak__policies_authentication__minus-icon",onClick:()=>c(t),"aria-label":l("common:remove"),children:e.jsx(pt,{})})})]})})},Ue=" and ",Ot=(t,i)=>t.map(a=>`${a.id}(${i[a.id]})`).join(Ue),Mt=(t,i)=>t.split(Ue).map(Lt).reduce((a,{id:n,value:c})=>{const l=i.find(p=>p.id===n);return l?a.concat({...l,value:c}):a},[]);function Lt(t){const i=t.indexOf("(");if(i===-1)return{id:t.trim()};const a=t.substring(0,i).trim(),n=t.lastIndexOf(")");if(n===-1)return{id:a};const c=t.substring(i+1,n).trim();return{id:a,value:c}}const ve=({onSelect:t,selectedPolicies:i})=>{const{t:a}=C("authentication"),{passwordPolicies:n}=Ne(),[c,l]=I.useState(!1),p=I.useMemo(()=>n?.filter(d=>i.find(h=>h.id===d.id)===void 0),[i]);return e.jsx(H,{width:300,onSelect:(d,h)=>{t(h),l(!1)},onToggle:d=>l(d),isOpen:c,selections:a("addPolicy"),isDisabled:p?.length===0,children:p?.map(d=>e.jsx(V,{value:d,children:d.displayName},d.id))})},Vt=({realm:t,realmUpdated:i})=>{const{t:a}=C("authentication"),{passwordPolicies:n}=Ne(),{addAlert:c,addError:l}=D(),{realm:p}=F(),[d,h]=I.useState([]),b=g=>{h([...d,g]),m(g.id,g.defaultValue,{shouldDirty:!0})},f=K({defaultValues:{}}),{handleSubmit:o,setValue:m,reset:u,formState:{isDirty:y}}=f,x=g=>{u();const j=Mt(g.passwordPolicy||"",n);j.forEach(s=>{m(s.id,s.value)}),h(j)};I.useEffect(()=>x(t),[]);const T=async g=>{const j={...t,passwordPolicy:Ot(d,g)};try{await v.realms.update({realm:p},j),i(j),x(j),c(a("updatePasswordPolicySuccess"),k.success)}catch(s){l("authentication:updatePasswordPolicyError",s)}};return e.jsxs(q,{variant:"light",className:"pf-u-p-0",children:[(d.length!==0||t.passwordPolicy)&&e.jsxs(e.Fragment,{children:[e.jsx(ft,{children:e.jsx(jt,{children:e.jsx(De,{children:e.jsx(ve,{onSelect:b,selectedPolicies:d})})})}),e.jsx(ze,{}),e.jsx(q,{variant:"light",children:e.jsx(de,{...f,children:e.jsxs(ee,{className:"keycloak__policies_authentication__form",role:"manage-realm",isHorizontal:!0,onSubmit:o(T),children:[d.map((g,j)=>e.jsx(Ft,{policy:g,onRemove:s=>{h(d.filter(r=>r.id!==s)),m(g.id,"",{shouldDirty:!0})}},`${g.id}-${j}`)),e.jsxs(Z,{children:[e.jsx(S,{"data-testid":"save",variant:"primary",type:"submit",isDisabled:!y,children:a("common:save")}),e.jsx(S,{"data-testid":"reload",variant:$.link,onClick:()=>x(t),children:a("common:reload")})]})]})})})]}),!d.length&&!t.passwordPolicy&&e.jsxs(xt,{"data-testid":"empty-state",variant:"large",children:[e.jsx(gt,{icon:At}),e.jsx(Ye,{headingLevel:"h1",size:"lg",children:a("noPasswordPolicies")}),e.jsx(yt,{children:a("noPasswordPoliciesInstructions")}),e.jsx($e,{children:e.jsx(ve,{onSelect:b,selectedPolicies:[]})})]})]})};const Dt=["ES256","ES384","ES512","RS256","RS384","RS512","RS1"],$t=["not specified","none","indirect","direct"],Ut=["not specified","platform","cross-platform"],qt=["not specified","Yes","No"],Ht=["not specified","required","preferred","discouraged"],B=({name:t,label:i,options:a,labelPrefix:n,isMultiSelect:c=!1})=>{const{t:l}=C("authentication"),{control:p}=_e(),[d,h]=I.useState(!1);return e.jsx(P,{label:l(i),labelIcon:e.jsx(w,{helpText:l(`authentication-help:${i}`),fieldLabelId:`authentication:${i}`}),fieldId:t,children:e.jsx(R,{name:t,defaultValue:a[0],control:p,render:({field:b})=>e.jsx(H,{toggleId:t,onToggle:h,onSelect:(f,o)=>{if(c){const m=b.value.find(u=>u===o)?b.value.filter(u=>u!==o):[...b.value,o];b.onChange(m)}else b.onChange(o.toString()),h(!1)},selections:n?l(`${n}.${b.value}`):b.value,variant:c?X.typeaheadMulti:X.single,"aria-label":l(t),typeAheadAriaLabel:l(t),isOpen:d,children:a.map(f=>e.jsx(V,{selected:f===b.value,value:f,children:n?l(`${n}.${f}`):f},f))})})})},Ie=({realm:t,realmUpdated:i,isPasswordLess:a=!1})=>{const{t:n}=C("authentication"),{addAlert:c,addError:l}=D(),{realm:p}=F(),{enabled:d}=We(),h=K({mode:"onChange"}),{control:b,register:f,setValue:o,handleSubmit:m,formState:{isDirty:u,errors:y}}=h,x=a?"webAuthnPolicyPasswordless":"webAuthnPolicy",T=j=>Ee(j,o);I.useEffect(()=>T(t),[]);const g=async j=>{const s=Re(j);try{await v.realms.update({realm:p},s),i(s),T(s),c(n("webAuthnUpdateSuccess"),k.success)}catch(r){l("authentication:webAuthnUpdateError",r)}};return e.jsxs(q,{variant:"light",children:[d&&e.jsx(Se,{bodyContent:n(`authentication-help:${x}FormHelp`),children:e.jsx(Ce,{className:"keycloak__section_intro__help",children:e.jsxs(se,{children:[e.jsx(It,{})," ",n("authentication-help:webauthnIntro")]})})}),e.jsxs(ee,{role:"manage-realm",isHorizontal:!0,onSubmit:m(g),className:"keycloak__webauthn_policies_authentication__form",children:[e.jsx(P,{label:n("webAuthnPolicyRpEntityName"),fieldId:"webAuthnPolicyRpEntityName",helperTextInvalid:n("common:required"),validated:y.webAuthnPolicyRpEntityName?"error":"default",isRequired:!0,labelIcon:e.jsx(w,{helpText:n("authentication-help:webAuthnPolicyRpEntityName"),fieldLabelId:"authentication:webAuthnPolicyRpEntityName"}),children:e.jsx(W,{id:"webAuthnPolicyRpEntityName","data-testid":"webAuthnPolicyRpEntityName",validated:y.webAuthnPolicyRpEntityName?"error":"default",...f(`${x}RpEntityName`,{required:!0})})}),e.jsxs(de,{...h,children:[e.jsx(B,{name:`${x}SignatureAlgorithms`,label:"webAuthnPolicySignatureAlgorithms",options:Dt,isMultiSelect:!0}),e.jsx(P,{label:n("webAuthnPolicyRpId"),labelIcon:e.jsx(w,{helpText:n("authentication-help:webAuthnPolicyRpId"),fieldLabelId:"authentication:webAuthnPolicyRpId"}),fieldId:"webAuthnPolicyRpId",children:e.jsx(W,{id:"webAuthnPolicyRpId","data-testid":"webAuthnPolicyRpId",...f(`${x}RpId`)})}),e.jsx(B,{name:`${x}AttestationConveyancePreference`,label:"webAuthnPolicyAttestationConveyancePreference",options:$t,labelPrefix:"attestationPreference"}),e.jsx(B,{name:`${x}AuthenticatorAttachment`,label:"webAuthnPolicyAuthenticatorAttachment",options:Ut,labelPrefix:"authenticatorAttachment"}),e.jsx(B,{name:`${x}RequireResidentKey`,label:"webAuthnPolicyRequireResidentKey",options:qt,labelPrefix:"residentKey"}),e.jsx(B,{name:`${x}UserVerificationRequirement`,label:"webAuthnPolicyUserVerificationRequirement",options:Ht,labelPrefix:"userVerify"}),e.jsx(P,{label:n("webAuthnPolicyCreateTimeout"),fieldId:"webAuthnPolicyCreateTimeout",helperTextInvalid:n("webAuthnPolicyCreateTimeoutHint"),validated:y.webAuthnPolicyCreateTimeout?"error":"default",labelIcon:e.jsx(w,{helpText:n("authentication-help:webAuthnPolicyCreateTimeout"),fieldLabelId:"authentication:webAuthnPolicyCreateTimeout"}),children:e.jsx(R,{name:`${x}CreateTimeout`,defaultValue:0,control:b,rules:{min:0,max:31536},render:({field:j})=>e.jsx(Ve,{"data-testid":"webAuthnPolicyCreateTimeout","aria-label":n("webAuthnPolicyCreateTimeout"),value:j.value,onChange:j.onChange,units:["second","minute","hour"],validated:y.webAuthnPolicyCreateTimeout?"error":"default"})})}),e.jsx(P,{label:n("webAuthnPolicyAvoidSameAuthenticatorRegister"),fieldId:"webAuthnPolicyAvoidSameAuthenticatorRegister",labelIcon:e.jsx(w,{helpText:n("authentication-help:webAuthnPolicyAvoidSameAuthenticatorRegister"),fieldLabelId:"authentication:webAuthnPolicyAvoidSameAuthenticatorRegister"}),children:e.jsx(R,{name:`${x}AvoidSameAuthenticatorRegister`,defaultValue:!1,control:b,render:({field:j})=>e.jsx(z,{id:"webAuthnPolicyAvoidSameAuthenticatorRegister",label:n("common:on"),labelOff:n("common:off"),isChecked:j.value,onChange:j.onChange,"aria-label":n("webAuthnPolicyAvoidSameAuthenticatorRegister")})})}),e.jsx(P,{label:n("webAuthnPolicyAcceptableAaguids"),fieldId:"webAuthnPolicyAcceptableAaguids",labelIcon:e.jsx(w,{helpText:n("authentication-help:webAuthnPolicyAcceptableAaguids"),fieldLabelId:"authentication:webAuthnPolicyAcceptableAaguids"}),children:e.jsx(vt,{name:`${x}AcceptableAaguids`,"aria-label":n("webAuthnPolicyAcceptableAaguids"),addButtonLabel:"authentication:addAaguids"})})]}),e.jsxs(Z,{children:[e.jsx(S,{"data-testid":"save",variant:"primary",type:"submit",isDisabled:!u,children:n("common:save")}),e.jsx(S,{"data-testid":"reload",variant:$.link,onClick:()=>T(t),children:n("common:reload")})]})]})]})},Kt=()=>{const{t}=C("authentication"),[i,a]=I.useState(1),{realm:n}=F(),[c,l]=I.useState();return ue(async()=>{const p=await v.realms.findOne({realm:n});if(!p)throw new Error(t("common:notFound"));return p},p=>{l(p)},[]),c?e.jsxs(Pt,{activeKey:i,onSelect:(p,d)=>a(d),mountOnEnter:!0,unmountOnExit:!0,children:[e.jsx(M,{id:"passwordPolicy",eventKey:1,title:e.jsx(L,{children:t("passwordPolicy")}),children:e.jsx(Vt,{realm:c,realmUpdated:l})}),e.jsx(M,{id:"otpPolicy",eventKey:2,title:e.jsx(L,{children:t("otpPolicy")}),children:e.jsx(kt,{realm:c,realmUpdated:l})}),e.jsx(M,{id:"webauthnPolicy",eventKey:3,title:e.jsx(L,{children:t("webauthnPolicy")}),children:e.jsx(Ie,{realm:c,realmUpdated:l})}),e.jsx(M,{id:"webauthnPasswordlessPolicy",eventKey:4,title:e.jsx(L,{children:t("webauthnPasswordlessPolicy")}),children:e.jsx(Ie,{realm:c,realmUpdated:l,isPasswordLess:!0})}),e.jsx(M,{"data-testid":"tab-ciba-policy",eventKey:5,title:e.jsx(L,{children:t("cibaPolicy")}),children:e.jsx(Nt,{realm:c,realmUpdated:l})})]}):e.jsx(me,{})},G=new Map([["browserFlow","browser"],["registrationFlow","registration"],["directGrantFlow","direct grant"],["resetCredentialsFlow","reset credentials"],["clientAuthenticationFlow","clients"],["dockerAuthenticationFlow","docker auth"]]),Bt=({id:t,alias:i,usedBy:a,builtIn:n})=>{const{t:c}=C("authentication"),{realm:l}=F();return e.jsxs(e.Fragment,{children:[e.jsx(ke,{to:Te({realm:l,id:t,usedBy:a?.type||"notInUse",builtIn:n?"builtIn":void 0}),children:i},`link-${t}`)," ",n&&e.jsx(Je,{children:c("buildIn")},`label-${t}`)]})};function Gt(){const{t}=C("authentication"),{realm:i}=F(),[a,n]=I.useState(0),c=()=>{x(void 0),n(a+1)},{addAlert:l,addError:p}=D(),d=Oe(),[h,b]=I.useState(),[f,o]=Y(),[m,u]=Y(),[y,x]=I.useState();ue(()=>v.realms.findOne({realm:i}),x,[a]);const T=async()=>{const O=await(await fetch(`${Ze(v.baseUrl)}admin/realms/${i}/ui-ext/authentication-management/flows`,{method:"GET",headers:st(await v.getAccessToken())})).json();return O?et(d(O,lt("alias")),qe=>qe.usedBy?.type):[]},g=A=>it(ye({realm:i,tab:A})),j=g("flows"),s=g("required-actions"),r=g("policies"),[E,N]=tt({titleKey:"authentication:deleteConfirmFlow",children:e.jsxs(wt,{i18nKey:"authentication:deleteConfirmFlowMessage",children:[" ",e.jsx("strong",{children:{flow:h?h.alias:""}}),"."]}),continueButtonLabel:"common:delete",continueButtonVariant:$.danger,onConfirm:async()=>{try{await v.authenticationManagement.deleteFlow({flowId:h.id}),c(),l(t("deleteFlowSuccess"),k.success)}catch(A){p("authentication:deleteFlowError",A)}}});return y?e.jsxs(e.Fragment,{children:[e.jsx(N,{}),f&&e.jsx(St,{name:h?h.alias:"",description:h?.description,toggleDialog:o,onComplete:()=>{c(),o()}}),m&&e.jsx(Tt,{onClose:()=>{u(),c()},flowAlias:h?.alias}),e.jsx(ot,{titleKey:"authentication:title",subKey:"authentication:authenticationExplain",helpUrl:Xe.authenticationUrl,divider:!1}),e.jsx(q,{variant:"light",className:"pf-u-p-0",children:e.jsxs(nt,{isBox:!0,defaultLocation:ye({realm:i,tab:"flows"}),children:[e.jsx(M,{"data-testid":"flows",title:e.jsx(L,{children:t("flows")}),...j,children:e.jsx(Fe,{loader:T,ariaLabelKey:"authentication:title",searchPlaceholderKey:"authentication:searchForFlow",toolbarItem:e.jsx(De,{children:e.jsx(S,{component:A=>e.jsx(ke,{...A,to:Qe({realm:i})}),children:t("createFlow")})}),actionResolver:({data:A})=>[{title:t("duplicate"),onClick:()=>{o(),b(A)}},...A.usedBy?.type!=="DEFAULT"?[{title:t("bindFlow"),onClick:()=>{u(),b(A)}}]:[],...!A.builtIn&&!A.usedBy?[{title:t("common:delete"),onClick:()=>{b(A),E()}}]:[]],columns:[{name:"alias",displayKey:"authentication:flowName",cellRenderer:A=>e.jsx(Bt,{...A})},{name:"usedBy",displayKey:"authentication:usedBy",cellRenderer:A=>e.jsx(_t,{authType:A,realm:y})},{name:"description",displayKey:"common:description"}],emptyState:e.jsx(at,{message:t("emptyEvents"),instructions:t("emptyEventsInstructions")})},a)}),e.jsx(M,{"data-testid":"requiredActions",title:e.jsx(L,{children:t("requiredActions")}),...s,children:e.jsx(Ct,{})}),e.jsx(M,{"data-testid":"policies",title:e.jsx(L,{children:t("policies")}),...r,children:e.jsx(Kt,{})})]})})]}):e.jsx(me,{})}const Ia=Object.freeze(Object.defineProperty({__proto__:null,REALM_FLOWS:G,default:Gt},Symbol.toStringTag,{value:"Module"}));export{Ia as A,Tt as B,St as D};
//# sourceMappingURL=AuthenticationSection-9ac18881.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy