UnisKB/static/admin/assets/index-FdvO2n1v.js

2 lines
29 KiB
JavaScript

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