UnisKB/static/admin/assets/index-C-nc-6Pq.js

2 lines
32 KiB
JavaScript

import{ay as L,aB as $,aU as B,aC as s,b6 as G,aD as r,b7 as T,aE as p,aW as b,aH as l,aG as n,b8 as q,aK as P,aJ as _,aI as V,b2 as k,bJ as J,bI as z,bK as H,b3 as O,aF as E,a_ as pe,a$ as me,b0 as ge,dI as fe,aX as W,aY as X,c1 as ae,b1 as N,ci as _e,cf as le,aS as ve,aA as he,az as be,cq as we}from"./admin-DgPvPHD7.js";import{a as D}from"./auth-setting-CNQF6zHn.js";import{_ as ye,a as Ve,b as $e,c as ke,d as Ue,e as Pe}from"./logo_wechat-CtSPVOnf.js";const Ce={class:"authentication-setting__main main-calc-height"},Ie={class:"form-container p-24"},Se={class:"mr-12"},Ae=L({__name:"LDAP",setup(A){const a=$({id:"",auth_type:"LDAP",config:{ldap_server:"",base_dn:"",password:"",ou:"",ldap_filter:"",ldap_mapping:""},is_active:!0}),v=$(),m=$(!1),f=B({"config.ldap_server":[{required:!0,message:s("views.system.authentication.ldap.serverPlaceholder"),trigger:"blur"}],"config.base_dn":[{required:!0,message:s("views.system.authentication.ldap.bindDNPlaceholder"),trigger:"blur"}],"config.password":[{required:!0,message:s("views.login.loginForm.password.placeholder"),trigger:"blur"}],"config.ou":[{required:!0,message:s("views.system.authentication.ldap.ouPlaceholder"),trigger:"blur"}],"config.ldap_filter":[{required:!0,message:s("views.system.authentication.ldap.ldap_filterPlaceholder"),trigger:"blur"}],"config.ldap_mapping":[{required:!0,message:s("views.system.authentication.ldap.ldap_mappingPlaceholder"),trigger:"blur"}]}),U=async(t,o)=>{t&&await t.validate((c,d)=>{c&&(o?D.postAuthSetting(a.value,m).then(w=>{O(s("views.system.testSuccess"))}):D.putAuthSetting(a.value.auth_type,a.value,m).then(w=>{O(s("common.saveSuccess"))}))})};function i(){D.getAuthSetting(a.value.auth_type,m).then(t=>{t.data&&JSON.stringify(t.data)!=="{}"&&(a.value=t.data,t.data.config.ldap_mapping&&(a.value.config.ldap_mapping=JSON.stringify(JSON.parse(t.data.config.ldap_mapping))))})}return G(()=>{i()}),(t,o)=>{const c=r("el-input"),d=r("el-form-item"),w=r("el-checkbox"),I=r("el-form"),S=r("el-button"),u=r("el-scrollbar"),g=T("hasPermission"),h=T("loading");return p(),b("div",Ce,[l(u,null,{default:n(()=>[q((p(),b("div",Ie,[l(I,{ref_key:"authFormRef",ref:v,rules:f,model:a.value,"label-position":"top","require-asterisk-position":"right"},{default:n(()=>[l(d,{label:t.$t("views.system.authentication.ldap.address"),prop:"config.ldap_server"},{default:n(()=>[l(c,{modelValue:a.value.config.ldap_server,"onUpdate:modelValue":o[0]||(o[0]=e=>a.value.config.ldap_server=e),placeholder:t.$t("views.system.authentication.ldap.serverPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.ldap.bindDN"),prop:"config.base_dn"},{default:n(()=>[l(c,{modelValue:a.value.config.base_dn,"onUpdate:modelValue":o[1]||(o[1]=e=>a.value.config.base_dn=e),placeholder:t.$t("views.system.authentication.ldap.bindDNPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.password"),prop:"config.password"},{default:n(()=>[l(c,{modelValue:a.value.config.password,"onUpdate:modelValue":o[2]||(o[2]=e=>a.value.config.password=e),placeholder:t.$t("views.login.loginForm.password.placeholder"),"show-password":""},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.ldap.ou"),prop:"config.ou"},{default:n(()=>[l(c,{modelValue:a.value.config.ou,"onUpdate:modelValue":o[3]||(o[3]=e=>a.value.config.ou=e),placeholder:t.$t("views.system.authentication.ldap.ouPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.ldap.ldap_filter"),prop:"config.ldap_filter"},{default:n(()=>[l(c,{modelValue:a.value.config.ldap_filter,"onUpdate:modelValue":o[4]||(o[4]=e=>a.value.config.ldap_filter=e),placeholder:t.$t("views.system.authentication.ldap.ldap_filterPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.ldap.ldap_mapping"),prop:"config.ldap_mapping"},{default:n(()=>[l(c,{modelValue:a.value.config.ldap_mapping,"onUpdate:modelValue":o[5]||(o[5]=e=>a.value.config.ldap_mapping=e),placeholder:'{"name":"name","email":"mail","username":"cn"}'},null,8,["modelValue"])]),_:1},8,["label"]),l(d,null,{default:n(()=>[l(w,{modelValue:a.value.is_active,"onUpdate:modelValue":o[6]||(o[6]=e=>a.value.is_active=e)},{default:n(()=>[P(_(t.$t("views.system.authentication.ldap.enableAuthentication")),1)]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["rules","model"]),V("div",null,[q((p(),b("span",Se,[l(S,{onClick:o[7]||(o[7]=e=>U(v.value)),type:"primary",disabled:m.value},{default:n(()=>[P(_(t.$t("common.save")),1)]),_:1},8,["disabled"])])),[[g,new(k(J))([k(z).ADMIN],[k(H).LOGIN_AUTH_EDIT],[],"OR")]]),V("span",null,[l(S,{onClick:o[8]||(o[8]=e=>U(v.value,"test")),disabled:m.value},{default:n(()=>[P(_(t.$t("views.system.test")),1)]),_:1},8,["disabled"])])])])),[[h,m.value]])]),_:1})])}}}),Ee={class:"authentication-setting__main main-calc-height"},Re={class:"form-container p-24"},Te=L({__name:"CAS",setup(A){const a=$({id:"",auth_type:"CAS",config:{ldpUri:"",validateUrl:"",redirectUrl:""},is_active:!0}),v=$(),m=$(!1),f=B({"config.ldpUri":[{required:!0,message:s("views.system.authentication.cas.ldpUriPlaceholder"),trigger:"blur"}],"config.validateUrl":[{required:!0,message:s("views.system.authentication.cas.validateUrlPlaceholder"),trigger:"blur"}],"config.redirectUrl":[{required:!0,message:s("views.system.authentication.cas.redirectUrlPlaceholder"),trigger:"blur"}]}),U=async t=>{t&&await t.validate((o,c)=>{o&&D.putAuthSetting(a.value.auth_type,a.value,m).then(d=>{O(s("common.saveSuccess"))})})};function i(){D.getAuthSetting(a.value.auth_type,m).then(t=>{t.data&&JSON.stringify(t.data)!=="{}"&&(t.data.config.validateUrl||(t.data.config.validateUrl=t.data.config.ldpUri),a.value=t.data),a.value.config.redirectUrl||(a.value.config.redirectUrl=window.location.origin+window.MaxKB.prefix+"/api/cas")})}return G(()=>{i()}),(t,o)=>{const c=r("el-input"),d=r("el-form-item"),w=r("el-checkbox"),I=r("el-form"),S=r("el-button"),u=r("el-scrollbar"),g=T("hasPermission"),h=T("loading");return p(),b("div",Ee,[l(u,null,{default:n(()=>[q((p(),b("div",Re,[l(I,{ref_key:"authFormRef",ref:v,rules:f,model:a.value,"label-position":"top","require-asterisk-position":"right"},{default:n(()=>[l(d,{label:t.$t("views.system.authentication.cas.ldpUri"),prop:"config.ldpUri"},{default:n(()=>[l(c,{modelValue:a.value.config.ldpUri,"onUpdate:modelValue":o[0]||(o[0]=e=>a.value.config.ldpUri=e),placeholder:t.$t("views.system.authentication.cas.ldpUriPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.cas.validateUrl"),prop:"config.validateUrl"},{default:n(()=>[l(c,{modelValue:a.value.config.validateUrl,"onUpdate:modelValue":o[1]||(o[1]=e=>a.value.config.validateUrl=e),placeholder:t.$t("views.system.authentication.cas.validateUrlPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.cas.redirectUrl"),prop:"config.redirectUrl"},{default:n(()=>[l(c,{modelValue:a.value.config.redirectUrl,"onUpdate:modelValue":o[2]||(o[2]=e=>a.value.config.redirectUrl=e),placeholder:t.$t("views.system.authentication.cas.redirectUrlPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,null,{default:n(()=>[l(w,{modelValue:a.value.is_active,"onUpdate:modelValue":o[3]||(o[3]=e=>a.value.is_active=e)},{default:n(()=>[P(_(t.$t("views.system.authentication.cas.enableAuthentication")),1)]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["rules","model"]),V("div",null,[q((p(),E(S,{onClick:o[4]||(o[4]=e=>U(v.value)),type:"primary",disabled:m.value},{default:n(()=>[P(_(t.$t("common.save")),1)]),_:1},8,["disabled"])),[[g,new(k(J))([k(z).ADMIN],[k(H).LOGIN_AUTH_EDIT],[],"OR")]])])])),[[h,m.value]])]),_:1})])}}}),qe={class:"authentication-setting__main main-calc-height"},De={class:"form-container p-24"},Me=L({__name:"OIDC",setup(A){const a=$({id:"",auth_type:"OIDC",config:{authEndpoint:"",tokenEndpoint:"",userInfoEndpoint:"",scope:"",state:"",clientId:"",clientSecret:"",fieldMapping:'{"username": "preferred_username", "email": "email"}',redirectUrl:""},is_active:!0}),v=$(),m=$(!1),f=B({"config.authEndpoint":[{required:!0,message:s("views.system.authentication.oidc.authEndpointPlaceholder"),trigger:"blur"}],"config.tokenEndpoint":[{required:!0,message:s("views.system.authentication.oidc.tokenEndpointPlaceholder"),trigger:"blur"}],"config.userInfoEndpoint":[{required:!0,message:s("views.system.authentication.oidc.userInfoEndpointPlaceholder"),trigger:"blur"}],"config.scope":[{required:!0,message:s("views.system.authentication.oidc.scopePlaceholder"),trigger:"blur"}],"config.clientId":[{required:!0,message:s("views.system.authentication.oidc.clientIdPlaceholder"),trigger:"blur"}],"config.clientSecret":[{required:!0,message:s("views.system.authentication.oidc.clientSecretPlaceholder"),trigger:"blur"}],"config.fieldMapping":[{required:!0,message:s("views.system.authentication.oauth2.filedMappingPlaceholder"),trigger:"blur"}],"config.redirectUrl":[{required:!0,message:s("views.system.authentication.oidc.redirectUrlPlaceholder"),trigger:"blur"}],"config.logoutEndpoint":[{required:!0,message:s("views.system.authentication.oidc.logoutEndpointPlaceholder"),trigger:"blur"}]}),U=async(t,o)=>{t&&await t.validate((c,d)=>{c&&D.putAuthSetting(a.value.auth_type,a.value,m).then(w=>{O(s("common.saveSuccess"))})})};function i(){D.getAuthSetting(a.value.auth_type,m).then(t=>{t.data&&JSON.stringify(t.data)!=="{}"&&(a.value=t.data,(a.value.config.fieldMapping===""||a.value.config.fieldMapping===void 0)&&(a.value.config.fieldMapping='{"username": "preferred_username", "email": "email"}')),a.value.config.redirectUrl||(a.value.config.redirectUrl=window.location.origin+window.MaxKB.prefix+"/api/oidc")})}return G(()=>{i()}),(t,o)=>{const c=r("el-input"),d=r("el-form-item"),w=r("el-checkbox"),I=r("el-form"),S=r("el-button"),u=r("el-scrollbar"),g=T("hasPermission"),h=T("loading");return p(),b("div",qe,[l(u,null,{default:n(()=>[q((p(),b("div",De,[l(I,{ref_key:"authFormRef",ref:v,rules:f,model:a.value,"label-position":"top","require-asterisk-position":"right"},{default:n(()=>[l(d,{label:t.$t("views.system.authentication.oidc.authEndpoint"),prop:"config.authEndpoint"},{default:n(()=>[l(c,{modelValue:a.value.config.authEndpoint,"onUpdate:modelValue":o[0]||(o[0]=e=>a.value.config.authEndpoint=e),placeholder:t.$t("views.system.authentication.oidc.authEndpointPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oidc.tokenEndpoint"),prop:"config.tokenEndpoint"},{default:n(()=>[l(c,{modelValue:a.value.config.tokenEndpoint,"onUpdate:modelValue":o[1]||(o[1]=e=>a.value.config.tokenEndpoint=e),placeholder:t.$t("views.system.authentication.oidc.tokenEndpointPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oidc.userInfoEndpoint"),prop:"config.userInfoEndpoint"},{default:n(()=>[l(c,{modelValue:a.value.config.userInfoEndpoint,"onUpdate:modelValue":o[2]||(o[2]=e=>a.value.config.userInfoEndpoint=e),placeholder:t.$t("views.system.authentication.oidc.userInfoEndpointPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:"Scope",prop:"config.scope"},{default:n(()=>[l(c,{modelValue:a.value.config.scope,"onUpdate:modelValue":o[3]||(o[3]=e=>a.value.config.scope=e),placeholder:"openid+profile+email "},null,8,["modelValue"])]),_:1}),l(d,{label:"State",prop:"config.state"},{default:n(()=>[l(c,{modelValue:a.value.config.state,"onUpdate:modelValue":o[4]||(o[4]=e=>a.value.config.state=e),placeholder:""},null,8,["modelValue"])]),_:1}),l(d,{label:t.$t("views.system.authentication.oidc.clientId"),prop:"config.clientId"},{default:n(()=>[l(c,{modelValue:a.value.config.clientId,"onUpdate:modelValue":o[5]||(o[5]=e=>a.value.config.clientId=e),placeholder:t.$t("views.system.authentication.oidc.clientIdPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oidc.clientSecret"),prop:"config.clientSecret"},{default:n(()=>[l(c,{modelValue:a.value.config.clientSecret,"onUpdate:modelValue":o[6]||(o[6]=e=>a.value.config.clientSecret=e),placeholder:t.$t("views.system.authentication.oidc.clientSecretPlaceholder"),"show-password":""},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oauth2.filedMapping"),prop:"config.fieldMapping"},{default:n(()=>[l(c,{modelValue:a.value.config.fieldMapping,"onUpdate:modelValue":o[7]||(o[7]=e=>a.value.config.fieldMapping=e),placeholder:t.$t("views.system.authentication.oauth2.filedMappingPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oidc.redirectUrl"),prop:"config.redirectUrl"},{default:n(()=>[l(c,{modelValue:a.value.config.redirectUrl,"onUpdate:modelValue":o[8]||(o[8]=e=>a.value.config.redirectUrl=e),placeholder:t.$t("views.system.authentication.oidc.redirectUrlPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,null,{default:n(()=>[l(w,{modelValue:a.value.is_active,"onUpdate:modelValue":o[9]||(o[9]=e=>a.value.is_active=e)},{default:n(()=>[P(_(t.$t("views.system.authentication.oidc.enableAuthentication")),1)]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["rules","model"]),V("div",null,[q((p(),E(S,{onClick:o[10]||(o[10]=e=>U(v.value)),type:"primary",disabled:m.value},{default:n(()=>[P(_(t.$t("common.save")),1)]),_:1},8,["disabled"])),[[g,new(k(J))([k(z).ADMIN],[k(H).LOGIN_AUTH_EDIT],[],"OR")]])])])),[[h,m.value]])]),_:1})])}}}),oe="/platform",Ne=A=>pe(`${oe}/source`,void 0,A),Oe=(A,a)=>ge(`${oe}/source`,A,void 0,a),Fe=(A,a)=>me(`${oe}/source`,A,void 0,a),j={getPlatformInfo:Ne,updateConfig:Oe,validateConnection:Fe},Qe={class:"flex align-center",style:{"margin-left":"-8px"}},Le={class:"dialog-footer"},Be=L({__name:"EditModal",emits:["refresh"],setup(A,{expose:a,emit:v}){const m=$(!1),f=$(!1),U=$(),i=B({key:"",logoSrc:"",name:"",isActive:!1,isValid:!1,config:{}}),t=e=>({corp_id:"Corp ID",app_key:(i==null?void 0:i.key)!="lark"?"APP Key":"App ID",app_secret:"APP Secret",agent_id:"Agent ID",callback_url:s("views.application.applicationAccess.callback")})[e]||(e?e.charAt(0).toUpperCase()+e.slice(1):""),o=e=>{switch(e){case"app_key":return[{required:!0,message:s("views.system.authentication.scanTheQRCode.appKeyPlaceholder"),trigger:["blur","change"]}];case"app_secret":return[{required:!0,message:s("views.system.authentication.scanTheQRCode.appSecretPlaceholder"),trigger:["blur","change"]}];case"corp_id":return[{required:!0,message:s("views.system.authentication.scanTheQRCode.corpIdPlaceholder"),trigger:["blur","change"]}];case"agent_id":return[{required:!0,message:s("views.system.authentication.scanTheQRCode.agentIdPlaceholder"),trigger:["blur","change"]}];case"callback_url":return[{required:!0,message:s("views.application.applicationAccess.callbackTip"),trigger:["blur","change"]},{pattern:/^https?:\/\/.+/,message:s("views.system.authentication.scanTheQRCode.callbackWarning"),trigger:["blur","change"]}];default:return[]}};a({open:async e=>{var Q;m.value=!0,f.value=!0,Object.assign(i,e);const C=window.location.origin+window.MaxKB.prefix;switch(e.key){case"wecom":i.config.app_key&&(i.config.agent_id=i.config.app_key,delete i.config.app_key),i.config.callback_url=`${C}/api/wecom`;break;case"dingtalk":i.config.agent_id&&(i.config.corp_id=i.config.agent_id,delete i.config.agent_id),i.config={corp_id:i.config.corp_id,app_key:i.config.app_key,app_secret:i.config.app_secret,callback_url:C},i.config.callback_url=`${C}/api/dingtalk`;break;case"lark":i.config.callback_url=`${C}/api/lark`;break}(Q=U.value)==null||Q.clearValidate()}});const d=()=>{var e;(e=U.value)==null||e.validate(C=>{C?h():ae(s("views.system.authentication.scanTheQRCode.validateFailedTip"))})},w=()=>{var e;m.value=!1,(e=U.value)==null||e.clearValidate(),g("refresh")};function I(){j.validateConnection(i,f).then(e=>{e.data?O(s("views.system.authentication.scanTheQRCode.validateSuccess")):ae(s("views.system.authentication.scanTheQRCode.validateFailed"))})}const S=new Set(["app_secret","client_secret","secret"]),u=e=>S.has(e),g=v;function h(){j.updateConfig(i,f).then(e=>{var C;O(s("common.saveSuccess")),g("refresh"),m.value=!1,(C=U.value)==null||C.clearValidate()})}return(e,C)=>{const Q=r("el-input"),Y=r("el-form-item"),K=r("el-button"),x=r("el-drawer");return p(),E(x,{modelValue:m.value,"onUpdate:modelValue":C[0]||(C[0]=Z=>m.value=Z),size:"60%","append-to-body":!0,"destroy-on-close":!0,onClose:w},{header:n(()=>[V("div",Qe,[V("h4",null,_(i.name+e.$t("views.system.authentication.scanTheQRCode.setting")),1)])]),footer:n(()=>[V("span",Le,[l(K,{onClick:w},{default:n(()=>[P(_(e.$t("common.cancel")),1)]),_:1}),l(K,{onClick:I},{default:n(()=>[P(_(e.$t("views.system.authentication.scanTheQRCode.validate")),1)]),_:1}),l(K,{type:"primary",onClick:d},{default:n(()=>[P(_(e.$t("common.save")),1)]),_:1})])]),default:n(()=>[l(k(fe),{model:i.config,"label-width":"120px","label-position":"top","require-asterisk-position":"right",ref_key:"formRef",ref:U},{default:n(()=>[(p(!0),b(W,null,X(i.config,(Z,M)=>(p(),E(Y,{key:M,label:t(M),prop:M,rules:o(M)},{default:n(()=>[l(Q,{modelValue:i.config[M],"onUpdate:modelValue":ee=>i.config[M]=ee,type:u(M)?"password":"text","show-password":u(M)},null,8,["modelValue","onUpdate:modelValue","type","show-password"])]),_:2},1032,["label","prop","rules"]))),128))]),_:1},8,["model"])]),_:1},8,["modelValue"])}}}),Ge={class:"scan-height"},Je={class:"flex-between"},ze={class:"flex align-center"},He=["src"],Ke={class:"ml-8"},je={key:1},We={class:"mr-4"},Xe={key:0,class:"border-t mt-16"},Ye={class:"mt-4 mb-16 flex align-center"},Ze={key:0,class:"vertical-middle lighter break-all ellipsis-1"},xe={key:1,class:"vertical-middle lighter break-all ellipsis-1"},et={key:2,class:"vertical-middle lighter break-all ellipsis-1"},tt={class:"ml-4"},at=L({__name:"SCAN",setup(A){const a=$(),v=$(!1),m=B(U()),f=B({});G(()=>{o()});function U(){return[i("wecom",s("views.system.authentication.scanTheQRCode.wecom")),i("dingtalk",s("views.system.authentication.scanTheQRCode.dingtalk")),i("lark",s("views.system.authentication.scanTheQRCode.lark"))]}function i(u,g){let h="";switch(u){case"wecom":h="wechat-work";break;case"dingtalk":h="dingtalk";break;case"lark":h="lark";break;default:h="";break}const e={...u==="wecom"?{corp_id:"",agent_id:""}:{app_key:""},app_secret:"",callback_url:""};return{key:u,logoSrc:new URL(Object.assign({"../../../../assets/logo/logo_dingtalk.svg":Pe,"../../../../assets/logo/logo_lark.svg":Ue,"../../../../assets/logo/logo_slack.svg":ke,"../../../../assets/logo/logo_wechat-bot.svg":$e,"../../../../assets/logo/logo_wechat-work.svg":Ve,"../../../../assets/logo/logo_wechat.svg":ye})[`../../../../assets/logo/logo_${h}.svg`],import.meta.url).href,name:g,isActive:!1,isValid:!1,config:e}}function t(u,g){return{corp_id:"Corp ID",app_key:(g==null?void 0:g.key)!="lark"?"APP Key":"App ID",app_secret:"APP Secret",agent_id:"Agent ID",callback_url:s("views.application.applicationAccess.callback")}[u]||(u?u.charAt(0).toUpperCase()+u.slice(1):"")}function o(){v.value=!0,j.getPlatformInfo(v).then(u=>{u&&m.forEach(g=>{const h=u.data.find(e=>e.auth_type===g.key);if(h){if(Object.assign(g,{isValid:h.is_valid,isActive:h.is_active,config:h.config}),g.key==="dingtalk"){const{corp_id:e,app_key:C,app_secret:Q}=g.config;g.config={corp_id:e,app_key:C,app_secret:Q,callback_url:g.config.callback_url}}f[g.key]={},f[g.key].app_secret=!1}})})}function c(u){j.validateConnection(u,v).then(g=>{g.data?O(s("views.system.authentication.scanTheQRCode.validateSuccess")):ae(s("views.system.authentication.scanTheQRCode.validateFailed"))})}function d(){o()}function w(u){j.updateConfig(u,v).then(g=>{O(s("common.saveSuccess"))})}function I(u){f[u]||(f[u]={}),f[u].app_secret=!f[u].app_secret}function S(u){var g;(g=a.value)==null||g.open(u)}return(u,g)=>{const h=r("el-tag"),e=r("el-button"),C=r("el-switch"),Q=r("el-text"),Y=r("AppIcon"),K=r("View"),x=r("el-icon"),Z=r("el-col"),M=r("el-row"),ee=r("el-collapse-transition"),re=r("el-card"),de=r("el-scrollbar"),ce=T("hasPermission"),ue=T("loading");return q((p(),b("div",Ge,[l(de,null,{default:n(()=>[(p(!0),b(W,null,X(m,y=>(p(),b("div",{key:y.key,class:"mb-16"},[l(re,{class:"border-none mb-16",shadow:"none"},{default:n(()=>[V("div",Je,[V("div",ze,[V("img",{src:y.logoSrc,alt:"",width:"24px"},null,8,He),V("h5",Ke,_(y.name),1),y.isValid?(p(),E(h,{key:0,type:"success",class:"ml-8"},{default:n(()=>[P(_(u.$t("views.system.authentication.scanTheQRCode.effective")),1)]),_:1})):N("",!0)]),V("div",null,[y.isValid?N("",!0):q((p(),E(e,{key:0,type:"primary",onClick:F=>S(y)},{default:n(()=>[P(_(u.$t("views.system.authentication.scanTheQRCode.access")),1)]),_:1},8,["onClick"])),[[ce,new(k(J))([k(z).ADMIN],[k(H).LOGIN_AUTH_EDIT],[],"OR")]]),y.isValid?(p(),b("span",je,[V("span",We,_(y.isActive?u.$t("views.system.authentication.scanTheQRCode.alreadyTurnedOn"):u.$t("views.system.authentication.scanTheQRCode.notEnabled")),1),l(C,{size:"small",modelValue:y.isActive,"onUpdate:modelValue":F=>y.isActive=F,disabled:!y.isValid,onChange:F=>w(y)},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])])):N("",!0)])]),l(ee,null,{default:n(()=>[y.isValid?(p(),b("div",Xe,[l(M,{gutter:12,class:"mt-16"},{default:n(()=>[(p(!0),b(W,null,X(y.config,(F,R)=>(p(),E(Z,{key:R,span:12},{default:n(()=>{var ne,ie;return[l(Q,{class:"color-secondary lighter"},{default:n(()=>[P(_(t(R,y)),1)]),_:2},1024),V("div",Ye,[R!=="app_secret"?(p(),b("span",Ze,_(F),1)):N("",!0),R==="app_secret"&&!((ne=f[y.key])!=null&&ne[R])?(p(),b("span",xe,"************")):N("",!0),R==="app_secret"&&((ie=f[y.key])!=null&&ie[R])?(p(),b("span",et,_(F),1)):N("",!0),V("span",null,[l(e,{type:"primary",text:"",onClick:()=>k(_e)(F)},{default:n(()=>[l(Y,{iconName:"app-copy"})]),_:1},8,["onClick"])]),V("span",tt,[R==="app_secret"?(p(),E(e,{key:0,type:"primary",text:"",onClick:te=>I(y.key)},{default:n(()=>{var te,se;return[R==="app_secret"&&!((te=f[y.key])!=null&&te[R])?(p(),E(Y,{key:0,iconName:"app-password-hide"})):N("",!0),R==="app_secret"&&((se=f[y.key])!=null&&se[R])?(p(),E(x,{key:1},{default:n(()=>[l(K)]),_:1})):N("",!0)]}),_:2},1032,["onClick"])):N("",!0)])])]}),_:2},1024))),128))]),_:2},1024),l(e,{type:"primary",onClick:F=>S(y)},{default:n(()=>[P(_(u.$t("common.edit")),1)]),_:1},8,["onClick"]),l(e,{onClick:F=>c(y)},{default:n(()=>[P(_(u.$t("views.system.authentication.scanTheQRCode.validate")),1)]),_:1},8,["onClick"])])):N("",!0)]),_:2},1024)]),_:2},1024)]))),128)),l(Be,{ref_key:"EditModelRef",ref:a,onRefresh:d},null,512)]),_:1})])),[[ue,v.value]])}}}),lt=le(at,[["__scopeId","data-v-2c9dd73e"]]),ot={class:"authentication-setting__main main-calc-height"},nt={class:"form-container p-24"},it=L({__name:"OAuth2",setup(A){const a=$({id:"",auth_type:"OAuth2",config:{authEndpoint:"",tokenEndpoint:"",userInfoEndpoint:"",scope:"",clientId:"",clientSecret:"",redirectUrl:"",fieldMapping:""},is_active:!0}),v=$(),m=$(!1),f=B({"config.authEndpoint":[{required:!0,message:s("views.system.authentication.oauth2.authEndpointPlaceholder"),trigger:"blur"}],"config.tokenEndpoint":[{required:!0,message:s("views.system.authentication.oauth2.tokenEndpointPlaceholder"),trigger:"blur"}],"config.userInfoEndpoint":[{required:!0,message:s("views.system.authentication.oauth2.userInfoEndpointPlaceholder"),trigger:"blur"}],"config.scope":[{required:!0,message:s("views.system.authentication.oauth2.scopePlaceholder"),trigger:"blur"}],"config.clientId":[{required:!0,message:s("views.system.authentication.oauth2.clientIdPlaceholder"),trigger:"blur"}],"config.clientSecret":[{required:!0,message:s("views.system.authentication.oauth2.clientSecretPlaceholder"),trigger:"blur"}],"config.redirectUrl":[{required:!0,message:s("views.system.authentication.oauth2.redirectUrlPlaceholder"),trigger:"blur"}],"config.fieldMapping":[{required:!0,message:s("views.system.authentication.oauth2.filedMappingPlaceholder"),trigger:"blur"}]}),U=async(t,o)=>{t&&await t.validate((c,d)=>{c&&D.putAuthSetting(a.value.auth_type,a.value,m).then(w=>{O(s("common.saveSuccess"))})})};function i(){D.getAuthSetting(a.value.auth_type,m).then(t=>{t.data&&JSON.stringify(t.data)!=="{}"&&(a.value=t.data),a.value.config.redirectUrl||(a.value.config.redirectUrl=window.location.origin+window.MaxKB.prefix+"/api/oauth2")})}return G(()=>{i()}),(t,o)=>{const c=r("el-input"),d=r("el-form-item"),w=r("el-checkbox"),I=r("el-form"),S=r("el-button"),u=r("el-scrollbar"),g=T("hasPermission"),h=T("loading");return p(),b("div",ot,[l(u,null,{default:n(()=>[q((p(),b("div",nt,[l(I,{ref_key:"authFormRef",ref:v,rules:f,model:a.value,"label-position":"top","require-asterisk-position":"right"},{default:n(()=>[l(d,{label:t.$t("views.system.authentication.oauth2.authEndpoint"),prop:"config.authEndpoint"},{default:n(()=>[l(c,{modelValue:a.value.config.authEndpoint,"onUpdate:modelValue":o[0]||(o[0]=e=>a.value.config.authEndpoint=e),placeholder:t.$t("views.system.authentication.oauth2.authEndpointPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oauth2.tokenEndpoint"),prop:"config.tokenEndpoint"},{default:n(()=>[l(c,{modelValue:a.value.config.tokenEndpoint,"onUpdate:modelValue":o[1]||(o[1]=e=>a.value.config.tokenEndpoint=e),placeholder:t.$t("views.system.authentication.oauth2.tokenEndpointPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oauth2.userInfoEndpoint"),prop:"config.userInfoEndpoint"},{default:n(()=>[l(c,{modelValue:a.value.config.userInfoEndpoint,"onUpdate:modelValue":o[2]||(o[2]=e=>a.value.config.userInfoEndpoint=e),placeholder:t.$t("views.system.authentication.oauth2.userInfoEndpointPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oauth2.scope"),prop:"config.scope"},{default:n(()=>[l(c,{modelValue:a.value.config.scope,"onUpdate:modelValue":o[3]||(o[3]=e=>a.value.config.scope=e),placeholder:t.$t("views.system.authentication.oauth2.scopePlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oauth2.clientId"),prop:"config.clientId"},{default:n(()=>[l(c,{modelValue:a.value.config.clientId,"onUpdate:modelValue":o[4]||(o[4]=e=>a.value.config.clientId=e),placeholder:t.$t("views.system.authentication.oauth2.clientIdPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oauth2.clientSecret"),prop:"config.clientSecret"},{default:n(()=>[l(c,{modelValue:a.value.config.clientSecret,"onUpdate:modelValue":o[5]||(o[5]=e=>a.value.config.clientSecret=e),placeholder:t.$t("views.system.authentication.oauth2.clientSecretPlaceholder"),"show-password":""},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oauth2.filedMapping"),prop:"config.fieldMapping"},{default:n(()=>[l(c,{modelValue:a.value.config.fieldMapping,"onUpdate:modelValue":o[6]||(o[6]=e=>a.value.config.fieldMapping=e),placeholder:t.$t("views.system.authentication.oauth2.filedMappingPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:t.$t("views.system.authentication.oauth2.redirectUrl"),prop:"config.redirectUrl"},{default:n(()=>[l(c,{modelValue:a.value.config.redirectUrl,"onUpdate:modelValue":o[7]||(o[7]=e=>a.value.config.redirectUrl=e),placeholder:t.$t("views.system.authentication.oauth2.redirectUrlPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,null,{default:n(()=>[l(w,{modelValue:a.value.is_active,"onUpdate:modelValue":o[8]||(o[8]=e=>a.value.is_active=e)},{default:n(()=>[P(_(t.$t("views.system.authentication.oauth2.enableAuthentication")),1)]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["rules","model"]),V("div",null,[q((p(),E(S,{onClick:o[9]||(o[9]=e=>U(v.value)),type:"primary",disabled:m.value},{default:n(()=>[P(_(t.$t("common.save")),1)]),_:1},8,["disabled"])),[[g,new(k(J))([k(z).ADMIN],[k(H).LOGIN_AUTH_EDIT],[],"OR")]])])])),[[h,m.value]])]),_:1})])}}}),st={class:"authentication-setting__main main-calc-height"},rt={class:"form-container p-24"},dt={style:{"font-size":"13px"}},ct={style:{"margin-left":"8px","font-size":"13px"}},ut={style:{"margin-left":"8px",color:"#909399","font-size":"12px"}},pt={style:{"margin-top":"16px"}},mt={class:"mr-12"},gt=L({__name:"Setting",setup(A){const a=$([]),v=$(!1),m=$(),f=$({default_value:"LOCAL",max_attempts:1}),U=async i=>{i&&await i.validate((t,o)=>{if(t){const c={default_value:f.value.default_value,max_attempts:f.value.max_attempts};D.putLoginSetting(c,v).then(d=>{O(s("common.saveSuccess"))})}else console.log("error submit!",o)})};return G(()=>{D.getLoginSetting().then(i=>{Object.keys(i.data).length>0&&(f.value=i.data,a.value=i.data.auth_types)})}),(i,t)=>{const o=r("el-radio"),c=r("el-radio-group"),d=r("el-form-item"),w=r("el-input-number"),I=r("el-form"),S=r("el-button"),u=r("el-scrollbar"),g=T("hasPermission"),h=T("loading");return p(),b("div",st,[l(u,null,{default:n(()=>[q((p(),b("div",rt,[l(I,{ref_key:"authFormRef",ref:m,model:f.value,"label-position":"top","require-asterisk-position":"right",onSubmit:t[2]||(t[2]=ve(()=>{},["prevent"]))},{default:n(()=>[l(d,{label:i.$t("views.system.default_login"),rules:[{required:!0,message:i.$t("views.applicationOverview.appInfo.LimitDialog.loginMethodRequired"),trigger:"change"}],prop:"default_value",style:{"padding-top":"16px"}},{default:n(()=>[l(c,{modelValue:f.value.default_value,"onUpdate:modelValue":t[0]||(t[0]=e=>f.value.default_value=e),class:"radio-group"},{default:n(()=>[(p(!0),b(W,null,X(a.value,e=>(p(),E(o,{key:e.value,label:e.value,class:"radio-item"},{default:n(()=>[P(_(e.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label","rules"]),l(d,{label:i.$t("views.system.display_code"),rules:[{required:!0,message:i.$t("views.applicationOverview.appInfo.LimitDialog.displayCodeRequired"),trigger:"change"}],prop:"max_attempts"},{default:n(()=>[V("span",dt,_(i.$t("views.system.loginFailed")),1),l(w,{style:{"margin-left":"8px"},modelValue:f.value.max_attempts,"onUpdate:modelValue":t[1]||(t[1]=e=>f.value.max_attempts=e),min:-1,max:10,step:1,"controls-position":"right"},null,8,["modelValue"]),V("span",ct,_(i.$t("views.system.loginFailedMessage")),1),V("span",ut," ("+_(i.$t("views.system.display_codeTip"))+") ",1)]),_:1},8,["label","rules"])]),_:1},8,["model"]),V("div",pt,[q((p(),b("span",mt,[l(S,{onClick:t[3]||(t[3]=e=>U(m.value)),type:"primary",disabled:v.value},{default:n(()=>[P(_(i.$t("common.save")),1)]),_:1},8,["disabled"])])),[[g,new(k(J))([k(z).ADMIN],[k(H).LOGIN_AUTH_EDIT],[],"OR")]])])])),[[h,v.value]])]),_:1})])}}}),ft=le(gt,[["__scopeId","data-v-4e20e438"]]),_t={class:"authentication-setting p-16-24"},vt={class:"ml-4 color-text-primary"},ht=L({__name:"index",setup(A){const{user:a}=he(),v=be(),m=$("SETTING"),f=[{label:s("views.system.setting"),name:"SETTING",component:ft},{label:s("views.system.authentication.ldap.title"),name:"LDAP",component:Ae},{label:s("views.system.authentication.cas.title"),name:"CAS",component:Te},{label:s("views.system.authentication.oidc.title"),name:"OIDC",component:Me},{label:s("views.system.authentication.oauth2.title"),name:"OAuth2",component:it},{label:s("views.system.authentication.scanTheQRCode.title"),name:"SCAN",component:lt}];return G(()=>{a.isExpire()&&v.push({path:"/application"})}),(U,i)=>{const t=r("el-breadcrumb-item"),o=r("el-breadcrumb"),c=r("el-tab-pane"),d=r("el-tabs");return p(),b("div",_t,[l(o,{"separator-icon":"ArrowRight",class:"mb-16"},{default:n(()=>[l(t,null,{default:n(()=>[P(_(k(s)("views.system.subTitle")),1)]),_:1}),l(t,null,{default:n(()=>[V("h5",vt,_(U.$t("views.system.authentication.title")),1)]),_:1})]),_:1}),l(d,{modelValue:m.value,"onUpdate:modelValue":i[0]||(i[0]=w=>m.value=w),class:"mt-4"},{default:n(()=>[(p(),b(W,null,X(f,(w,I)=>l(c,{key:I,label:w.label,name:w.name},{default:n(()=>[(p(),E(we(w.component)))]),_:2},1032,["label","name"])),64))]),_:1},8,["modelValue"])])}}}),Vt=le(ht,[["__scopeId","data-v-edee15cc"]]);export{Vt as default};