File tree Expand file tree Collapse file tree 3 files changed +19
-16
lines changed
app/api/auth/sso/register Expand file tree Collapse file tree 3 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -403,7 +403,6 @@ export async function POST(request: NextRequest) {
403403 idpMetadata : {
404404 metadata : computedIdpMetadataXml ,
405405 } ,
406- mapping,
407406 }
408407
409408 if ( audience ) samlConfig . audience = audience
@@ -413,7 +412,6 @@ export async function POST(request: NextRequest) {
413412 if ( identifierFormat ) samlConfig . identifierFormat = identifierFormat
414413
415414 providerConfig . samlConfig = samlConfig
416- providerConfig . mapping = undefined
417415 }
418416
419417 logger . info ( 'Calling Better Auth registerSSOProvider with config:' , {
Original file line number Diff line number Diff line change @@ -133,7 +133,12 @@ export function SSO() {
133133 )
134134 }
135135 } else {
136- if ( ! isLoadingProviders && isSSOProviderOwner === false && providers . length > 0 ) {
136+ if (
137+ ! activeOrganization &&
138+ ! isLoadingProviders &&
139+ isSSOProviderOwner === false &&
140+ providers . length > 0
141+ ) {
137142 return (
138143 < div className = 'flex h-full items-center justify-center text-[var(--text-muted)] text-small' >
139144 Only the user who configured SSO can manage these settings.
Original file line number Diff line number Diff line change @@ -241,19 +241,6 @@ function buildSSOConfigFromEnv(): SSOProviderConfig | null {
241241 ''
242242 ) . replace ( / \/ $ / , '' )
243243
244- const callbackUrl =
245- process . env . SSO_SAML_CALLBACK_URL || `${ appBaseUrl } /api/auth/sso/saml2/callback/${ providerId } `
246-
247- let spMetadata = process . env . SSO_SAML_SP_METADATA
248- if ( ! spMetadata ) {
249- spMetadata = `<?xml version="1.0" encoding="UTF-8"?>
250- <md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="${ appBaseUrl } ">
251- <md:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
252- <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="${ callbackUrl } " index="1"/>
253- </md:SPSSODescriptor>
254- </md:EntityDescriptor>`
255- }
256-
257244 const escapeXml = ( str : string ) =>
258245 str . replace ( / [ < > & " ' ] / g, ( c ) => {
259246 switch ( c ) {
@@ -272,6 +259,19 @@ function buildSSOConfigFromEnv(): SSOProviderConfig | null {
272259 }
273260 } )
274261
262+ const callbackUrl =
263+ process . env . SSO_SAML_CALLBACK_URL || `${ appBaseUrl } /api/auth/sso/saml2/callback/${ providerId } `
264+
265+ let spMetadata = process . env . SSO_SAML_SP_METADATA
266+ if ( ! spMetadata ) {
267+ spMetadata = `<?xml version="1.0" encoding="UTF-8"?>
268+ <md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="${ escapeXml ( appBaseUrl ) } ">
269+ <md:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
270+ <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="${ escapeXml ( callbackUrl ) } " index="1"/>
271+ </md:SPSSODescriptor>
272+ </md:EntityDescriptor>`
273+ }
274+
275275 const idpMetadataXml = process . env . SSO_SAML_IDP_METADATA
276276 let computedIdpMetadata : string
277277 if ( idpMetadataXml ) {
You can’t perform that action at this time.
0 commit comments