"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8741],{88075:(Y,v,i)=>{i.r(v),i.d(v,{AuthConfigPageUnconnected:()=>N,default:()=>Q});var l=i(9892),$=i(82897),e=i(66111),S=i(67948),h=i(72648),C=i(8412),I=i(68183),T=i(31403),F=i(97097);const z=({title:t,buttonIcon:n,buttonLink:o,buttonTitle:r,buttonDisabled:c,description:s})=>{const g=(0,h.wW)(j),d=s?e.createElement("span",{key:"proTipFooter"},s):"",f=s?"":g.button,E=e.createElement(T.Qj,{size:"lg",href:o,icon:n,className:f,"data-testid":I.wl.components.CallToActionCard.buttonV2(r),disabled:c},r);return e.createElement(F._,{className:g.cta,message:t,footer:d,callToActionElement:E})},j=t=>({cta:l.css`
      text-align: center;
    `,button:l.css`
      margin-bottom: ${t.spacing(2.5)};
    `}),w=z;var P=i(72948),H=i(61860),B=i(39904),y=i(19985);const A="admin/authentication/",K="48px";function x({providerId:t,displayName:n,enabled:o,configFoundInIniFile:r,configPath:c,authType:s,badges:g}){const d=(0,h.wW)(U);return c=A+(c||t),e.createElement(P.Z,{href:c,className:d.container},e.createElement(P.Z.Heading,{className:d.name},n),r&&e.createElement(e.Fragment,null,e.createElement("span",{className:d.initext},e.createElement(H.u,{content:"Note: Settings enabled in the .ini configuration file will overwritten by the current settings."},e.createElement(e.Fragment,null,e.createElement(B.J,{name:"adjust-circle"}),"Configuration found in .ini file")))),e.createElement("div",{className:d.footer},s&&e.createElement(y.C,{text:s,color:"blue",icon:"info-circle"}),o?e.createElement(y.C,{text:"Enabled",color:"green",icon:"check"}):e.createElement(y.C,{text:"Not enabled",color:"red"})))}const U=t=>({container:l.css`
      min-height: ${t.spacing(16)};
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      padding: ${t.spacing(2)};
    `,header:l.css`
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: ${t.spacing(2)};
    `,footer:l.css`
      display: flex;
      justify-content: space-between;
    `,name:l.css`
      align-self: flex-start;
      font-size: ${t.typography.h4.fontSize};
      color: ${t.colors.text.primary};
      margin: 0;
    `,initext:l.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 W=i(54899),L=i(77582),V=i(27876);const u=[],p={};function q(t,n){u.find(o=>o.id===t.id)||(u.push(t),n&&(p[t.id]=n))}function b(){return u}function _(t){return u.find(n=>n.id===t)}function tt(t){const n=[];for(const[o,r]of Object.entries(t)){const c=u.find(s=>`auth.${s.id}`===o);if(c){const s={...r,providerId:c.id,displayName:r.name||c.displayName};n.push(s)}}return n}async function O(t){if(p[t]){const n=p[t];return n()}return{configured:!1,enabled:!1}}var m=i(85389);function Z(){return async t=>{if(L.Vt.hasPermission(V.AccessControlAction.SettingsRead)){t((0,m.uX)());const n=await(0,W.i)().get("/api/admin/settings");return t((0,m.AW)(n)),await t(D()),t((0,m._E)()),n}}}function D(){return async t=>{const n=b(),o={},r=[];for(const s of n)r.push(O(s.id));const c=await Promise.all(r);for(let s=0;s<n.length;s++){const g=n[s],d=c[s];o[g.id]=d}t((0,m.AB)(o))}}function et(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(o){if(console.log(o),isFetchError(o)){o.isHandled=!0;const r={message:o.data?.message,errors:o.data?.errors};return n(setError(r)),!1}}return!1}}function G(t){return A+(t.configPath||t.id)}function R(t){const{isLoading:n,providerStatuses:o}=t.authConfig;return{isLoading:n,providerStatuses:o}}const k={loadSettings:Z},J=(0,S.connect)(R,k),N=({providerStatuses:t,isLoading:n,loadSettings:o})=>{const r=(0,h.wW)(M);(0,e.useEffect)(()=>{o()},[o]);const c=b(),s=c.filter(a=>t[a.id]?.enabled),g=c.filter(a=>t[a.id]?.configured&&!t[a.id]?.enabled),d=c.filter(a=>!t[a.id]?.enabled&&!t[a.id]?.configured),f=d?.length?d[0]:null,E=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."),X=e.createElement("span",null,"Manage your auth settings and configure single sign-on. Find out more in our ",E);return e.createElement(C.T,{navId:"authentication",subTitle:X},e.createElement(C.T.Contents,{isLoading:n},e.createElement("h3",{className:r.sectionHeader},"Configured authentication"),!!s?.length&&e.createElement("div",{className:r.cardsContainer},s.map(a=>e.createElement(x,{key:a.id,providerId:a.id,displayName:a.displayName,authType:a.type,enabled:t[a.id]?.enabled,configFoundInIniFile:t[a.id]?.configFoundInIniFile,configPath:a.configPath}))),!s?.length&&f&&!(0,$.isEmpty)(t)&&e.createElement(w,{title:`You have no ${f.type} configuration created at the moment`,buttonIcon:"plus-circle",buttonLink:G(f),buttonTitle:`Configure ${f.type}`,description:`Important: if you have ${f.type} configuration enabled via the .ini file Grafana is using it.
              Configuring ${f.type} via UI will take precedence over any configuration in the .ini file.
              No changes will be written into .ini file.`}),!!g?.length&&e.createElement("div",{className:r.cardsContainer},g.map(a=>e.createElement(x,{key:a.id,providerId:a.id,displayName:a.displayName,authType:a.protocol,enabled:t[a.id]?.enabled,configFoundInIniFile:t[a.id]?.configFoundInIniFile,configPath:a.configPath})))))},M=t=>({cardsContainer:l.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:l.css`
      margin-bottom: ${t.spacing(3)};
    `,settingsSection:l.css`
      margin-top: ${t.spacing(4)};
    `,settingName:l.css`
      padding-left: 25px;
    `,doclink:l.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:l.css`
      white-space: break-spaces;
    `}),Q=J(N)}}]);

//# sourceMappingURL=AdminAuthentication.1905e67a2625280ee03f.js.map