| 1 |
- import{dd as le,fI as oe,fD as ne,cQ as B,fL as O,gs as i,fr as H,fV as s,fW as N,ft as p,cs as w,cw as l,g$ as n,h0 as Q,cv as U,gx as _,cp as k,gN as C,e as X,O as G,B as Y,fM as $,y as F,cq as R,k as de,F as j,fS as W,x as ee,cr as D,ch as ue,ac as ie,fX as pe}from"./builder-DygomDiV.js";import{e as me,d as fe,c as ge,b as he,a as ve,_ as _e}from"./logo_wechat-CQWIwUnm.js";const te="/chat_user/auth",be=(y,e)=>le(`${te}/${y}/detail`,void 0,e),we=(y,e)=>ne(`${te}/connection`,y,void 0,e),ye=(y,e,h)=>oe(`${te}/${y}/info`,e,void 0,h),ae="/chat_user/auth/platform",Ve=y=>le(`${ae}/source`,void 0,y),ke=(y,e)=>ne(`${ae}/source`,y,void 0,e),$e=(y,e)=>oe(`${ae}/source`,y,void 0,e),S={getAuthSetting:be,postAuthSetting:we,putAuthSetting:ye,getPlatformInfo:Ve,updateConfig:ke,validateConnection:$e},Ue={class:"authentication-setting__main main-calc-height"},Pe={class:"form-container p-24"},Ce={class:"mr-12"},Se=B({__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),g=O({"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((d,r)=>{d&&(o?S.postAuthSetting(e.value,m).then(P=>{F(i("views.system.testSuccess"))}):S.putAuthSetting(e.value.auth_type,e.value,m).then(P=>{F(i("common.saveSuccess"))}))})};function u(){S.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 H(()=>{u()}),(t,o)=>{const d=s("el-input"),r=s("el-form-item"),P=s("el-checkbox"),q=s("el-form"),A=s("el-button"),c=s("el-scrollbar"),f=N("hasPermission"),v=N("loading");return p(),w("div",Ue,[l(c,null,{default:n(()=>[Q((p(),w("div",Pe,[l(q,{ref_key:"authFormRef",ref:h,rules:g,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(d,{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(d,{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(d,{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(d,{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(d,{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(d,{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(P,{modelValue:e.value.is_active,"onUpdate:modelValue":o[6]||(o[6]=a=>e.value.is_active=a)},{default:n(()=>[U(_(t.$t("views.system.authentication.ldap.enableAuthentication")),1)]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["rules","model"]),k("div",null,[Q((p(),w("span",Ce,[l(A,{onClick:o[7]||(o[7]=a=>V(h.value)),type:"primary",disabled:m.value},{default:n(()=>[U(_(t.$t("common.save")),1)]),_:1},8,["disabled"])])),[[f,new(C(X))([C(G).ADMIN],[C(Y).CHAT_USER_AUTH_EDIT],[],"OR")]]),k("span",null,[l(A,{onClick:o[8]||(o[8]=a=>V(h.value,"test")),disabled:m.value},{default:n(()=>[U(_(t.$t("views.system.test")),1)]),_:1},8,["disabled"])])])])),[[v,m.value]])]),_:1})])}}}),Ae={class:"authentication-setting__main main-calc-height"},Ee={class:"form-container p-24"},Ie=B({__name:"CAS",setup(y){const e=$({id:"",auth_type:"CAS",config:{ldpUri:"",validateUrl:"",redirectUrl:""},is_active:!0}),h=$(),m=$(!1),g=O({"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,d)=>{o&&S.putAuthSetting(e.value.auth_type,e.value,m).then(r=>{F(i("common.saveSuccess"))})})};function u(){S.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 H(()=>{u()}),(t,o)=>{const d=s("el-input"),r=s("el-form-item"),P=s("el-checkbox"),q=s("el-form"),A=s("el-button"),c=s("el-scrollbar"),f=N("hasPermission"),v=N("loading");return p(),w("div",Ae,[l(c,null,{default:n(()=>[Q((p(),w("div",Ee,[l(q,{ref_key:"authFormRef",ref:h,rules:g,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(d,{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(d,{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(d,{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(P,{modelValue:e.value.is_active,"onUpdate:modelValue":o[3]||(o[3]=a=>e.value.is_active=a)},{default:n(()=>[U(_(t.$t("views.system.authentication.cas.enableAuthentication")),1)]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["rules","model"]),k("div",null,[Q((p(),R(A,{onClick:o[4]||(o[4]=a=>V(h.value)),type:"primary",disabled:m.value},{default:n(()=>[U(_(t.$t("common.save")),1)]),_:1},8,["disabled"])),[[f,new(C(X))([C(G).ADMIN],[C(Y).CHAT_USER_AUTH_EDIT],[],"OR")]])])])),[[v,m.value]])]),_:1})])}}}),Re={class:"authentication-setting__main main-calc-height"},qe={class:"form-container p-24"},Te=B({__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),g=O({"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((d,r)=>{d&&S.putAuthSetting(e.value.auth_type,e.value,m).then(P=>{F(i("common.saveSuccess"))})})};function u(){S.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 H(()=>{u()}),(t,o)=>{const d=s("el-input"),r=s("el-form-item"),P=s("el-checkbox"),q=s("el-form"),A=s("el-button"),c=s("el-scrollbar"),f=N("hasPermission"),v=N("loading");return p(),w("div",Re,[l(c,null,{default:n(()=>[Q((p(),w("div",qe,[l(q,{ref_key:"authFormRef",ref:h,rules:g,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(d,{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(d,{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(d,{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(d,{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(d,{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(d,{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(d,{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(d,{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(d,{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(P,{modelValue:e.value.is_active,"onUpdate:modelValue":o[9]||(o[9]=a=>e.value.is_active=a)},{default:n(()=>[U(_(t.$t("views.system.authentication.oidc.enableAuthentication")),1)]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["rules","model"]),k("div",null,[Q((p(),R(A,{onClick:o[10]||(o[10]=a=>V(h.value)),type:"primary",disabled:m.value},{default:n(()=>[U(_(t.$t("common.save")),1)]),_:1},8,["disabled"])),[[f,new(C(X))([C(G).ADMIN],[C(Y).CHAT_USER_AUTH_EDIT],[],"OR")]])])])),[[v,m.value]])]),_:1})])}}}),De={class:"flex align-center",style:{"margin-left":"-8px"}},Me={class:"dialog-footer"},Ne=B({__name:"EditModal",emits:["refresh"],setup(y,{expose:e,emit:h}){const m=$(!1),g=$(!1),V=$(),u=O({key:"",logoSrc:"",name:"",isActive:!1,isValid:!1,config:{}}),t=a=>({corp_id:"Corp ID",app_key:u?.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=>{m.value=!0,g.value=!0,Object.assign(u,a);const E=window.location.origin+window.MaxKB.chatPrefix+"/api";switch(a.key){case"wecom":u.config.app_key&&(u.config.agent_id=u.config.app_key,delete u.config.app_key),u.config.callback_url=`${E}/auth/wecom`;break;case"dingtalk":u.config.agent_id&&(u.config.corp_id=u.config.agent_id,delete u.config.agent_id),u.config={corp_id:u.config.corp_id,app_key:u.config.app_key,app_secret:u.config.app_secret,callback_url:E},u.config.callback_url=`${E}/auth/dingtalk`;break;case"lark":u.config.callback_url=`${E}/auth/lark`;break}V.value?.clearValidate()}});const r=()=>{V.value?.validate(a=>{a?v():ee(i("views.system.authentication.scanTheQRCode.validateFailedTip"))})},P=()=>{m.value=!1,V.value?.clearValidate(),f("refresh")};function q(){S.validateConnection(u,g).then(a=>{a.data?F(i("views.system.authentication.scanTheQRCode.validateSuccess")):ee(i("views.system.authentication.scanTheQRCode.validateFailed"))})}const A=new Set(["app_secret","client_secret","secret"]),c=a=>A.has(a),f=h;function v(){S.updateConfig(u,g).then(a=>{F(i("common.saveSuccess")),f("refresh"),m.value=!1,V.value?.clearValidate()})}return(a,E)=>{const L=s("el-input"),z=s("el-form-item"),J=s("el-button"),Z=s("el-drawer");return p(),R(Z,{modelValue:m.value,"onUpdate:modelValue":E[0]||(E[0]=K=>m.value=K),size:"60%","append-to-body":!0,"destroy-on-close":!0,onClose:P},{header:n(()=>[k("div",De,[k("h4",null,_(u.name+a.$t("views.system.authentication.scanTheQRCode.setting")),1)])]),footer:n(()=>[k("span",Me,[l(J,{onClick:P},{default:n(()=>[U(_(a.$t("common.cancel")),1)]),_:1}),l(J,{onClick:q},{default:n(()=>[U(_(a.$t("views.system.authentication.scanTheQRCode.validate")),1)]),_:1}),l(J,{type:"primary",onClick:r},{default:n(()=>[U(_(a.$t("common.save")),1)]),_:1})])]),default:n(()=>[l(C(de),{model:u.config,"label-width":"120px","label-position":"top","require-asterisk-position":"right",ref_key:"formRef",ref:V},{default:n(()=>[(p(!0),w(j,null,W(u.config,(K,T)=>(p(),R(z,{key:T,label:t(T),prop:T,rules:o(T)},{default:n(()=>[l(L,{modelValue:u.config[T],"onUpdate:modelValue":x=>u.config[T]=x,type:c(T)?"password":"text","show-password":c(T)},null,8,["modelValue","onUpdate:modelValue","type","show-password"])]),_:2},1032,["label","prop","rules"]))),128))]),_:1},8,["model"])]),_:1},8,["modelValue"])}}}),Qe={class:"scan-height"},Fe={class:"flex-between"},Oe={class:"flex align-center"},Be=["src"],He={class:"ml-8"},Le={key:1},Je={class:"mr-4"},ze={key:0,class:"border-t mt-16"},Ke={class:"mt-4 mb-16 flex align-center"},je={key:0,class:"vertical-middle lighter break-all ellipsis-1"},We={key:1,class:"vertical-middle lighter break-all ellipsis-1"},Xe={key:2,class:"vertical-middle lighter break-all ellipsis-1"},Ge={class:"ml-4"},Ye=B({__name:"SCAN",setup(y){const e=$(),h=$(!1),m=O(V()),g=O({});H(()=>{o()});function V(){return[u("wecom",i("views.system.authentication.scanTheQRCode.wecom")),u("dingtalk",i("views.system.authentication.scanTheQRCode.dingtalk")),u("lark",i("views.system.authentication.scanTheQRCode.lark"))]}function u(c,f){let v="";switch(c){case"wecom":v="wechat-work";break;case"dingtalk":v="dingtalk";break;case"lark":v="lark";break;default:v="";break}const a={...c==="wecom"?{corp_id:"",agent_id:""}:{app_key:""},app_secret:"",callback_url:""};return{key:c,logoSrc:new URL(Object.assign({"../../../../assets/logo/logo_dingtalk.svg":_e,"../../../../assets/logo/logo_lark.svg":ve,"../../../../assets/logo/logo_slack.svg":he,"../../../../assets/logo/logo_wechat-bot.svg":ge,"../../../../assets/logo/logo_wechat-work.svg":fe,"../../../../assets/logo/logo_wechat.svg":me})[`../../../../assets/logo/logo_${v}.svg`],import.meta.url).href,name:f,isActive:!1,isValid:!1,config:a}}function t(c,f){return{corp_id:"Corp ID",app_key:f?.key!="lark"?"APP Key":"App ID",app_secret:"APP Secret",agent_id:"Agent ID",callback_url:i("views.application.applicationAccess.callback")}[c]||(c?c.charAt(0).toUpperCase()+c.slice(1):"")}function o(){h.value=!0,S.getPlatformInfo(h).then(c=>{c&&m.forEach(f=>{const v=c.data.find(a=>a.auth_type===f.key);if(v){if(Object.assign(f,{isValid:v.is_valid,isActive:v.is_active,config:v.config}),f.key==="dingtalk"){const{corp_id:a,app_key:E,app_secret:L}=f.config;f.config={corp_id:a,app_key:E,app_secret:L,callback_url:f.config.callback_url}}g[f.key]={},g[f.key].app_secret=!1}})})}function d(c){S.validateConnection(c,h).then(f=>{f.data?F(i("views.system.authentication.scanTheQRCode.validateSuccess")):ee(i("views.system.authentication.scanTheQRCode.validateFailed"))})}function r(){o()}function P(c){S.updateConfig(c,h).then(f=>{F(i("common.saveSuccess"))})}function q(c){g[c]||(g[c]={}),g[c].app_secret=!g[c].app_secret}function A(c){e.value?.open(c)}return(c,f)=>{const v=s("el-tag"),a=s("el-button"),E=s("el-switch"),L=s("el-text"),z=s("AppIcon"),J=s("View"),Z=s("el-icon"),K=s("el-col"),T=s("el-row"),x=s("el-collapse-transition"),se=s("el-card"),re=s("el-scrollbar"),ce=N("loading");return Q((p(),w("div",Qe,[l(re,null,{default:n(()=>[(p(!0),w(j,null,W(m,b=>(p(),w("div",{key:b.key,class:"mb-16"},[l(se,{class:"border-none mb-16",shadow:"never"},{default:n(()=>[k("div",Fe,[k("div",Oe,[k("img",{src:b.logoSrc,alt:"",width:"24px"},null,8,Be),k("h5",He,_(b.name),1),b.isValid?(p(),R(v,{key:0,size:"small",type:"success",class:"ml-8"},{default:n(()=>[U(_(c.$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=>A(b)},{default:n(()=>[U(_(c.$t("views.system.authentication.scanTheQRCode.access")),1)]),_:1},8,["onClick"])),b.isValid?(p(),w("span",Le,[k("span",Je,_(b.isActive?c.$t("views.system.authentication.scanTheQRCode.alreadyTurnedOn"):c.$t("views.system.authentication.scanTheQRCode.notEnabled")),1),l(E,{size:"small",modelValue:b.isActive,"onUpdate:modelValue":M=>b.isActive=M,disabled:!b.isValid,onChange:M=>P(b)},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])])):D("",!0)])]),l(x,null,{default:n(()=>[b.isValid?(p(),w("div",ze,[l(T,{gutter:12,class:"mt-16"},{default:n(()=>[(p(!0),w(j,null,W(b.config,(M,I)=>(p(),R(K,{key:I,span:12},{default:n(()=>[l(L,{class:"color-secondary lighter"},{default:n(()=>[U(_(t(I,b)),1)]),_:2},1024),k("div",Ke,[I!=="app_secret"?(p(),w("span",je,_(M),1)):D("",!0),I==="app_secret"&&!g[b.key]?.[I]?(p(),w("span",We,"************")):D("",!0),I==="app_secret"&&g[b.key]?.[I]?(p(),w("span",Xe,_(M),1)):D("",!0),k("span",null,[l(a,{type:"primary",text:"",onClick:()=>C(ue)(M)},{default:n(()=>[l(z,{iconName:"app-copy"})]),_:1},8,["onClick"])]),k("span",Ge,[I==="app_secret"?(p(),R(a,{key:0,type:"primary",text:"",onClick:nt=>q(b.key)},{default:n(()=>[I==="app_secret"&&!g[b.key]?.[I]?(p(),R(z,{key:0,iconName:"app-password-hide"})):D("",!0),I==="app_secret"&&g[b.key]?.[I]?(p(),R(Z,{key:1},{default:n(()=>[l(J)]),_:1})):D("",!0)]),_:2},1032,["onClick"])):D("",!0)])])]),_:2},1024))),128))]),_:2},1024),l(a,{type:"primary",onClick:M=>A(b)},{default:n(()=>[U(_(c.$t("common.edit")),1)]),_:1},8,["onClick"]),l(a,{onClick:M=>d(b)},{default:n(()=>[U(_(c.$t("views.system.authentication.scanTheQRCode.validate")),1)]),_:1},8,["onClick"])])):D("",!0)]),_:2},1024)]),_:2},1024)]))),128)),l(Ne,{ref_key:"EditModelRef",ref:e,onRefresh:r},null,512)]),_:1})])),[[ce,h.value]])}}}),Ze=ie(Ye,[["__scopeId","data-v-f37efc90"]]),xe={class:"authentication-setting__main main-calc-height"},et={class:"form-container p-24"},tt=B({__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),g=O({"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((d,r)=>{d&&S.putAuthSetting(e.value.auth_type,e.value,m).then(P=>{F(i("common.saveSuccess"))})})};function u(){S.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 H(()=>{u()}),(t,o)=>{const d=s("el-input"),r=s("el-form-item"),P=s("el-checkbox"),q=s("el-form"),A=s("el-button"),c=s("el-scrollbar"),f=N("hasPermission"),v=N("loading");return p(),w("div",xe,[l(c,null,{default:n(()=>[Q((p(),w("div",et,[l(q,{ref_key:"authFormRef",ref:h,rules:g,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(d,{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(d,{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(d,{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(d,{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(d,{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(d,{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(d,{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(d,{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(P,{modelValue:e.value.is_active,"onUpdate:modelValue":o[8]||(o[8]=a=>e.value.is_active=a)},{default:n(()=>[U(_(t.$t("views.system.authentication.oauth2.enableAuthentication")),1)]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["rules","model"]),k("div",null,[Q((p(),R(A,{onClick:o[9]||(o[9]=a=>V(h.value)),type:"primary",disabled:m.value},{default:n(()=>[U(_(t.$t("common.save")),1)]),_:1},8,["disabled"])),[[f,new(C(X))([C(G).ADMIN],[C(Y).CHAT_USER_AUTH_EDIT],[],"OR")]])])])),[[v,m.value]])]),_:1})])}}}),at={class:"authentication-setting p-16-24"},lt={class:"mb-16"},ot=B({__name:"index",setup(y){const e=$("LDAP"),h=[{label:i("views.system.authentication.ldap.title"),name:"LDAP",component:Se},{label:i("views.system.authentication.cas.title"),name:"CAS",component:Ie},{label:i("views.system.authentication.oidc.title"),name:"OIDC",component:Te},{label:i("views.system.authentication.oauth2.title"),name:"OAuth2",component:tt},{label:i("views.system.authentication.scanTheQRCode.title"),name:"SCAN",component:Ze}];return H(()=>{}),(m,g)=>{const V=s("el-tab-pane"),u=s("el-tabs");return p(),w("div",at,[k("h4",lt,_(m.$t("views.system.authentication.title")),1),l(u,{modelValue:e.value,"onUpdate:modelValue":g[0]||(g[0]=t=>e.value=t),class:"mt-4"},{default:n(()=>[(p(),w(j,null,W(h,(t,o)=>l(V,{key:o,label:t.label,name:t.name},{default:n(()=>[(p(),R(pe(t.component)))]),_:2},1032,["label","name"])),64))]),_:1},8,["modelValue"])])}}}),rt=ie(ot,[["__scopeId","data-v-229b756b"]]);export{rt as default};
|