"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8741],{37725:(_,E,s)=>{s.r(E),s.d(E,{AuthConfigPageUnconnected:()=>S,default:()=>Y});var d=s(42844),I=s(89949),e=s(27702),T=s(27173),P=s(86312),h=s(66310),A=s(44644),F=s(74639),z=s(66670),j=s(60801);const H=({title:t,buttonIcon:n,buttonLink:a,buttonTitle:r,buttonDisabled:c,description:i,onClick:f})=>{const g=(0,h.wW)(k),l=i?e.createElement("span",{key:"proTipFooter"},i):"",C=i?"":g.button,v=e.createElement(z.Qj,{size:"lg",href:a,icon:n,className:C,"data-testid":F.wl.components.CallToActionCard.buttonV2(r),disabled:c,onClick:()=>f&&f()},r);return e.createElement(j._,{className:g.cta,message:t,footer:l,callToActionElement:v})},k=t=>({cta:(0,d.css)`
      text-align: center;
    `,button:(0,d.css)`
      margin-bottom: ${t.spacing(2.5)};
    `}),w=H;var x=s(50230),B=s(80011),U=s(73453),y=s(25357);const b="admin/authentication/",tt="48px";function N({providerId:t,displayName:n,enabled:a,configFoundInIniFile:r,configPath:c,authType:i,badges:f,onClick:g}){const l=(0,h.wW)(W);return c=b+(c||t),e.createElement(x.Z,{href:c,className:l.container,onClick:()=>g&&g()},e.createElement(x.Z.Heading,{className:l.name},n),r&&e.createElement(e.Fragment,null,e.createElement("span",{className:l.initext},e.createElement(B.u,{content:"Note: Settings enabled in the .ini configuration file will overwritten by the current settings."},e.createElement(e.Fragment,null,e.createElement(U.J,{name:"adjust-circle"}),"Configuration found in .ini file")))),e.createElement("div",{className:l.footer},i&&e.createElement(y.C,{text:i,color:"blue",icon:"info-circle"}),a?e.createElement(y.C,{text:"Enabled",color:"green",icon:"check"}):e.createElement(y.C,{text:"Not enabled",color:"red"})))}const W=t=>({container:(0,d.css)`
      min-height: ${t.spacing(16)};
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      padding: ${t.spacing(2)};
    `,header:(0,d.css)`
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: ${t.spacing(2)};
    `,footer:(0,d.css)`
      display: flex;
      justify-content: space-between;
    `,name:(0,d.css)`
      align-self: flex-start;
      font-size: ${t.typography.h4.fontSize};
      color: ${t.colors.text.primary};
      margin: 0;
    `,initext:(0,d.css)`
      font-size: ${t.typography.bodySmall.fontSize};
      color: ${t.colors.text.secondary};
      padding: ${t.spacing(1)} 0; // Add some padding
      max-width: 90%; // Add a max-width to prevent text from stretching too wide
    `});var L=s(73289),V=s(66574),O=s(18771);const u=[],p={};function et(t,n){u.find(a=>a.id===t.id)||(u.push(t),n&&(p[t.id]=n))}function $(){return u}function nt(t){return u.find(n=>n.id===t)}function ot(t){const n=[];for(const[a,r]of Object.entries(t)){const c=u.find(i=>`auth.${i.id}`===a);if(c){const i={...r,providerId:c.id,displayName:r.name||c.displayName};n.push(i)}}return n}async function Z(t){if(p[t]){const n=p[t];return n()}return{configured:!1,enabled:!1}}var m=s(4242);function D(){return async t=>{if(V.Vt.hasPermission(O.AccessControlAction.SettingsRead)){t((0,m.uX)());const n=await(0,L.i)().get("/api/admin/settings");return t((0,m.AW)(n)),await t(G()),t((0,m._E)()),n}}}function G(){return async t=>{const n=$(),a={},r=[];for(const i of n)r.push(Z(i.id));const c=await Promise.all(r);for(let i=0;i<n.length;i++){const f=n[i],g=c[i];a[f.id]=g}t((0,m.AB)(a))}}function at(t){return async n=>{if(contextSrv.hasPermission(AccessControlAction.SettingsWrite))try{return await lastValueFrom(getBackendSrv().fetch({url:"/api/admin/settings",method:"PUT",data:t,showSuccessAlert:!1,showErrorAlert:!1})),n(resetError()),!0}catch(a){if(console.log(a),isFetchError(a)){a.isHandled=!0;const r={message:a.data?.message,errors:a.data?.errors};return n(setError(r)),!1}}return!1}}function R(t){return b+(t.configPath||t.id)}function J(t){const{isLoading:n,providerStatuses:a}=t.authConfig;return{isLoading:n,providerStatuses:a}}const M={loadSettings:D},Q=(0,T.connect)(J,M),S=({providerStatuses:t,isLoading:n,loadSettings:a})=>{const r=(0,h.wW)(X);(0,e.useEffect)(()=>{a()},[a]);const c=$(),i=c.filter(o=>t[o.id]?.enabled),f=c.filter(o=>t[o.id]?.configured&&!t[o.id]?.enabled),g=c.filter(o=>!t[o.id]?.enabled&&!t[o.id]?.configured&&!t[o.id]?.hide),l=g?.length?g[0]:null,C=e.createElement("a",{className:"external-link",href:"https://grafana.com/docs/grafana/next/setup-grafana/configure-security/configure-authentication/saml-ui/",target:"_blank",rel:"noopener noreferrer"},"documentation."),v=e.createElement("span",null,"Manage your auth settings and configure single sign-on. Find out more in our ",C),K=()=>{(0,P.ff)("authentication_ui_created",{provider:l?.type})},q=o=>{(0,P.ff)("authentication_ui_provider_clicked",{provider:o.type})};return e.createElement(A.T,{navId:"authentication",subTitle:v},e.createElement(A.T.Contents,{isLoading:n},e.createElement("h3",{className:r.sectionHeader},"Configured authentication"),!!i?.length&&e.createElement("div",{className:r.cardsContainer},i.map(o=>e.createElement(N,{key:o.id,providerId:o.id,displayName:o.displayName,authType:o.type,enabled:t[o.id]?.enabled,configFoundInIniFile:t[o.id]?.configFoundInIniFile,configPath:o.configPath,onClick:()=>{q(o)}}))),!i?.length&&l&&!(0,I.isEmpty)(t)&&e.createElement(w,{title:`You have no ${l.type} configuration created at the moment`,buttonIcon:"plus-circle",buttonLink:R(l),buttonTitle:`Configure ${l.type}`,description:`Important: if you have ${l.type} configuration enabled via the .ini file Grafana is using it.
              Configuring ${l.type} via UI will take precedence over any configuration in the .ini file.
              No changes will be written into .ini file.`,onClick:K}),!!f?.length&&e.createElement("div",{className:r.cardsContainer},f.map(o=>e.createElement(N,{key:o.id,providerId:o.id,displayName:o.displayName,authType:o.protocol,enabled:t[o.id]?.enabled,configFoundInIniFile:t[o.id]?.configFoundInIniFile,configPath:o.configPath})))))},X=t=>({cardsContainer:(0,d.css)`
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
      gap: ${t.spacing(3)};
      margin-bottom: ${t.spacing(3)};
      margin-top: ${t.spacing(2)};
    `,sectionHeader:(0,d.css)`
      margin-bottom: ${t.spacing(3)};
    `,settingsSection:(0,d.css)`
      margin-top: ${t.spacing(4)};
    `,settingName:(0,d.css)`
      padding-left: 25px;
    `,doclink:(0,d.css)`
      padding-bottom: 5px;
      padding-top: -5px;
      font-size: ${t.typography.bodySmall.fontSize};
      a {
        color: ${t.colors.info.name}; // use theme link color or any other color
        text-decoration: underline; // underline or none, as you prefer
      }
    `,settingValue:(0,d.css)`
      white-space: break-spaces;
    `}),Y=Q(S)}}]);

//# sourceMappingURL=AdminAuthentication.b323105cfdd86a8811ae.js.map