Skip to content

Commit 2df8476

Browse files
author
Tim Kendrick
committed
fix: ensure correct SAML Entity ID in client SSO flow
When initiating a SAML client flow via the /sso endpoint, the service provider object Entity ID is omitted from the initialization options, causing the underlying saml library to incorrectly use the metadata URL for the SAML server as the Entity ID. This causes some service providers (e.g. Microsoft Entra ID) to reject the SAML authentication request, as the inferred supabase auth server metadata URL does not match the provider's Entity ID. This change ensures the service provider is correctly initialized with the provider Entity ID during the client auth flow, while retaining the existing behavior for the server metadata endpoint.
1 parent dea5b8e commit 2df8476

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/api/saml.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ func (a *API) getSAMLServiceProvider(identityProvider *saml.EntityDescriptor, id
4040

4141
externalURL.Path += "sso/"
4242

43+
entityID := ""
44+
if identityProvider != nil {
45+
entityID = identityProvider.EntityID
46+
}
47+
4348
provider := samlsp.DefaultServiceProvider(samlsp.Options{
4449
URL: *externalURL,
4550
Key: a.config.SAML.RSAPrivateKey,
4651
Certificate: a.config.SAML.Certificate,
4752
SignRequest: true,
4853
AllowIDPInitiated: idpInitiated,
4954
IDPMetadata: identityProvider,
55+
EntityID: entityID,
5056
})
5157

5258
provider.AuthnNameIDFormat = saml.PersistentNameIDFormat

0 commit comments

Comments
 (0)