import{DEFAULT_SSO_IDP_TITLE as a}from"../../../constants/index.js";const l="https://auth.cloud.redocly.com/oidc/.well-known/openid-configuration";async function u(p){return{id:"sso",async processContent(s){const e=s.getConfig();if(e.ssoDirect&&typeof e.ssoDirect=="object"&&Object.keys(e.ssoDirect).length!==0||e.sso&&Array.isArray(e.sso)&&!e.sso.length)return;const i=!!(e.rbac&&typeof e.rbac=="object"&&Object.keys(e.rbac).length!==0),r=e.requiresLogin;if(!i&&!r)return;let n=l;const o=e.residency;o&&(n=`${(o.endsWith("/")?o.slice(0,-1):o).replace("app.","auth.")}/oidc/.well-known/openid-configuration`);let t="AUTO";e.sso&&(Array.isArray(e.sso)?t=e.sso.join(","):t=e.sso);const c={oidc:{title:a,type:"OIDC",configurationUrl:n,clientId:"{{ process.env.OAUTH_CLIENT_ID }}",clientSecret:"{{ process.env.OAUTH_CLIENT_SECRET }}",teamsClaimName:"https://redocly.com/sso/teams",scopes:["openid"],authorizationRequestCustomParams:{login_hint:"{{ process.env.ORG_ID }}",login_type:t,prompt:"login"},audience:"{{ process.env.ORG_ID }}"}};s.setGlobalConfig({ssoDirect:c})},async afterRoutesCreated(s){}}}export{u as ssoPlugin};
