From 92d45f2432135079f4c4b3f4d8bf348417b4c2ca Mon Sep 17 00:00:00 2001 From: simeng-li Date: Wed, 27 Mar 2024 11:10:48 +0800 Subject: [PATCH] refactor(core,schemas): refactor the sso connector factory type (#5541) * refactor(core,schemas): refactor the sso connector factory type refactor the sso connector factory type and add providerType to the config data * fix(core): fix ut fix ut * refactor(schemas): add the providerType to the providerDetails return type add the new providerType property to the providerDetails return type --- .../utils/single-sign-on-session.ts | 2 +- .../interaction/utils/single-sign-on.test.ts | 2 +- .../interaction/utils/single-sign-on.ts | 3 +- .../src/routes/sso-connector/utils.test.ts | 7 ++- .../core/src/routes/sso-connector/utils.ts | 8 ++- .../core/src/sso/AzureAdSsoConnector/index.ts | 3 +- .../src/sso/AzureOidcSsoConnector/index.ts | 3 +- .../sso/GoogleWorkspaceSsoConnector/index.ts | 10 ++-- .../core/src/sso/OidcSsoConnector/index.ts | 5 +- .../core/src/sso/OktaSsoConnector/index.ts | 3 +- .../core/src/sso/SamlSsoConnector/index.ts | 5 +- packages/core/src/sso/index.ts | 55 +++--------------- packages/core/src/sso/types/connector.ts | 20 +++++++ packages/core/src/sso/types/index.ts | 58 +++++++++++++------ packages/core/src/sso/types/session.ts | 8 --- .../core/src/utils/saml-assertion-handler.ts | 2 +- packages/schemas/src/types/sso-connector.ts | 17 +++++- 17 files changed, 113 insertions(+), 98 deletions(-) create mode 100644 packages/core/src/sso/types/connector.ts diff --git a/packages/core/src/routes/interaction/utils/single-sign-on-session.ts b/packages/core/src/routes/interaction/utils/single-sign-on-session.ts index cf6fe14dc..f096ca3e7 100644 --- a/packages/core/src/routes/interaction/utils/single-sign-on-session.ts +++ b/packages/core/src/routes/interaction/utils/single-sign-on-session.ts @@ -7,7 +7,7 @@ import { singleSignOnConnectorSessionGuard, singleSignOnInteractionIdentifierResultGuard, type SingleSignOnInteractionIdentifierResult, -} from '#src/sso/types/session.js'; +} from '#src/sso/index.js'; import assertThat from '#src/utils/assert-that.js'; /** diff --git a/packages/core/src/routes/interaction/utils/single-sign-on.test.ts b/packages/core/src/routes/interaction/utils/single-sign-on.test.ts index 118041021..fc85eda76 100644 --- a/packages/core/src/routes/interaction/utils/single-sign-on.test.ts +++ b/packages/core/src/routes/interaction/utils/single-sign-on.test.ts @@ -6,7 +6,7 @@ import RequestError from '#src/errors/RequestError/index.js'; import { type WithLogContext } from '#src/middleware/koa-audit-log.js'; import { OidcSsoConnector } from '#src/sso/OidcSsoConnector/index.js'; import { ssoConnectorFactories } from '#src/sso/index.js'; -import { type SingleSignOnConnectorData } from '#src/sso/types/index.js'; +import { type SingleSignOnConnectorData } from '#src/sso/types/connector.js'; import { createMockLogContext } from '#src/test-utils/koa-audit-log.js'; import { createMockProvider } from '#src/test-utils/oidc-provider.js'; import { MockTenant } from '#src/test-utils/tenant.js'; diff --git a/packages/core/src/routes/interaction/utils/single-sign-on.ts b/packages/core/src/routes/interaction/utils/single-sign-on.ts index bcaa2245a..32b49c6db 100644 --- a/packages/core/src/routes/interaction/utils/single-sign-on.ts +++ b/packages/core/src/routes/interaction/utils/single-sign-on.ts @@ -13,8 +13,7 @@ import { z } from 'zod'; import RequestError from '#src/errors/RequestError/index.js'; import { type WithLogContext } from '#src/middleware/koa-audit-log.js'; import { type WithInteractionDetailsContext } from '#src/routes/interaction/middleware/koa-interaction-details.js'; -import { ssoConnectorFactories } from '#src/sso/index.js'; -import { type SingleSignOnConnectorSession } from '#src/sso/types/index.js'; +import { ssoConnectorFactories, type SingleSignOnConnectorSession } from '#src/sso/index.js'; import type Queries from '#src/tenants/Queries.js'; import type TenantContext from '#src/tenants/TenantContext.js'; import assertThat from '#src/utils/assert-that.js'; diff --git a/packages/core/src/routes/sso-connector/utils.test.ts b/packages/core/src/routes/sso-connector/utils.test.ts index b8a54bf65..0064189fd 100644 --- a/packages/core/src/routes/sso-connector/utils.test.ts +++ b/packages/core/src/routes/sso-connector/utils.test.ts @@ -20,11 +20,12 @@ const mockTenantId = 'mock_tenant_id'; describe('parseFactoryDetail', () => { it.each(Object.values(SsoProviderName))('should return correct detail for %s', (providerName) => { - const { logo, logoDark, description, name } = ssoConnectorFactories[providerName]; + const { logo, logoDark, description, name, providerType } = ssoConnectorFactories[providerName]; const detail = parseFactoryDetail(ssoConnectorFactories[providerName], 'en'); expect(detail).toEqual({ providerName, + providerType, logo, logoDark, description: description.en, @@ -35,11 +36,13 @@ describe('parseFactoryDetail', () => { it.each(Object.values(SsoProviderName))( 'should return correct detail for %s with unknown locale', (providerName) => { - const { logo, logoDark, description, name } = ssoConnectorFactories[providerName]; + const { logo, logoDark, description, name, providerType } = + ssoConnectorFactories[providerName]; const detail = parseFactoryDetail(ssoConnectorFactories[providerName], 'zh'); expect(detail).toEqual({ providerName, + providerType, logo, logoDark, description: description.en, diff --git a/packages/core/src/routes/sso-connector/utils.ts b/packages/core/src/routes/sso-connector/utils.ts index 78014df12..db2edb18c 100644 --- a/packages/core/src/routes/sso-connector/utils.ts +++ b/packages/core/src/routes/sso-connector/utils.ts @@ -11,7 +11,7 @@ import { trySafe } from '@silverhand/essentials'; import RequestError from '#src/errors/RequestError/index.js'; import SamlConnector from '#src/sso/SamlConnector/index.js'; import { type SingleSignOnFactory, ssoConnectorFactories } from '#src/sso/index.js'; -import { type SingleSignOnConnectorData } from '#src/sso/types/index.js'; +import { type SingleSignOnConnectorData } from '#src/sso/types/connector.js'; const isKeyOfI18nPhrases = (key: string, phrases: I18nPhrases): key is keyof I18nPhrases => key in phrases; @@ -20,10 +20,11 @@ export const parseFactoryDetail = ( factory: SingleSignOnFactory, locale: string ) => { - const { providerName, logo, logoDark, description, name } = factory; + const { providerName, logo, logoDark, description, name, providerType } = factory; return { providerName, + providerType, logo, logoDark, // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- falsy value expected @@ -61,7 +62,7 @@ export const fetchConnectorProviderDetails = async ( ): Promise => { const { providerName } = connector; - const { logo, logoDark, constructor, name } = ssoConnectorFactories[providerName]; + const { logo, logoDark, constructor, name, providerType } = ssoConnectorFactories[providerName]; /* Safely fetch and parse the detailed connector config from provider. @@ -76,6 +77,7 @@ export const fetchConnectorProviderDetails = async ( ...connector, // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- falsy value expected name: (isKeyOfI18nPhrases(locale, name) && name[locale]) || name.en, + providerType, providerLogo: logo, providerLogoDark: logoDark, providerConfig, diff --git a/packages/core/src/sso/AzureAdSsoConnector/index.ts b/packages/core/src/sso/AzureAdSsoConnector/index.ts index bd8587de9..328bb10ab 100644 --- a/packages/core/src/sso/AzureAdSsoConnector/index.ts +++ b/packages/core/src/sso/AzureAdSsoConnector/index.ts @@ -1,4 +1,4 @@ -import { SsoProviderName } from '@logto/schemas'; +import { SsoProviderName, SsoProviderType } from '@logto/schemas'; import { SamlSsoConnector } from '../SamlSsoConnector/index.js'; import { type SingleSignOnFactory } from '../index.js'; @@ -8,6 +8,7 @@ export class AzureAdSsoConnector extends SamlSsoConnector {} export const azureAdSsoConnectorFactory: SingleSignOnFactory = { providerName: SsoProviderName.AZURE_AD, + providerType: SsoProviderType.SAML, logo: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUuMDY5MzQgMTguNzA5N0M1LjU4NjY3IDE5LjAzMjMgNi40NDY2NyAxOS4zOTEgNy4zNTYgMTkuMzkxQzguMTg0IDE5LjM5MSA4Ljk1MzM0IDE5LjE1MSA5LjU5MDY3IDE4Ljc0MTdDOS41OTA2NyAxOC43NDE3IDkuNTkyIDE4Ljc0MTcgOS41OTMzNCAxOC43NDAzTDEyIDE3LjIzNjNWMjIuNjY3QzExLjYxODcgMjIuNjY3IDExLjIzNDcgMjIuNTYzIDEwLjkwMTMgMjIuMzU1TDUuMDY5MzQgMTguNzA5N1oiIGZpbGw9IiMyMjUwODYiLz4KPHBhdGgg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hdGggZD0iTTEyLjAwMTMgMS4zMzMwMVY3LjAzMzAxTDEyLjE0NjcgNi44NjkwMUMxMi44OCA2LjAzMzAxIDEzLjk4MjcgNS41MDEwMSAxNS4yMTYgNS41MDEwMUMxNS44NDUzIDUuNTAxMDEgMTYuNDM3MyA1LjY0MzY3IDE2Ljk2NjcgNS44ODkwMUwxMy41MjggMi4wMTAzNEMxMy4xMjkzIDEuNTU5NjcgMTIuNTY0IDEuMzM0MzQgMTIgMS4zMzQzNEwxMi4wMDEzIDEuMzMzMDFaIiBmaWxsPSIjMDI5NEU0Ii8+CjxwYXRoIGQ9Ik0xNy44MiAxMy41OTkyTDEyLjAwMTMgNy4wMzUxNlYxNy4yMzUyTDE3LjgyIDEzLjU5OTJaIiBmaWxsPSIjOTZCQ0MyIi8+Cjwvc3ZnPgo=', diff --git a/packages/core/src/sso/AzureOidcSsoConnector/index.ts b/packages/core/src/sso/AzureOidcSsoConnector/index.ts index cbe746b1a..3f595f86f 100644 --- a/packages/core/src/sso/AzureOidcSsoConnector/index.ts +++ b/packages/core/src/sso/AzureOidcSsoConnector/index.ts @@ -1,4 +1,4 @@ -import { SsoProviderName } from '@logto/schemas'; +import { SsoProviderName, SsoProviderType } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; import camelcaseKeys from 'camelcase-keys'; @@ -65,6 +65,7 @@ export class AzureOidcSsoConnector extends OidcSsoConnector { export const azureOidcSsoConnectorFactory: SingleSignOnFactory = { providerName: SsoProviderName.AZURE_AD_OIDC, + providerType: SsoProviderType.OIDC, logo: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUuMDY5MzQgMTguNzA5N0M1LjU4NjY3IDE5LjAzMjMgNi40NDY2NyAxOS4zOTEgNy4zNTYgMTkuM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SAxNS4yMTczIDUuNUMxMy45ODQgNS41IDEyLjg4MTMgNi4wMzIgMTIuMTQ4IDYuODY4TDEyLjAwMjcgNy4wMzJMMTcuODIxMyAxMy41OTczTDEyLjAwMTMgMTcuMjM0N1YyMi42NjUzQzEyLjM4NCAyMi42NjUzIDEyLjc2NTMgMjIuNTYxMyAxMy4wOTg3IDIyLjM1MzNMMjMuMDk4NyAxNi4xMDI3VjE2LjEwNFoiIGZpbGw9IiMwNzQ3OTMiLz4KPHBhdGggZD0iTTEyLjAwMTMgMS4zMzMwMVY3LjAzMzAxTDEyLjE0NjcgNi44NjkwMUMxMi44OCA2LjAzMzAxIDEzLjk4MjcgNS41MDEwMSAxNS4yMTYgNS41MDEwMUMxNS44NDUzIDUuNTAxMDEgMTYuNDM3MyA1LjY0MzY3IDE2Ljk2NjcgNS44ODkwMUwxMy41MjggMi4wMTAzNEMxMy4xMjkzIDEuNTU5NjcgMTIuNTY0IDEuMzM0MzQgMTIgMS4zMzQzNEwxMi4wMDEzIDEuMzMzMDFaIiBmaWxsPSIjMDI5NEU0Ii8+CjxwYXRoIGQ9Ik0xNy44MiAxMy41OTkyTDEyLjAwMTMgNy4wMzUxNlYxNy4yMzUyTDE3LjgyIDEzLjU5OTJaIiBmaWxsPSIjOTZCQ0MyIi8+Cjwvc3ZnPgo=', diff --git a/packages/core/src/sso/GoogleWorkspaceSsoConnector/index.ts b/packages/core/src/sso/GoogleWorkspaceSsoConnector/index.ts index f2e4d6d56..fb56861ea 100644 --- a/packages/core/src/sso/GoogleWorkspaceSsoConnector/index.ts +++ b/packages/core/src/sso/GoogleWorkspaceSsoConnector/index.ts @@ -1,14 +1,11 @@ import { ConnectorError, ConnectorErrorCodes } from '@logto/connector-kit'; -import { SsoProviderName } from '@logto/schemas'; +import { SsoProviderName, SsoProviderType } from '@logto/schemas'; import OidcConnector from '../OidcConnector/index.js'; import { type SingleSignOnFactory } from '../index.js'; -import { - type CreateSingleSignOnSession, - type SingleSignOn, - type SingleSignOnConnectorData, -} from '../types/index.js'; +import { type SingleSignOn, type SingleSignOnConnectorData } from '../types/connector.js'; import { basicOidcConnectorConfigGuard } from '../types/oidc.js'; +import { type CreateSingleSignOnSession } from '../types/session.js'; // Google use static issue endpoint. const googleIssuer = 'https://accounts.google.com'; @@ -53,6 +50,7 @@ export const googleWorkspaceSsoConnectorConfigGuard = basicOidcConnectorConfigGu export const googleWorkSpaceSsoConnectorFactory: SingleSignOnFactory = { providerName: SsoProviderName.GOOGLE_WORKSPACE, + providerType: SsoProviderType.OIDC, logo: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yMy41MiAxMi4yNzI5QzIzLjUyIDExLjQyMiAyMy40NDM2IDEwLjYwMzggMjMuMzAxOCA5LjgxODM2SDEyVjE0LjQ2MDJIMTguNDU4MkMxOC4xOCAxNS45NjAyIDE3LjMzNDUgMTcuMjMxMSAxNi4wNjM2IDE4LjA4MlYyMS4wOTI5SDE5Ljk0MThDMjIuMjEwOSAxOS4wMDM4IDIzLjUyIDE1LjkyNzQgMjMuNTIgMTIuMjcyOVYxMi4yNzI5WiIgZmlsbD0iIzQyODVGNCIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEyIDIzLjk5OTNDMTUuMjQgMjMuOTk5MyAxNy45NTY0IDIyLjkyNDggMTkuOTQxOCAyMS4wOTJMMTYuMDYzNiAxOC4wODExQzE0Ljk4OTEgMTguODAxMSAxMy42MTQ1IDE5LjIyNjYgMTIgMTkuMjI2NkM4Ljg3NDU1IDE5LjIyNjYgNi4yMjkwOSAxNy4xMTU3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MzYzNiA4LjIzMDM1IDAgMTAuMDYzMSAwIDExLjk5OTRDMCAxMy45MzU4IDAuNDYzNjM2IDE1Ljc2ODUgMS4yNzYzNiAxNy4zODg1TDUuMjg1NDUgMTQuMjc5NFYxNC4yNzk0WiIgZmlsbD0iI0ZCQkMwNSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEyIDQuNzcyNzNDMTMuNzYxOCA0Ljc3MjczIDE1LjM0MzYgNS4zNzgxOCAxNi41ODczIDYuNTY3MjdMMjAuMDI5MSAzLjEyNTQ1QzE3Ljk1MDkgMS4xODkwOSAxNS4yMzQ1IDAgMTIgMEM3LjMwOTA5IDAgMy4yNTA5MSAyLjY4OTA5IDEuMjc2MzcgNi42MTA5MUw1LjI4NTQ2IDkuNzJDNi4yMjkwOSA2Ljg4MzY0IDguODc0NTUgNC43NzI3MyAxMiA0Ljc3MjczVjQuNzcyNzNaIiBmaWxsPSIjRUE0MzM1Ii8+Cjwvc3ZnPgo=', diff --git a/packages/core/src/sso/OidcSsoConnector/index.ts b/packages/core/src/sso/OidcSsoConnector/index.ts index b27e4efd4..7daf715a4 100644 --- a/packages/core/src/sso/OidcSsoConnector/index.ts +++ b/packages/core/src/sso/OidcSsoConnector/index.ts @@ -1,13 +1,13 @@ -import { SsoProviderName } from '@logto/schemas'; +import { SsoProviderName, SsoProviderType } from '@logto/schemas'; import OidcConnector from '../OidcConnector/index.js'; import { type SingleSignOnFactory } from '../index.js'; +import { type SingleSignOn, type SingleSignOnConnectorData } from '../types/connector.js'; import { SsoConnectorError, SsoConnectorErrorCodes, SsoConnectorConfigErrorCodes, } from '../types/error.js'; -import { type SingleSignOn, type SingleSignOnConnectorData } from '../types/index.js'; import { basicOidcConnectorConfigGuard } from '../types/oidc.js'; export class OidcSsoConnector extends OidcConnector implements SingleSignOn { @@ -36,6 +36,7 @@ export class OidcSsoConnector extends OidcConnector implements SingleSignOn { export const o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ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF85OTE0XzIwNjEyIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSJ3aGl0ZSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo=', diff --git a/packages/core/src/sso/OktaSsoConnector/index.ts b/packages/core/src/sso/OktaSsoConnector/index.ts index 27c04b8c6..ac3b8e456 100644 --- a/packages/core/src/sso/OktaSsoConnector/index.ts +++ b/packages/core/src/sso/OktaSsoConnector/index.ts @@ -1,4 +1,4 @@ -import { SsoProviderName } from '@logto/schemas'; +import { SsoProviderName, SsoProviderType } from '@logto/schemas'; import { OidcSsoConnector } from '../OidcSsoConnector/index.js'; import { type SingleSignOnFactory } from '../index.js'; @@ -10,6 +10,7 @@ export class OktaSsoConnector extends OidcSsoConnector {} export const oktaSsoConnectorFactory: SingleSignOnFactory = { providerName: SsoProviderName.OKTA, + providerType: SsoProviderType.OIDC, logo: logoBase64, logoDark: logoDarkBase64, description: { diff --git a/packages/core/src/sso/SamlSsoConnector/index.ts b/packages/core/src/sso/SamlSsoConnector/index.ts index d073dae5f..d6ff84341 100644 --- a/packages/core/src/sso/SamlSsoConnector/index.ts +++ b/packages/core/src/sso/SamlSsoConnector/index.ts @@ -1,4 +1,4 @@ -import { SsoProviderName } from '@logto/schemas'; +import { SsoProviderName, SsoProviderType } from '@logto/schemas'; import { conditional, trySafe } from '@silverhand/essentials'; import RequestError from '#src/errors/RequestError/index.js'; @@ -6,7 +6,7 @@ import assertThat from '#src/utils/assert-that.js'; import SamlConnector from '../SamlConnector/index.js'; import { type SingleSignOnFactory } from '../index.js'; -import { type SingleSignOn, type SingleSignOnConnectorData } from '../types/index.js'; +import { type SingleSignOn, type SingleSignOnConnectorData } from '../types/connector.js'; import { defaultAttributeMapping, samlConnectorConfigGuard, @@ -105,6 +105,7 @@ export class SamlSsoConnector extends SamlConnector implements SingleSignOn { export const samlSsoConnectorFactory: S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EzLjAyNCAyMS41OTA2IDE4LjE4MzYgMjIuNTMxOSAyMC4wNzUyWiIgZmlsbD0iI0MxMjcyRCIvPgo8L3N2Zz4K', diff --git a/packages/core/src/sso/index.ts b/packages/core/src/sso/index.ts index 9f1547d99..8b36bc42f 100644 --- a/packages/core/src/sso/index.ts +++ b/packages/core/src/sso/index.ts @@ -1,52 +1,15 @@ -import { type I18nPhrases } from '@logto/connector-kit'; import { SsoProviderName } from '@logto/schemas'; -import { - type AzureAdSsoConnector, - azureAdSsoConnectorFactory, -} from './AzureAdSsoConnector/index.js'; -import { - type AzureOidcSsoConnector, - azureOidcSsoConnectorFactory, -} from './AzureOidcSsoConnector/index.js'; -import { - type GoogleWorkspaceSsoConnector, - googleWorkSpaceSsoConnectorFactory, - type googleWorkspaceSsoConnectorConfigGuard, -} from './GoogleWorkspaceSsoConnector/index.js'; -import { oidcSsoConnectorFactory, type OidcSsoConnector } from './OidcSsoConnector/index.js'; -import { oktaSsoConnectorFactory, type OktaSsoConnector } from './OktaSsoConnector/index.js'; -import { samlSsoConnectorFactory, type SamlSsoConnector } from './SamlSsoConnector/index.js'; -import { type basicOidcConnectorConfigGuard } from './types/oidc.js'; -import { type samlConnectorConfigGuard } from './types/saml.js'; +import { azureAdSsoConnectorFactory } from './AzureAdSsoConnector/index.js'; +import { azureOidcSsoConnectorFactory } from './AzureOidcSsoConnector/index.js'; +import { googleWorkSpaceSsoConnectorFactory } from './GoogleWorkspaceSsoConnector/index.js'; +import { oidcSsoConnectorFactory } from './OidcSsoConnector/index.js'; +import { oktaSsoConnectorFactory } from './OktaSsoConnector/index.js'; +import { samlSsoConnectorFactory } from './SamlSsoConnector/index.js'; +import { type SingleSignOnFactory } from './types/index.js'; -type SingleSignOnConstructor = { - [SsoProviderName.OIDC]: typeof OidcSsoConnector; - [SsoProviderName.SAML]: typeof SamlSsoConnector; - [SsoProviderName.AZURE_AD]: typeof AzureAdSsoConnector; - [SsoProviderName.GOOGLE_WORKSPACE]: typeof GoogleWorkspaceSsoConnector; - [SsoProviderName.OKTA]: typeof OktaSsoConnector; - [SsoProviderName.AZURE_AD_OIDC]: typeof AzureOidcSsoConnector; -}; - -export type SingleSignOnConnectorConfig = { - [SsoProviderName.OIDC]: typeof basicOidcConnectorConfigGuard; - [SsoProviderName.SAML]: typeof samlConnectorConfigGuard; - [SsoProviderName.AZURE_AD]: typeof samlConnectorConfigGuard; - [SsoProviderName.GOOGLE_WORKSPACE]: typeof googleWorkspaceSsoConnectorConfigGuard; - [SsoProviderName.OKTA]: typeof basicOidcConnectorConfigGuard; - [SsoProviderName.AZURE_AD_OIDC]: typeof basicOidcConnectorConfigGuard; -}; - -export type SingleSignOnFactory = { - providerName: T; - logo: string; - logoDark: string; - description: I18nPhrases; - name: I18nPhrases; // This `name` is for console and experience display use, while `providerName` is for internal use. - configGuard: SingleSignOnConnectorConfig[T]; - constructor: SingleSignOnConstructor[T]; -}; +export { type SingleSignOnFactory, type SingleSignOnConnectorConfig } from './types/index.js'; +export * from './types/session.js'; export const ssoConnectorFactories: { [key in SsoProviderName]: SingleSignOnFactory; diff --git a/packages/core/src/sso/types/connector.ts b/packages/core/src/sso/types/connector.ts new file mode 100644 index 000000000..ab83215f5 --- /dev/null +++ b/packages/core/src/sso/types/connector.ts @@ -0,0 +1,20 @@ +import { type SsoProviderName, type JsonObject, type SsoConnector } from '@logto/schemas'; + +// Pick the required fields from SsoConnector Schema +// providerName must be supported by the SSO connector factories +export type SingleSignOnConnectorData = Pick & { + providerName: SsoProviderName; +}; + +/** + * Single sign-on connector interface + * @interface SingleSignOn + * + * @property {SsoConnector} data - SSO connector data schema + * @method {getConfig} getConfig - Get the full-list of SSO config from the SSO provider + */ +export abstract class SingleSignOn { + abstract data: SingleSignOnConnectorData; + abstract getConfig: () => Promise; + abstract getIssuer: () => Promise; +} diff --git a/packages/core/src/sso/types/index.ts b/packages/core/src/sso/types/index.ts index 50684b1b0..5273845c4 100644 --- a/packages/core/src/sso/types/index.ts +++ b/packages/core/src/sso/types/index.ts @@ -1,22 +1,44 @@ -import { type SsoProviderName, type JsonObject, type SsoConnector } from '@logto/schemas'; +import { type I18nPhrases } from '@logto/connector-kit'; +import { type SsoProviderType, type SsoProviderName } from '@logto/schemas'; -export * from './session.js'; +import { type AzureAdSsoConnector } from '../AzureAdSsoConnector/index.js'; +import { type AzureOidcSsoConnector } from '../AzureOidcSsoConnector/index.js'; +import { + type googleWorkspaceSsoConnectorConfigGuard, + type GoogleWorkspaceSsoConnector, +} from '../GoogleWorkspaceSsoConnector/index.js'; +import { type OidcSsoConnector } from '../OidcSsoConnector/index.js'; +import { type OktaSsoConnector } from '../OktaSsoConnector/index.js'; +import { type SamlSsoConnector } from '../SamlSsoConnector/index.js'; -/** - * Single sign-on connector interface - * @interface SingleSignOn - * - * @property {SsoConnector} data - SSO connector data schema - * @method {getConfig} getConfig - Get the full-list of SSO config from the SSO provider - */ -export abstract class SingleSignOn { - abstract data: SingleSignOnConnectorData; - abstract getConfig: () => Promise; - abstract getIssuer: () => Promise; -} +import { type basicOidcConnectorConfigGuard } from './oidc.js'; +import { type samlConnectorConfigGuard } from './saml.js'; -// Pick the required fields from SsoConnector Schema -// providerName must be supported by the SSO connector factories -export type SingleSignOnConnectorData = Pick & { - providerName: SsoProviderName; +type SingleSignOnConstructor = { + [SsoProviderName.OIDC]: typeof OidcSsoConnector; + [SsoProviderName.SAML]: typeof SamlSsoConnector; + [SsoProviderName.AZURE_AD]: typeof AzureAdSsoConnector; + [SsoProviderName.GOOGLE_WORKSPACE]: typeof GoogleWorkspaceSsoConnector; + [SsoProviderName.OKTA]: typeof OktaSsoConnector; + [SsoProviderName.AZURE_AD_OIDC]: typeof AzureOidcSsoConnector; +}; + +export type SingleSignOnConnectorConfig = { + [SsoProviderName.OIDC]: typeof basicOidcConnectorConfigGuard; + [SsoProviderName.SAML]: typeof samlConnectorConfigGuard; + [SsoProviderName.AZURE_AD]: typeof samlConnectorConfigGuard; + [SsoProviderName.GOOGLE_WORKSPACE]: typeof googleWorkspaceSsoConnectorConfigGuard; + [SsoProviderName.OKTA]: typeof basicOidcConnectorConfigGuard; + [SsoProviderName.AZURE_AD_OIDC]: typeof basicOidcConnectorConfigGuard; +}; + +export type SingleSignOnFactory = { + providerName: T; + providerType: SsoProviderType; + logo: string; + logoDark: string; + description: I18nPhrases; + name: I18nPhrases; // This `name` is for console and experience display use, while `providerName` is for internal use. + configGuard: SingleSignOnConnectorConfig[T]; + constructor: SingleSignOnConstructor[T]; }; diff --git a/packages/core/src/sso/types/session.ts b/packages/core/src/sso/types/session.ts index 71913831e..077d29086 100644 --- a/packages/core/src/sso/types/session.ts +++ b/packages/core/src/sso/types/session.ts @@ -29,16 +29,8 @@ export const singleSignOnConnectorSessionGuard = z.object({ export type SingleSignOnConnectorSession = z.infer; -export const samlConnectorAssertionSessionGuard = z.object({ - state: z.string(), - redirectUri: z.string(), - connectorId: z.string(), -}); - export type CreateSingleSignOnSession = (storage: SingleSignOnConnectorSession) => Promise; -export type GetSingleSignOnSession = () => Promise; - /** * Single sign on interaction identifier session * diff --git a/packages/core/src/utils/saml-assertion-handler.ts b/packages/core/src/utils/saml-assertion-handler.ts index 507228625..a08c4832d 100644 --- a/packages/core/src/utils/saml-assertion-handler.ts +++ b/packages/core/src/utils/saml-assertion-handler.ts @@ -10,7 +10,7 @@ import { import { type SingleSignOnConnectorSession, singleSignOnConnectorSessionGuard, -} from '#src/sso/types/index.js'; +} from '#src/sso/index.js'; import { type ExtendedSocialUserInfo } from '#src/sso/types/saml.js'; import assertThat from './assert-that.js'; diff --git a/packages/schemas/src/types/sso-connector.ts b/packages/schemas/src/types/sso-connector.ts index 145393922..e3a9bb073 100644 --- a/packages/schemas/src/types/sso-connector.ts +++ b/packages/schemas/src/types/sso-connector.ts @@ -23,6 +23,11 @@ export enum SsoProviderName { AZURE_AD_OIDC = 'AzureAdOidc', } +export enum SsoProviderType { + OIDC = 'oidc', + SAML = 'saml', +} + export const singleSignOnDomainBlackList = Object.freeze([ 'gmail.com', 'yahoo.com', @@ -51,6 +56,7 @@ export type SupportedSsoConnector = Omit & { const ssoConnectorProviderDetailGuard = z.object({ providerName: z.nativeEnum(SsoProviderName), + providerType: z.nativeEnum(SsoProviderType), logo: z.string(), logoDark: z.string(), description: z.string(), @@ -65,13 +71,18 @@ export type SsoConnectorProvidersResponse = z.infer