1import{r as b,_ as q,a5 as V,aX as Q,a as K,a6 as P,j as e,B as x,aD as I,k as D,bt as g,m as O,C as U,e as E,b as W,d as Y,o as J,s as T,f as X,h as _,bp as H,E as Z,d3 as ee,au as se,ak as te,al as ae,am as re,an as ie,ao as ne,a_ as le,a$ as r,b0 as i,b1 as n,$ as oe,b2 as l,a0 as ce,a1 as de,a2 as xe,a3 as v,b3 as c,aF as m,ap as me,bj as S,b8 as a,U as he,bg as ue,aY as ge,bf as je,a7 as N}from"./index-CuSEeJFb.js";const pe=a.object({providerType:a.enum(["google","microsoft","saml"]),name:a.string().min(1,"Provider name is required"),clientId:a.string().optional(),clientSecret:a.string().optional(),tenantId:a.string().optional(),discoveryUrl:a.string().url().optional(),issuer:a.string().url().optional(),authorizationUrl:a.string().url().optional(),tokenUrl:a.string().url().optional(),userInfoUrl:a.string().url().optional(),entrypoint:a.string().url().optional(),certificate:a.string().optional(),scopes:a.string().optional(),isActive:a.boolean().default(!0),isPrimary:a.boolean().default(!1),autoCreateUsers:a.boolean().default(!0)});function fe(){const[d,j]=b.useState(null),[F,h]=b.useState(!1),[p,M]=b.useState({}),{toast:u}=q(),C=V(),t=Q({resolver:je(pe),defaultValues:{providerType:"google",isActive:!0,isPrimary:!1,autoCreateUsers:!0}}),{data:w=[],isLoading:$}=K({queryKey:["/api/sso/providers"]}),y=P({mutationFn:async s=>s.id?N(`/api/sso/providers/${s.id}`,{method:"PUT",body:JSON.stringify(s)}):N("/api/sso/providers",{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{u({title:d?"Provider Updated":"Provider Created",description:`SSO provider has been ${d?"updated":"created"} successfully.`}),C.invalidateQueries({queryKey:["/api/sso/providers"]}),h(!1),j(null),t.reset()},onError:s=>{u({title:"Error",description:s.message||"Failed to save SSO provider",variant:"destructive"})}}),f=P({mutationFn:async s=>N(`/api/sso/providers/${s}`,{method:"DELETE"}),onSuccess:()=>{u({title:"Provider Deleted",description:"SSO provider has been deleted successfully."}),C.invalidateQueries({queryKey:["/api/sso/providers"]})},onError:s=>{u({title:"Error",description:s.message||"Failed to delete SSO provider",variant:"destructive"})}}),z=s=>{y.mutate(d?{...s,id:d.id}:s)},B=s=>{j(s),t.reset({providerType:s.providerType,name:s.name,clientId:s.clientId||"",tenantId:s.tenantId||"",isActive:s.isActive,isPrimary:s.isPrimary,autoCreateUsers:s.autoCreateUsers}),h(!0)},A=()=>{j(null),t.reset({providerType:"google",isActive:!0,isPrimary:!1,autoCreateUsers:!0}),h(!0)},L=s=>{M(k=>({...k,[s]:!k[s]}))},R=s=>{switch(s){case"google":return e.jsx(ge,{className:"h-5 w-5 text-blue-500"});case"microsoft":return e.jsx(ue,{className:"h-5 w-5 text-orange-500"});case"saml":return e.jsx(g,{className:"h-5 w-5 text-purple-500"});default:return e.jsx(he,{className:"h-5 w-5 text-gray-500"})}},G=s=>{switch(s){case"google":return"Google Workspace";case"microsoft":return"Microsoft Azure AD";case"saml":return"SAML 2.0";default:return"Unknown Provider"}},o=t.watch("providerType");return $?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-orange-500"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:"Single Sign-On Settings"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:"Configure SSO providers to enable seamless authentication across your organization"})]}),e.jsxs(x,{onClick:A,className:"bg-orange-500 hover:bg-orange-600","data-testid":"button-add-sso",children:[e.jsx(I,{className:"h-4 w-4 mr-2"}),"Add SSO Provider"]})]}),e.jsxs(D,{children:[e.jsx(g,{className:"h-4 w-4"}),e.jsx(O,{children:"SSO is available for all subscription tiers. Configure providers to enable secure authentication for your team members. Users can sign in using their existing corporate accounts."})]}),e.jsx("div",{className:"grid gap-6",children:w.length===0?e.jsx(U,{"data-testid":"card-no-sso-providers",children:e.jsxs(E,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(g,{className:"h-12 w-12 text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"No SSO Providers Configured"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-center mb-6 max-w-md",children:"Set up Single Sign-On to enable secure authentication through Google Worksp
1ace, Microsoft Azure AD, or SAML providers."}),e.jsxs(x,{onClick:A,className:"bg-orange-500 hover:bg-orange-600","data-testid":"button-add-first-sso",children:[e.jsx(I,{className:"h-4 w-4 mr-2"}),"Add Your First SSO Provider"]})]})}):w.map(s=>e.jsxs(U,{className:"relative","data-testid":`card-sso-${s.id}`,children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[R(s.providerType),e.jsxs("div",{children:[e.jsx(Y,{className:"text-xl",children:s.name}),e.jsx(J,{children:G(s.providerType)})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[s.isPrimary&&e.jsx(T,{variant:"default",className:"bg-orange-500","data-testid":`badge-primary-${s.id}`,children:"Primary"}),e.jsx(T,{variant:s.isActive?"default":"secondary",className:s.isActive?"bg-green-500":"","data-testid":`badge-status-${s.id}`,children:s.isActive?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-3 w-3 mr-1"}),"Active"]}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"h-3 w-3 mr-1"}),"Inactive"]})})]})]})}),e.jsxs(E,{children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"Client ID"}),e.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[e.jsx("p",{className:"text-sm text-gray-900 dark:text-white font-mono","data-testid":`text-client-id-${s.id}`,children:p[s.id]?s.clientId||"Not configured":"â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢"}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>L(s.id),"data-testid":`button-toggle-secret-${s.id}`,children:p[s.id]?e.jsx(H,{className:"h-4 w-4"}):e.jsx(Z,{className:"h-4 w-4"})})]})]}),s.tenantId&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"Tenant ID"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white font-mono mt-1","data-testid":`text-tenant-id-${s.id}`,children:p[s.id]?s.tenantId:"â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"Callback URL"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white font-mono mt-1 break-all","data-testid":`text-callback-url-${s.id}`,children:s.callbackUrl})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"Auto Create Users"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white mt-1","data-testid":`text-auto-create-${s.id}`,children:s.autoCreateUsers?"Enabled":"Disabled"})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-4 pt-4 border-t",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>B(s),"data-testid":`button-edit-${s.id}`,children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>f.mutate(s.id),className:"text-red-600 hover:text-red-700 hover:border-red-300",disabled:f.isPending,"data-testid":`button-delete-${s.id}`,children:[e.jsx(se,{className:"h-4 w-4 mr-2"}),f.isPending?"Deleting...":"Delete"]})]})]})]},s.id))}),e.jsx(te,{open:F,onOpenChange:h,children:e.jsxs(ae,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"dialog-sso-config",children:[e.jsxs(re,{children:[e.jsx(ie,{children:d?"Edit SSO Provider":"Add SSO Provider"}),e.jsx(ne,{children:"Configure your SSO provider settings. Make sure to use the exact callback URL in your provider's configuration."})]}),e.jsx(le,{...t,children:e.jsxs("form",{onSubmit:t.handleSubmit(z),className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-semibold",children:"Basic Settings"}),e.jsx(r,{control:t.control,name:"providerType",render:({field:s})=>e.jsxs(i,{children:[e.jsx(n,{children:"Provider Type"}),e.jsxs(oe,{onValueChange:s.onChange,defaultValue:s.value,"data-testid":"select-provider-type",children:[e.jsx(l,{children:e.jsx(ce,{children:e.jsx(de,{placeholder:"Select SSO provider type"})})}),e.jsxs(xe,{children:[e.jsx(v,{value:"google",children:"Google Worksp
1ace"}),e.jsx(v,{value:"microsoft",children:"Microsoft Azure AD"}),e.jsx(v,{value:"saml",children:"SAML 2.0"})]})]}),e.jsx(c,{})]})}),e.jsx(r,{control:t.control,name:"name",render:({field:s})=>e.jsxs(i,{children:[e.jsx(n,{children:"Provider Name"}),e.jsx(l,{children:e.jsx(m,{placeholder:"e.g., Company Google SSO",...s,"data-testid":"input-provider-name"})}),e.jsx(c,{})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"text-lg font-semibold",children:[o==="google"&&"Google Workspace Configuration",o==="microsoft"&&"Microsoft Azure AD Configuration",o==="saml"&&"SAML 2.0 Configuration"]}),(o==="google"||o==="microsoft")&&e.jsxs(e.Fragment,{children:[e.jsx(r,{control:t.control,name:"clientId",render:({field:s})=>e.jsxs(i,{children:[e.jsx(n,{children:"Client ID"}),e.jsx(l,{children:e.jsx(m,{placeholder:"Your OAuth client ID",...s,"data-testid":"input-client-id"})}),e.jsx(c,{})]})}),e.jsx(r,{control:t.control,name:"clientSecret",render:({field:s})=>e.jsxs(i,{children:[e.jsx(n,{children:"Client Secret"}),e.jsx(l,{children:e.jsx(m,{type:"password",placeholder:"Your OAuth client secret",...s,"data-testid":"input-client-secret"})}),e.jsx(c,{})]})}),o==="microsoft"&&e.jsx(r,{control:t.control,name:"tenantId",render:({field:s})=>e.jsxs(i,{children:[e.jsx(n,{children:"Tenant ID"}),e.jsx(l,{children:e.jsx(m,{placeholder:"Your Azure AD tenant ID",...s,"data-testid":"input-tenant-id"})}),e.jsx(c,{})]})})]}),o==="saml"&&e.jsxs(e.Fragment,{children:[e.jsx(r,{control:t.control,name:"issuer",render:({field:s})=>e.jsxs(i,{children:[e.jsx(n,{children:"Issuer / Entity ID"}),e.jsx(l,{children:e.jsx(m,{placeholder:"https://your-provider.com/saml/metadata",...s,"data-testid":"input-issuer"})}),e.jsx(c,{})]})}),e.jsx(r,{control:t.control,name:"entrypoint",render:({field:s})=>e.jsxs(i,{children:[e.jsx(n,{children:"SSO URL / Entrypoint"}),e.jsx(l,{children:e.jsx(m,{placeholder:"https://your-provider.com/saml/sso",...s,"data-testid":"input-entrypoint"})}),e.jsx(c,{})]})}),e.jsx(r,{control:t.control,name:"certificate",render:({field:s})=>e.jsxs(i,{children:[e.jsx(n,{children:"X.509 Certificate"}),e.jsx(l,{children:e.jsx(me,{placeholder:`-----BEGIN CERTIFICATE----- 2MIIDXTCCAkWgAwIBAgIJAKoK/heBjcOuMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV 3... 4-----END CERTIFICATE-----`,rows:6,...s,"data-testid":"textarea-certificate"})}),e.jsx(c,{})]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-semibold",children:"Settings"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsx(r,{control:t.control,name:"isActive",render:({field:s})=>e.jsxs(i,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n,{className:"text-base",children:"Active"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enable this SSO provider for authentication"})]}),e.jsx(l,{children:e.jsx(S,{checked:s.value,onCheckedChange:s.onChange,"data-testid":"switch-is-active"})})]})}),e.jsx(r,{control:t.control,name:"isPrimary",render:({field:s})=>e.jsxs(i,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n,{className:"text-base",children:"Primary Provider"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set as the default SSO provider"})]}),e.jsx(l,{children:e.jsx(S,{checked:s.value,onCheckedChange:s.onChange,"data-testid":"switch-is-primary"})})]})}),e.jsx(r,{control:t.control,name:"autoCreateUsers",render:({field:s})=>e.jsxs(i,{className:"flex flex-row items-center justify-between rounded-lg border p-4 md:col-span-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n,{className:"text-base",children:"Auto Create Users"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically create user accounts for new SSO logins"})]}),e.jsx(l,{children:e.jsx(S,{checked:s.value,onCheckedChange:s.onChange,"data-testid":"switch-auto-create"})})]})})]})]}),e.jsxs(D,{children:[e.jsx(g,{className:"h-4 w-4"}),e.jsxs(O,{children:[e.jsx("strong",{children:"Callback URL:"}
4)," Use this URL in your SSO provider configuration:",e.jsx("br",{}),e.jsxs("code",{className:"text-sm bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded mt-1 block",children:[window.location.origin,"/api/sso/callback/",o,"/[PROVIDER_ID]"]})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4 border-t",children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>h(!1),"data-testid":"button-cancel-sso",children:"Cancel"}),e.jsx(x,{type:"submit",className:"bg-orange-500 hover:bg-orange-600",disabled:y.isPending,"data-testid":"button-save-sso",children:y.isPending?d?"Updating...":"Creating...":d?"Update Provider":"Create Provider"})]})]})})]})})]})}export{fe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.