Skip to content

Commit

Permalink
fix: support single-tenant saml record (#9486)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
  • Loading branch information
mattkrick authored Mar 1, 2024
1 parent 807e347 commit 4e2e2ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/server/graphql/private/mutations/loginSAML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import getSignOnURL from '../../public/mutations/helpers/SAMLHelpers/getSignOnUR
import {SSORelayState} from '../../queries/SAMLIdP'
import {MutationResolvers} from '../resolverTypes'
import standardError from '../../../utils/standardError'
import {isSingleTenantSSO} from '../../../utils/getSAMLURLFromEmail'

const serviceProvider = samlify.ServiceProvider({})
samlify.setSchemaValidator(samlXMLValidator)
Expand Down Expand Up @@ -104,8 +105,10 @@ const loginSAML: MutationResolvers['loginSAML'] = async (
}
const ssoDomain = getSSODomainFromEmail(email)
if (!ssoDomain || !domains.includes(ssoDomain)) {
// don't blindly trust the IdP
return {error: {message: `${email} does not belong to ${domains.join(', ')}`}}
if (!isSingleTenantSSO) {
// don't blindly trust the IdP unless there is only 1
return {error: {message: `${email} does not belong to ${domains.join(', ')}`}}
}
}

if (newMetadata) {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/utils/getSAMLURLFromEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {URL} from 'url'
import {DataLoaderWorker} from '../graphql/graphql'
import getKysely from '../postgres/getKysely'

const isSingleTenantSSO =
export const isSingleTenantSSO =
process.env.AUTH_INTERNAL_DISABLED === 'true' &&
process.env.AUTH_GOOGLE_DISABLED === 'true' &&
process.env.AUTH_MICROSOFT_DISABLED === 'true' &&
Expand Down

0 comments on commit 4e2e2ca

Please sign in to comment.