Skip to content

Commit

Permalink
feat: get saml config for domain (#10618)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall authored Dec 18, 2024
1 parent 2c1547b commit 2da5af3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/server/graphql/private/queries/getSAMLForDomain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import getKysely from '../../../postgres/getKysely'
import standardError from '../../../utils/standardError'
import {QueryResolvers} from '../resolverTypes'

const getSAMLForDomain: QueryResolvers['getSAMLForDomain'] = async (_parent, {domain}) => {
const pg = getKysely()

const samlResult = await pg
.selectFrom('SAML')
.innerJoin('SAMLDomain', 'SAML.id', 'SAMLDomain.samlId')
.selectAll('SAML')
.where('SAMLDomain.domain', '=', domain.toLowerCase())
.executeTakeFirst()

if (!samlResult) {
return standardError(new Error('No SAML configuration found for domain'))
}
return {
saml: samlResult
}
}

export default getSAMLForDomain
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
Return value for getSAMLForDomain, which could be an error
"""
union GetSAMLForDomainPayload = ErrorPayload | GetSAMLForDomainSuccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type GetSAMLForDomainSuccess {
"""
The SAML configuration
"""
saml: SAML!
}
7 changes: 7 additions & 0 deletions packages/server/graphql/private/typeDefs/Query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,11 @@ type Query {
"""
includeInactive: Boolean! = false
): [Organization!]

getSAMLForDomain(
"""
the domain to get the SAML record for
"""
domain: String!
): GetSAMLForDomainPayload
}

0 comments on commit 2da5af3

Please sign in to comment.