@gzl10/nexus-plugin-auth-providers 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-TPBCCFGG.js +489 -0
- package/dist/chunk-TPBCCFGG.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +749 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/index.d.ts +402 -0
- package/dist/shared/index.js +17 -0
- package/dist/shared/index.js.map +1 -0
- package/image.png +0 -0
- package/package.json +42 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/providers/google/adapter.ts","../src/providers/google/index.ts","../src/providers/github/adapter.ts","../src/providers/github/index.ts","../src/providers/gitlab/adapter.ts","../src/providers/gitlab/index.ts","../src/providers/microsoft/adapter.ts","../src/providers/microsoft/index.ts","../src/providers/pocketid/adapter.ts","../src/providers/pocketid/index.ts","../src/providers/oidc/adapter.ts","../src/providers/oidc/index.ts"],"sourcesContent":["/**\n * @gzl10/nexus-plugin-auth-providers\n *\n * Consolidated auth providers plugin for Nexus BaaS.\n * Auto-discovers active providers based on environment variables.\n *\n * Supported providers:\n * - Google (OIDC) — GOOGLE_CLIENT_ID\n * - GitHub (OAuth 2.0) — GITHUB_CLIENT_ID\n * - GitLab (OAuth 2.0) — GITLAB_CLIENT_ID\n * - Microsoft (OIDC) — MICROSOFT_CLIENT_ID\n * - PocketID (OIDC) — POCKETID_URL\n * - Generic OIDC — OIDC_ISSUER_URL\n */\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { PluginManifest, ModuleManifest, PluginEnvVar } from '@gzl10/nexus-sdk'\nimport { authProvidersConfigEntity } from './shared/index.js'\n\nconst pkg = JSON.parse(readFileSync(join(import.meta.dirname, '..', 'package.json'), 'utf-8')) as { version: string }\n\n// ============================================================================\n// PROVIDER REGISTRY\n// ============================================================================\n\ninterface ProviderDef {\n name: string\n envKey: string\n modules: () => ModuleManifest[]\n envVars: PluginEnvVar[]\n}\n\n// Google\nimport { configModule as googleConfig, authModule as googleAuth } from './providers/google/index.js'\n// GitHub\nimport { configModule as githubConfig, authModule as githubAuth } from './providers/github/index.js'\n// GitLab\nimport { configModule as gitlabConfig, authModule as gitlabAuth } from './providers/gitlab/index.js'\n// Microsoft\nimport { configModule as microsoftConfig, authModule as microsoftAuth } from './providers/microsoft/index.js'\n// PocketID\nimport { configModule as pocketidConfig, authModule as pocketidAuth } from './providers/pocketid/index.js'\n// Generic OIDC\nimport { configModule as oidcConfig, authModule as oidcAuth } from './providers/oidc/index.js'\n\nconst providers: ProviderDef[] = [\n {\n name: 'google',\n envKey: 'GOOGLE_CLIENT_ID',\n modules: () => [googleConfig, googleAuth],\n envVars: [\n { name: 'GOOGLE_CLIENT_ID', description: { en: 'Google OAuth client ID' }, required: true },\n { name: 'GOOGLE_CLIENT_SECRET', description: { en: 'Google OAuth client secret' }, required: true, sensitive: true }\n ]\n },\n {\n name: 'github',\n envKey: 'GITHUB_CLIENT_ID',\n modules: () => [githubConfig, githubAuth],\n envVars: [\n { name: 'GITHUB_CLIENT_ID', description: { en: 'GitHub OAuth client ID' }, required: true },\n { name: 'GITHUB_CLIENT_SECRET', description: { en: 'GitHub OAuth client secret' }, required: true, sensitive: true }\n ]\n },\n {\n name: 'gitlab',\n envKey: 'GITLAB_CLIENT_ID',\n modules: () => [gitlabConfig, gitlabAuth],\n envVars: [\n { name: 'GITLAB_CLIENT_ID', description: { en: 'GitLab OAuth client ID' }, required: true },\n { name: 'GITLAB_CLIENT_SECRET', description: { en: 'GitLab OAuth client secret' }, required: true, sensitive: true },\n { name: 'GITLAB_URL', description: { en: 'GitLab instance URL (default: https://gitlab.com)' }, required: false }\n ]\n },\n {\n name: 'microsoft',\n envKey: 'MICROSOFT_CLIENT_ID',\n modules: () => [microsoftConfig, microsoftAuth],\n envVars: [\n { name: 'MICROSOFT_CLIENT_ID', description: { en: 'Microsoft OAuth client ID' }, required: true },\n { name: 'MICROSOFT_CLIENT_SECRET', description: { en: 'Microsoft OAuth client secret' }, required: true, sensitive: true },\n { name: 'MICROSOFT_TENANT_ID', description: { en: 'Azure AD tenant ID (default: common)' }, required: false }\n ]\n },\n {\n name: 'pocketid',\n envKey: 'POCKETID_URL',\n modules: () => [pocketidConfig, pocketidAuth],\n envVars: [\n { name: 'POCKETID_URL', description: { en: 'PocketID instance URL' }, required: true },\n { name: 'POCKETID_CLIENT_ID', description: { en: 'PocketID OAuth client ID' }, required: true },\n { name: 'POCKETID_CLIENT_SECRET', description: { en: 'PocketID OAuth client secret' }, required: true, sensitive: true }\n ]\n },\n {\n name: 'oidc',\n envKey: 'OIDC_ISSUER_URL',\n modules: () => [oidcConfig, oidcAuth],\n envVars: [\n { name: 'OIDC_ISSUER_URL', description: { en: 'OIDC issuer URL (discovery endpoint)' }, required: true },\n { name: 'OIDC_CLIENT_ID', description: { en: 'OIDC client ID' }, required: true },\n { name: 'OIDC_CLIENT_SECRET', description: { en: 'OIDC client secret' }, required: true, sensitive: true }\n ]\n }\n]\n\n// ============================================================================\n// AUTO-DISCOVERY\n// ============================================================================\n\nconst activeProviders = providers.filter(p => !!process.env[p.envKey])\nconst providerModules = activeProviders.flatMap(p => p.modules())\nconst activeEnvVars = activeProviders.flatMap(p => p.envVars)\n\n// Base module: registers the unified auth_providers_config entity (only if providers are active)\nconst baseModule: ModuleManifest = {\n name: 'auth_providers_config',\n type: 'plugin',\n category: 'security',\n label: { en: 'Auth Providers Config', es: 'Config Proveedores Auth' },\n icon: 'mdi:shield-key',\n definitions: [authProvidersConfigEntity]\n}\n\nconst activeModules = activeProviders.length > 0\n ? [baseModule, ...providerModules]\n : []\n\n// ============================================================================\n// PLUGIN MANIFEST\n// ============================================================================\n\nexport const authProvidersPlugin: PluginManifest = {\n name: '@gzl10/nexus-plugin-auth-providers',\n code: 'atp',\n version: pkg.version,\n label: { en: 'Auth Providers', es: 'Proveedores de Auth' },\n icon: 'mdi:shield-check',\n category: 'integrations',\n description: {\n en: 'Consolidated OAuth/OIDC authentication providers (Google, GitHub, GitLab, Microsoft, PocketID, Generic OIDC)',\n es: 'Proveedores de autenticación OAuth/OIDC consolidados'\n },\n modules: activeModules,\n envVars: activeEnvVars\n}\n\nexport default authProvidersPlugin\n","/**\n * Google OIDC Adapter\n *\n * Provider-specific logic for Google authentication.\n * Everything else (state management, identity resolution, controller)\n * is handled by the shared Auth Plugin Base in @gzl10/nexus-sdk.\n */\nimport type { ModuleContext } from '@gzl10/nexus-sdk'\nimport {\n getOidcClient,\n type OidcDiscoveryDocument\n} from '@gzl10/nexus-sdk'\nimport type {\n AuthPluginAdapter,\n AuthPluginBaseConfig,\n BuildAuthUrlParams,\n AuthPluginUserInfo\n} from '../../shared/index.js'\n\n// ============================================================================\n// CONFIG TYPE\n// ============================================================================\n\nexport interface GoogleAuthConfig extends AuthPluginBaseConfig {\n /** Provider-specific: extra_config JSON with hosted_domain */\n extra_config: string | null\n}\n\ninterface GoogleExtraConfig {\n hosted_domain?: string | null\n}\n\n// ============================================================================\n// ADAPTER\n// ============================================================================\n\nconst GOOGLE_ISSUER = 'https://accounts.google.com'\n\nexport function createGoogleAdapter(ctx: ModuleContext): AuthPluginAdapter<GoogleAuthConfig> {\n const { errors } = ctx.core\n const oidcClient = getOidcClient()\n\n // Discovery cache (1 hour)\n let discoveryDoc: OidcDiscoveryDocument | null = null\n let discoveryExpires = 0\n\n async function getDiscovery(): Promise<OidcDiscoveryDocument> {\n const now = Date.now()\n if (discoveryDoc && discoveryExpires > now) {\n return discoveryDoc\n }\n discoveryDoc = await oidcClient.discover(GOOGLE_ISSUER)\n discoveryExpires = now + 3600000\n return discoveryDoc\n }\n\n function parseExtraConfig(config: GoogleAuthConfig): GoogleExtraConfig {\n if (!config.extra_config) return {}\n try {\n return typeof config.extra_config === 'string'\n ? JSON.parse(config.extra_config) as GoogleExtraConfig\n : config.extra_config as unknown as GoogleExtraConfig\n } catch {\n return {}\n }\n }\n\n return {\n provider: 'google',\n\n async getValidConfig(): Promise<GoogleAuthConfig> {\n const configService = ctx.services.get<{ getConfig(): Promise<GoogleAuthConfig | null> }>('google.config')\n const config = await configService.getConfig()\n\n if (!config?.enabled) {\n throw new errors.ForbiddenError('Google authentication is disabled')\n }\n if (!config.client_id || !config.client_secret) {\n throw new errors.ForbiddenError('Google Auth is not fully configured')\n }\n return config\n },\n\n async buildAuthorizationUrl(config: GoogleAuthConfig, params: BuildAuthUrlParams): Promise<string> {\n const discovery = await getDiscovery()\n const extra = parseExtraConfig(config)\n\n return oidcClient.buildAuthorizationUrl(discovery.authorization_endpoint, {\n clientId: config.client_id,\n redirectUri: params.redirectUri,\n scopes: params.scopes,\n state: params.state,\n nonce: params.nonce,\n hostedDomain: extra.hosted_domain || undefined\n })\n },\n\n async exchangeCodeAndGetUserInfo(\n config: GoogleAuthConfig,\n code: string,\n redirectUri: string,\n nonce: string\n ): Promise<AuthPluginUserInfo> {\n const discovery = await getDiscovery()\n\n // Exchange code for tokens\n const tokens = await oidcClient.exchangeCode({\n tokenEndpoint: discovery.token_endpoint,\n clientId: config.client_id,\n clientSecret: config.client_secret,\n code,\n redirectUri\n })\n\n // Validate ID token\n if (tokens.id_token) {\n await oidcClient.validateIdToken(tokens.id_token, {\n jwksUri: discovery.jwks_uri,\n issuer: discovery.issuer,\n clientId: config.client_id,\n nonce\n })\n }\n\n // Get user info\n const userInfo = await oidcClient.getUserInfo(\n tokens.access_token,\n discovery.userinfo_endpoint\n )\n\n return {\n providerUserId: userInfo.sub,\n email: userInfo.email || null,\n name: userInfo.name || userInfo.preferred_username || null,\n raw: userInfo as unknown as Record<string, unknown>\n }\n }\n }\n}\n","import {\n createAuthConfigModule,\n createAuthModule\n} from '../../shared/index.js'\nimport { createGoogleAdapter } from './adapter.js'\n\n// ============================================================================\n// MODULES (generated by factories)\n// ============================================================================\n\nexport const configModule = createAuthConfigModule({\n name: 'google_auth_config',\n label: { en: 'Google Auth Config', es: 'Configuración Google Auth' },\n provider: 'google',\n envPrefix: 'GOOGLE',\n defaultScopes: 'openid profile email',\n defaultRole: 'VIEWER'\n})\n\nexport const authModule = createAuthModule({\n name: 'google_auth',\n label: { en: 'Google Auth', es: 'Auth Google' },\n configDependency: 'google_auth_config',\n provider: 'google',\n caslSubject: 'GoogleAuth',\n providerInfo: {\n code: 'GOOGLE_AUTH',\n provider: 'google',\n icon: 'mdi:google',\n label: { en: 'Sign in with Google', es: 'Iniciar sesión con Google' },\n color: '#4285F4'\n },\n createAdapter: createGoogleAdapter\n})\n","/**\n * GitHub OAuth 2.0 Adapter\n *\n * Provider-specific logic for GitHub authentication.\n * Note: GitHub does NOT support OIDC, only OAuth 2.0.\n * Token exchange and user info use direct API calls via ofetch.\n */\nimport { ofetch } from 'ofetch'\nimport type { ModuleContext } from '@gzl10/nexus-sdk'\nimport type {\n AuthPluginAdapter,\n AuthPluginBaseConfig,\n BuildAuthUrlParams,\n AuthPluginUserInfo\n} from '../../shared/index.js'\n\n// ============================================================================\n// GITHUB API TYPES\n// ============================================================================\n\ninterface GitHubUserInfo {\n id: number\n login: string\n name: string | null\n email: string | null\n avatar_url: string\n}\n\ninterface GitHubEmail {\n email: string\n primary: boolean\n verified: boolean\n}\n\n// ============================================================================\n// CONSTANTS\n// ============================================================================\n\nconst GITHUB_AUTHORIZE_URL = 'https://github.com/login/oauth/authorize'\nconst GITHUB_TOKEN_URL = 'https://github.com/login/oauth/access_token'\nconst GITHUB_USER_URL = 'https://api.github.com/user'\nconst GITHUB_EMAILS_URL = 'https://api.github.com/user/emails'\n\n// ============================================================================\n// ADAPTER\n// ============================================================================\n\nexport function createGitHubAdapter(ctx: ModuleContext): AuthPluginAdapter<AuthPluginBaseConfig> {\n const { logger, errors } = ctx.core\n\n return {\n provider: 'github',\n\n async getValidConfig(): Promise<AuthPluginBaseConfig> {\n const configService = ctx.services.get<{ getConfig(): Promise<AuthPluginBaseConfig | null> }>('github.config')\n const config = await configService.getConfig()\n\n if (!config?.enabled) {\n throw new errors.ForbiddenError('GitHub authentication is disabled')\n }\n if (!config.client_id || !config.client_secret) {\n throw new errors.ForbiddenError('GitHub Auth is not fully configured')\n }\n return config\n },\n\n async buildAuthorizationUrl(config: AuthPluginBaseConfig, params: BuildAuthUrlParams): Promise<string> {\n const queryParams = new URLSearchParams({\n client_id: config.client_id,\n redirect_uri: params.redirectUri,\n scope: config.scopes || 'user:email',\n state: params.state\n })\n return `${GITHUB_AUTHORIZE_URL}?${queryParams}`\n },\n\n async exchangeCodeAndGetUserInfo(\n config: AuthPluginBaseConfig,\n code: string,\n redirectUri: string,\n _nonce: string\n ): Promise<AuthPluginUserInfo> {\n // Exchange code for access token\n const tokenResponse = await ofetch<{\n access_token?: string\n error?: string\n error_description?: string\n }>(GITHUB_TOKEN_URL, {\n method: 'POST',\n headers: { Accept: 'application/json' },\n body: {\n client_id: config.client_id,\n client_secret: config.client_secret,\n code,\n redirect_uri: redirectUri\n }\n })\n\n if (tokenResponse.error || !tokenResponse.access_token) {\n throw new errors.ValidationError(\n tokenResponse.error_description || tokenResponse.error || 'Failed to exchange code'\n )\n }\n\n const accessToken = tokenResponse.access_token\n\n // Get user info\n const user = await ofetch<GitHubUserInfo>(GITHUB_USER_URL, {\n headers: { Authorization: `Bearer ${accessToken}` }\n })\n\n // If email is not public, fetch from emails API\n let email = user.email\n if (!email) {\n try {\n const emails = await ofetch<GitHubEmail[]>(GITHUB_EMAILS_URL, {\n headers: { Authorization: `Bearer ${accessToken}` }\n })\n const primaryEmail = emails.find(e => e.primary && e.verified)\n if (primaryEmail) {\n email = primaryEmail.email\n }\n } catch {\n logger.debug('Could not fetch emails - scope might not be granted')\n }\n }\n\n return {\n providerUserId: user.id.toString(),\n email: email || null,\n name: user.name || user.login || null,\n raw: user as unknown as Record<string, unknown>\n }\n }\n }\n}\n","import {\n createAuthConfigModule,\n createAuthModule\n} from '../../shared/index.js'\nimport { createGitHubAdapter } from './adapter.js'\n\n// ============================================================================\n// MODULES (generated by factories)\n// ============================================================================\n\nexport const configModule = createAuthConfigModule({\n name: 'github_auth_config',\n label: { en: 'GitHub Auth Config', es: 'Configuración GitHub Auth' },\n provider: 'github',\n envPrefix: 'GITHUB',\n defaultScopes: 'user:email',\n defaultRole: 'VIEWER'\n})\n\nexport const authModule = createAuthModule({\n name: 'github_auth',\n label: { en: 'GitHub Auth', es: 'Auth GitHub' },\n configDependency: 'github_auth_config',\n provider: 'github',\n caslSubject: 'GitHubAuth',\n providerInfo: {\n code: 'GITHUB_AUTH',\n provider: 'github',\n icon: 'mdi:github',\n label: { en: 'Sign in with GitHub', es: 'Iniciar sesión con GitHub' },\n color: '#24292e'\n },\n createAdapter: createGitHubAdapter\n})\n","/**\n * GitLab OAuth 2.0 Adapter\n *\n * Provider-specific logic for GitLab authentication (cloud and self-hosted).\n * Supports configurable GitLab instance URL via extra_config.gitlab_url or GITLAB_URL env var.\n */\nimport { ofetch } from 'ofetch'\nimport type { ModuleContext } from '@gzl10/nexus-sdk'\nimport type {\n AuthPluginAdapter,\n AuthPluginBaseConfig,\n BuildAuthUrlParams,\n AuthPluginUserInfo\n} from '../../shared/index.js'\n\n// ============================================================================\n// GITLAB API TYPES\n// ============================================================================\n\ninterface GitLabUserInfo {\n id: number\n username: string\n email: string | null\n name: string\n avatar_url: string | null\n}\n\ninterface GitLabAuthConfig extends AuthPluginBaseConfig {\n extra_config?: {\n gitlab_url?: string\n } | null\n}\n\n// ============================================================================\n// ADAPTER\n// ============================================================================\n\nexport function createGitLabAdapter(ctx: ModuleContext): AuthPluginAdapter<GitLabAuthConfig> {\n const { errors } = ctx.core\n\n function getGitLabUrl(config: GitLabAuthConfig): string {\n const url =\n config?.extra_config?.gitlab_url || process.env['GITLAB_URL'] || 'https://gitlab.com'\n return url.replace(/\\/$/, '')\n }\n\n return {\n provider: 'gitlab',\n\n async getValidConfig(): Promise<GitLabAuthConfig> {\n const configService = ctx.services.get<{\n getConfig(): Promise<GitLabAuthConfig | null>\n }>('gitlab.config')\n const config = await configService.getConfig()\n\n if (!config?.enabled) {\n throw new errors.ForbiddenError('GitLab authentication is disabled')\n }\n if (!config.client_id || !config.client_secret) {\n throw new errors.ForbiddenError('GitLab Auth is not fully configured')\n }\n return config\n },\n\n async buildAuthorizationUrl(\n config: GitLabAuthConfig,\n params: BuildAuthUrlParams\n ): Promise<string> {\n const gitlabUrl = getGitLabUrl(config)\n const queryParams = new URLSearchParams({\n client_id: config.client_id,\n redirect_uri: params.redirectUri,\n response_type: 'code',\n scope: config.scopes || 'read_user',\n state: params.state\n })\n return `${gitlabUrl}/oauth/authorize?${queryParams}`\n },\n\n async exchangeCodeAndGetUserInfo(\n config: GitLabAuthConfig,\n code: string,\n redirectUri: string,\n _nonce: string\n ): Promise<AuthPluginUserInfo> {\n const gitlabUrl = getGitLabUrl(config)\n\n // Exchange code for access token\n const tokenResponse = await ofetch<{\n access_token?: string\n error?: string\n error_description?: string\n }>(`${gitlabUrl}/oauth/token`, {\n method: 'POST',\n headers: { Accept: 'application/json' },\n body: {\n client_id: config.client_id,\n client_secret: config.client_secret,\n code,\n redirect_uri: redirectUri,\n grant_type: 'authorization_code'\n }\n })\n\n if (tokenResponse.error || !tokenResponse.access_token) {\n throw new errors.ValidationError(\n tokenResponse.error_description || tokenResponse.error || 'Failed to exchange code'\n )\n }\n\n const accessToken = tokenResponse.access_token\n\n // Get user info\n const user = await ofetch<GitLabUserInfo>(`${gitlabUrl}/api/v4/user`, {\n headers: { Authorization: `Bearer ${accessToken}` }\n })\n\n return {\n providerUserId: user.id.toString(),\n email: user.email || null,\n name: user.name || user.username || null,\n raw: user as unknown as Record<string, unknown>\n }\n }\n }\n}\n","import {\n createAuthConfigModule,\n createAuthModule\n} from '../../shared/index.js'\nimport { createGitLabAdapter } from './adapter.js'\n\n// ============================================================================\n// MODULES (generated by factories)\n// ============================================================================\n\nexport const configModule = createAuthConfigModule({\n name: 'gitlab_auth_config',\n label: { en: 'GitLab Auth Config', es: 'Configuración GitLab Auth' },\n provider: 'gitlab',\n envPrefix: 'GITLAB',\n defaultScopes: 'read_user',\n defaultRole: 'VIEWER',\n extraConfig: {\n gitlab_url: process.env['GITLAB_URL'] || 'https://gitlab.com'\n }\n})\n\nexport const authModule = createAuthModule({\n name: 'gitlab_auth',\n label: { en: 'GitLab Auth', es: 'Auth GitLab' },\n configDependency: 'gitlab_auth_config',\n provider: 'gitlab',\n caslSubject: 'GitLabAuth',\n providerInfo: {\n code: 'GITLAB_AUTH',\n provider: 'gitlab',\n icon: 'mdi:gitlab',\n label: { en: 'Sign in with GitLab', es: 'Iniciar sesión con GitLab' },\n color: '#FC6D26'\n },\n createAdapter: createGitLabAdapter\n})\n","/**\n * Microsoft OIDC Adapter\n *\n * Provider-specific logic for Microsoft/Azure AD authentication.\n * Supports single/multi-tenant scenarios with tenant-aware discovery.\n * Everything else (state management, identity resolution, controller)\n * is handled by the shared Auth Plugin Base in @gzl10/nexus-sdk.\n */\nimport type { ModuleContext } from '@gzl10/nexus-sdk'\nimport {\n getOidcClient,\n type OidcDiscoveryDocument\n} from '@gzl10/nexus-sdk'\nimport type {\n AuthPluginAdapter,\n AuthPluginBaseConfig,\n BuildAuthUrlParams,\n AuthPluginUserInfo\n} from '../../shared/index.js'\n\n// ============================================================================\n// CONFIG TYPE\n// ============================================================================\n\nexport interface MicrosoftAuthConfig extends AuthPluginBaseConfig {\n /** Provider-specific: extra_config JSON with tenant_id */\n extra_config: string | null\n}\n\ninterface MicrosoftExtraConfig {\n tenant_id?: string | null\n}\n\n// ============================================================================\n// ADAPTER\n// ============================================================================\n\nexport function createMicrosoftAdapter(ctx: ModuleContext): AuthPluginAdapter<MicrosoftAuthConfig> {\n const { errors } = ctx.core\n const oidcClient = getOidcClient()\n\n // Discovery cache per tenant (1 hour TTL)\n const discoveryCache = new Map<string, { doc: OidcDiscoveryDocument; expiresAt: number }>()\n const CACHE_TTL = 3600000 // 1 hour\n\n function getTenant(config: MicrosoftAuthConfig): string {\n const extra = parseExtraConfig(config)\n return extra.tenant_id || process.env['MICROSOFT_TENANT_ID'] || 'common'\n }\n\n function parseExtraConfig(config: MicrosoftAuthConfig): MicrosoftExtraConfig {\n if (!config.extra_config) return {}\n try {\n return typeof config.extra_config === 'string'\n ? JSON.parse(config.extra_config) as MicrosoftExtraConfig\n : config.extra_config as unknown as MicrosoftExtraConfig\n } catch {\n return {}\n }\n }\n\n async function getDiscovery(tenant: string): Promise<OidcDiscoveryDocument> {\n const now = Date.now()\n const cached = discoveryCache.get(tenant)\n if (cached && cached.expiresAt > now) {\n return cached.doc\n }\n\n const issuer = `https://login.microsoftonline.com/${tenant}/v2.0`\n const doc = await oidcClient.discover(issuer)\n discoveryCache.set(tenant, { doc, expiresAt: now + CACHE_TTL })\n return doc\n }\n\n return {\n provider: 'microsoft',\n\n async getValidConfig(): Promise<MicrosoftAuthConfig> {\n const configService = ctx.services.get<{ getConfig(): Promise<MicrosoftAuthConfig | null> }>('microsoft.config')\n const config = await configService.getConfig()\n\n if (!config?.enabled) {\n throw new errors.ForbiddenError('Microsoft authentication is disabled')\n }\n if (!config.client_id || !config.client_secret) {\n throw new errors.ForbiddenError('Microsoft Auth is not fully configured')\n }\n return config\n },\n\n async buildAuthorizationUrl(config: MicrosoftAuthConfig, params: BuildAuthUrlParams): Promise<string> {\n const tenant = getTenant(config)\n const discovery = await getDiscovery(tenant)\n\n return oidcClient.buildAuthorizationUrl(discovery.authorization_endpoint, {\n clientId: config.client_id,\n redirectUri: params.redirectUri,\n scopes: params.scopes,\n state: params.state,\n nonce: params.nonce\n })\n },\n\n async exchangeCodeAndGetUserInfo(\n config: MicrosoftAuthConfig,\n code: string,\n redirectUri: string,\n nonce: string\n ): Promise<AuthPluginUserInfo> {\n const tenant = getTenant(config)\n const discovery = await getDiscovery(tenant)\n\n // Exchange code for tokens\n const tokens = await oidcClient.exchangeCode({\n tokenEndpoint: discovery.token_endpoint,\n clientId: config.client_id,\n clientSecret: config.client_secret,\n code,\n redirectUri\n })\n\n // Validate ID token\n if (tokens.id_token) {\n await oidcClient.validateIdToken(tokens.id_token, {\n jwksUri: discovery.jwks_uri,\n issuer: discovery.issuer,\n clientId: config.client_id,\n nonce\n })\n }\n\n // Get user info\n const userInfo = await oidcClient.getUserInfo(\n tokens.access_token,\n discovery.userinfo_endpoint\n )\n\n return {\n providerUserId: userInfo.sub,\n email: userInfo.email || null,\n name: userInfo.name || userInfo.preferred_username || null,\n raw: userInfo as unknown as Record<string, unknown>\n }\n }\n }\n}\n","/**\n * Microsoft Auth Provider\n *\n * Azure AD / Microsoft Entra ID via OIDC with tenant-aware discovery.\n * Supports single-tenant, multi-tenant, and B2C scenarios.\n */\nimport {\n createAuthConfigModule,\n createAuthModule\n} from '../../shared/index.js'\nimport { createMicrosoftAdapter } from './adapter.js'\n\n// ============================================================================\n// MODULES (generated by factories)\n// ============================================================================\n\nexport const configModule = createAuthConfigModule({\n name: 'microsoft_auth_config',\n label: { en: 'Microsoft Auth Config', es: 'Configuración Microsoft Auth' },\n provider: 'microsoft',\n envPrefix: 'MICROSOFT',\n defaultScopes: 'openid profile email',\n defaultRole: 'VIEWER'\n})\n\nexport const authModule = createAuthModule({\n name: 'microsoft_auth',\n label: { en: 'Microsoft Auth', es: 'Auth Microsoft' },\n configDependency: 'microsoft_auth_config',\n provider: 'microsoft',\n caslSubject: 'MicrosoftAuth',\n providerInfo: {\n code: 'MICROSOFT_AUTH',\n provider: 'microsoft',\n icon: 'mdi:microsoft',\n label: { en: 'Sign in with Microsoft', es: 'Iniciar sesión con Microsoft' },\n color: '#00A4EF'\n },\n createAdapter: createMicrosoftAdapter\n})\n","/**\n * PocketID OIDC Adapter\n *\n * Provider-specific logic for PocketID authentication.\n * Differs from Google in that the issuer URL is dynamic (from config).\n */\nimport type { ModuleContext } from '@gzl10/nexus-sdk'\nimport {\n getOidcClient,\n type OidcDiscoveryDocument\n} from '@gzl10/nexus-sdk'\nimport type {\n AuthPluginAdapter,\n AuthPluginBaseConfig,\n BuildAuthUrlParams,\n AuthPluginUserInfo\n} from '../../shared/index.js'\n\n// ============================================================================\n// CONFIG TYPE\n// ============================================================================\n\nexport interface PocketIdAuthConfig extends AuthPluginBaseConfig {\n /** Provider-specific: extra_config JSON with issuer_url */\n extra_config: string | null\n}\n\ninterface PocketIdExtraConfig {\n issuer_url?: string | null\n}\n\n// ============================================================================\n// ADAPTER\n// ============================================================================\n\nexport function createPocketIdAdapter(ctx: ModuleContext): AuthPluginAdapter<PocketIdAuthConfig> {\n const { errors } = ctx.core\n const oidcClient = getOidcClient()\n\n // Discovery cache (1 hour)\n let discoveryDoc: OidcDiscoveryDocument | null = null\n let discoveryExpires = 0\n\n function parseExtraConfig(config: PocketIdAuthConfig): PocketIdExtraConfig {\n if (!config.extra_config) return {}\n try {\n return typeof config.extra_config === 'string'\n ? JSON.parse(config.extra_config) as PocketIdExtraConfig\n : config.extra_config as unknown as PocketIdExtraConfig\n } catch {\n return {}\n }\n }\n\n function getIssuerUrl(config: PocketIdAuthConfig): string {\n // Check extra_config first, then fall back to POCKETID_URL env var\n const extra = parseExtraConfig(config)\n const issuerUrl = extra.issuer_url || process.env['POCKETID_URL']\n if (!issuerUrl) {\n throw new errors.ForbiddenError('PocketID issuer URL is not configured')\n }\n return issuerUrl\n }\n\n async function getDiscovery(config: PocketIdAuthConfig): Promise<OidcDiscoveryDocument> {\n const issuerUrl = getIssuerUrl(config)\n const now = Date.now()\n if (discoveryDoc && discoveryExpires > now) {\n return discoveryDoc\n }\n discoveryDoc = await oidcClient.discover(issuerUrl)\n discoveryExpires = now + 3600000\n return discoveryDoc\n }\n\n return {\n provider: 'pocketid',\n\n async getValidConfig(): Promise<PocketIdAuthConfig> {\n const configService = ctx.services.get<{ getConfig(): Promise<PocketIdAuthConfig | null> }>('pocketid.config')\n const config = await configService.getConfig()\n\n if (!config?.enabled) {\n throw new errors.ForbiddenError('PocketID authentication is disabled')\n }\n if (!config.client_id || !config.client_secret) {\n throw new errors.ForbiddenError('PocketID is not fully configured')\n }\n // Validate issuer URL is available\n getIssuerUrl(config)\n return config\n },\n\n async buildAuthorizationUrl(config: PocketIdAuthConfig, params: BuildAuthUrlParams): Promise<string> {\n const discovery = await getDiscovery(config)\n\n return oidcClient.buildAuthorizationUrl(discovery.authorization_endpoint, {\n clientId: config.client_id,\n redirectUri: params.redirectUri,\n scopes: params.scopes,\n state: params.state,\n nonce: params.nonce\n })\n },\n\n async exchangeCodeAndGetUserInfo(\n config: PocketIdAuthConfig,\n code: string,\n redirectUri: string,\n nonce: string\n ): Promise<AuthPluginUserInfo> {\n const discovery = await getDiscovery(config)\n\n // Exchange code for tokens\n const tokens = await oidcClient.exchangeCode({\n tokenEndpoint: discovery.token_endpoint,\n clientId: config.client_id,\n clientSecret: config.client_secret,\n code,\n redirectUri\n })\n\n // Validate ID token\n if (tokens.id_token) {\n await oidcClient.validateIdToken(tokens.id_token, {\n jwksUri: discovery.jwks_uri,\n issuer: discovery.issuer,\n clientId: config.client_id,\n nonce\n })\n }\n\n // Get user info\n const userInfo = await oidcClient.getUserInfo(\n tokens.access_token,\n discovery.userinfo_endpoint\n )\n\n return {\n providerUserId: userInfo.sub,\n email: userInfo.email || null,\n name: userInfo.name || userInfo.preferred_username || null,\n raw: userInfo as unknown as Record<string, unknown>\n }\n }\n }\n}\n","import {\n createAuthConfigModule,\n createAuthModule\n} from '../../shared/index.js'\nimport { createPocketIdAdapter } from './adapter.js'\n\n// ============================================================================\n// MODULES (generated by factories)\n// ============================================================================\n\nexport const configModule = createAuthConfigModule({\n name: 'pocketid_config',\n label: { en: 'PocketID Config', es: 'Configuración PocketID' },\n provider: 'pocketid',\n envPrefix: 'POCKETID',\n defaultScopes: 'openid profile email',\n defaultRole: 'VIEWER',\n extraConfig: { issuer_url: process.env['POCKETID_URL'] || null }\n})\n\nexport const authModule = createAuthModule({\n name: 'pocketid_auth',\n label: { en: 'PocketID Auth', es: 'Auth PocketID' },\n configDependency: 'pocketid_config',\n provider: 'pocketid',\n caslSubject: 'PocketIdAuth',\n providerInfo: {\n code: 'POCKETID_AUTH',\n provider: 'pocketid',\n icon: 'mdi:key-chain',\n label: { en: 'Sign in with PocketID', es: 'Iniciar sesión con PocketID' },\n color: '#7c3aed'\n },\n createAdapter: createPocketIdAdapter\n})\n\n// ============================================================================\n// EXPORTS\n// ============================================================================\n\nexport { createPocketIdAdapter } from './adapter.js'\nexport type { PocketIdAuthConfig } from './adapter.js'\n","/**\n * Generic OIDC Adapter\n *\n * Works with any OpenID Connect compliant identity provider.\n * Issuer URL is configured via OIDC_ISSUER_URL env var or admin panel.\n */\nimport type { ModuleContext } from '@gzl10/nexus-sdk'\nimport {\n getOidcClient,\n type OidcDiscoveryDocument\n} from '@gzl10/nexus-sdk'\nimport type {\n AuthPluginAdapter,\n AuthPluginBaseConfig,\n BuildAuthUrlParams,\n AuthPluginUserInfo\n} from '../../shared/index.js'\n\n// ============================================================================\n// CONFIG TYPE\n// ============================================================================\n\nexport interface GenericOidcConfig extends AuthPluginBaseConfig {\n /** Provider-specific: extra_config JSON with issuer_url */\n extra_config: string | null\n}\n\ninterface OidcExtraConfig {\n issuer_url?: string | null\n}\n\n// ============================================================================\n// ADAPTER\n// ============================================================================\n\nexport function createOidcAdapter(ctx: ModuleContext): AuthPluginAdapter<GenericOidcConfig> {\n const { errors } = ctx.core\n const oidcClient = getOidcClient()\n\n // Discovery cache (1 hour per issuer)\n const discoveryCache = new Map<string, { doc: OidcDiscoveryDocument; expiresAt: number }>()\n const CACHE_TTL = 3600000 // 1 hour in ms\n\n function getIssuerUrl(config: GenericOidcConfig): string {\n const extra = parseExtraConfig(config)\n const url = extra.issuer_url || process.env['OIDC_ISSUER_URL']\n\n if (!url) {\n throw new errors.ForbiddenError('OIDC issuer URL is required (set OIDC_ISSUER_URL env var or configure issuer_url in admin)')\n }\n\n return url.replace(/\\/$/, '') // Remove trailing slash\n }\n\n function parseExtraConfig(config: GenericOidcConfig): OidcExtraConfig {\n if (!config.extra_config) return {}\n try {\n return typeof config.extra_config === 'string'\n ? JSON.parse(config.extra_config) as OidcExtraConfig\n : config.extra_config as unknown as OidcExtraConfig\n } catch {\n return {}\n }\n }\n\n async function getDiscovery(issuerUrl: string): Promise<OidcDiscoveryDocument> {\n const now = Date.now()\n const cached = discoveryCache.get(issuerUrl)\n\n if (cached && cached.expiresAt > now) {\n return cached.doc\n }\n\n const doc = await oidcClient.discover(issuerUrl)\n discoveryCache.set(issuerUrl, { doc, expiresAt: now + CACHE_TTL })\n\n return doc\n }\n\n return {\n provider: 'oidc',\n\n async getValidConfig(): Promise<GenericOidcConfig> {\n const configService = ctx.services.get<{ getConfig(): Promise<GenericOidcConfig | null> }>('oidc.config')\n const config = await configService.getConfig()\n\n if (!config?.enabled) {\n throw new errors.ForbiddenError('OIDC authentication is disabled')\n }\n if (!config.client_id || !config.client_secret) {\n throw new errors.ForbiddenError('OIDC Auth is not fully configured')\n }\n // Validate issuer URL can be resolved\n getIssuerUrl(config)\n return config\n },\n\n async buildAuthorizationUrl(config: GenericOidcConfig, params: BuildAuthUrlParams): Promise<string> {\n const issuerUrl = getIssuerUrl(config)\n const discovery = await getDiscovery(issuerUrl)\n\n return oidcClient.buildAuthorizationUrl(discovery.authorization_endpoint, {\n clientId: config.client_id,\n redirectUri: params.redirectUri,\n scopes: params.scopes,\n state: params.state,\n nonce: params.nonce\n })\n },\n\n async exchangeCodeAndGetUserInfo(\n config: GenericOidcConfig,\n code: string,\n redirectUri: string,\n nonce: string\n ): Promise<AuthPluginUserInfo> {\n const issuerUrl = getIssuerUrl(config)\n const discovery = await getDiscovery(issuerUrl)\n\n // Exchange code for tokens\n const tokens = await oidcClient.exchangeCode({\n tokenEndpoint: discovery.token_endpoint,\n clientId: config.client_id,\n clientSecret: config.client_secret,\n code,\n redirectUri\n })\n\n // Validate ID token\n if (tokens.id_token) {\n await oidcClient.validateIdToken(tokens.id_token, {\n jwksUri: discovery.jwks_uri,\n issuer: discovery.issuer,\n clientId: config.client_id,\n nonce\n })\n }\n\n // Get user info\n const userInfo = await oidcClient.getUserInfo(\n tokens.access_token,\n discovery.userinfo_endpoint\n )\n\n return {\n providerUserId: userInfo.sub,\n email: userInfo.email || null,\n name: userInfo.name || userInfo.preferred_username || null,\n raw: userInfo as unknown as Record<string, unknown>\n }\n }\n }\n}\n","/**\n * Generic OIDC Provider\n *\n * Works with any OpenID Connect compliant identity provider\n * (Keycloak, Authentik, Authelia, Zitadel, etc.).\n *\n * Configure via OIDC_ISSUER_URL environment variable or admin panel.\n */\nimport {\n createAuthConfigModule,\n createAuthModule\n} from '../../shared/index.js'\nimport { createOidcAdapter } from './adapter.js'\n\n// ============================================================================\n// MODULES (generated by factories)\n// ============================================================================\n\nexport const configModule = createAuthConfigModule({\n name: 'oidc_auth_config',\n label: { en: 'Generic OIDC Auth Config', es: 'Configuración Auth OIDC Genérico' },\n provider: 'oidc',\n envPrefix: 'OIDC',\n defaultScopes: 'openid profile email',\n defaultRole: 'VIEWER'\n})\n\nexport const authModule = createAuthModule({\n name: 'oidc_auth',\n label: { en: 'Generic OIDC Auth', es: 'Auth OIDC Genérico' },\n configDependency: 'oidc_auth_config',\n provider: 'oidc',\n caslSubject: 'OidcAuth',\n providerInfo: {\n code: 'OIDC_AUTH',\n provider: 'oidc',\n icon: 'mdi:shield-key',\n label: { en: 'Sign in with SSO', es: 'Iniciar sesión con SSO' },\n color: '#6366F1'\n },\n createAdapter: createOidcAdapter\n})\n"],"mappings":";;;;;;;AAcA,SAAS,oBAAoB;AAC7B,SAAS,YAAY;;;ACPrB;AAAA,EACE;AAAA,OAEK;AAyBP,IAAM,gBAAgB;AAEf,SAAS,oBAAoB,KAAyD;AAC3F,QAAM,EAAE,OAAO,IAAI,IAAI;AACvB,QAAM,aAAa,cAAc;AAGjC,MAAI,eAA6C;AACjD,MAAI,mBAAmB;AAEvB,iBAAe,eAA+C;AAC5D,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,gBAAgB,mBAAmB,KAAK;AAC1C,aAAO;AAAA,IACT;AACA,mBAAe,MAAM,WAAW,SAAS,aAAa;AACtD,uBAAmB,MAAM;AACzB,WAAO;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,IAAI,0BAA0B;AAAA,EACpE,MAAM;AAAA,EACN,aAAa,CAAC,yBAAyB;AACzC;AAEA,IAAM,gBAAgB,gBAAgB,SAAS,IAC3C,CAAC,YAAY,GAAG,eAAe,IAC/B,CAAC;AAME,IAAM,sBAAsC;AAAA,EACjD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS,IAAI;AAAA,EACb,OAAO,EAAE,IAAI,kBAAkB,IAAI,sBAAsB;AAAA,EACzD,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,IACX,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EACA,SAAS;AAAA,EACT,SAAS;AACX;AAEA,IAAO,gBAAQ;","names":["configModule","authModule","ofetch","configModule","authModule","getOidcClient","configModule","authModule","getOidcClient","configModule","authModule","getOidcClient","configModule","authModule","configModule","authModule"]}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { OidcState, SessionResult, ModuleContext, ActionDefinition, SingleEntityDefinition, LocalizedString, ModuleManifest, AuthProviderInfo } from '@gzl10/nexus-sdk';
|
|
2
|
+
import { Request } from 'express';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Auth Plugin Base Types
|
|
6
|
+
*
|
|
7
|
+
* Shared types for OAuth/OIDC authentication plugins.
|
|
8
|
+
* Eliminates duplication across google-auth, pocketid, github-auth plugins.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Extended OAuth state with returnUrl for post-auth frontend redirects.
|
|
13
|
+
* Used by all auth plugins regardless of protocol (OIDC or OAuth 2.0).
|
|
14
|
+
*/
|
|
15
|
+
interface AuthPluginState extends OidcState {
|
|
16
|
+
/** Frontend URL to redirect user after auth completes */
|
|
17
|
+
returnUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Session result with optional redirect URL.
|
|
21
|
+
* Returned by handleCallback after successful authentication.
|
|
22
|
+
*/
|
|
23
|
+
interface AuthPluginSessionResult extends SessionResult {
|
|
24
|
+
/** Frontend URL to redirect user after auth (server-side flow) */
|
|
25
|
+
returnUrl?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Subset of core AuthService used by auth plugins.
|
|
29
|
+
* Registered as `ctx.services.get('auth')` by nexus-backend.
|
|
30
|
+
*
|
|
31
|
+
* Auth plugins use this interface to:
|
|
32
|
+
* - Find/create users
|
|
33
|
+
* - Link/unlink external identities
|
|
34
|
+
* - Create session tokens
|
|
35
|
+
*/
|
|
36
|
+
interface CoreAuthService {
|
|
37
|
+
findUserById(id: string): Promise<{
|
|
38
|
+
id: string;
|
|
39
|
+
email: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
} | null>;
|
|
42
|
+
findUserByEmail(email: string): Promise<{
|
|
43
|
+
id: string;
|
|
44
|
+
email: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
} | null>;
|
|
47
|
+
createUser(data: {
|
|
48
|
+
email: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
role?: string;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
id: string;
|
|
53
|
+
email: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
}>;
|
|
56
|
+
createTokens(user: {
|
|
57
|
+
id: string;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
accessToken: string;
|
|
60
|
+
refreshToken: string;
|
|
61
|
+
expiresIn: number;
|
|
62
|
+
}>;
|
|
63
|
+
findIdentity(provider: string, providerUserId: string): Promise<AuthIdentity | undefined>;
|
|
64
|
+
findIdentitiesByUser(userId: string, provider?: string): Promise<AuthIdentity[]>;
|
|
65
|
+
linkIdentity(input: LinkIdentityInput): Promise<AuthIdentity>;
|
|
66
|
+
unlinkIdentity(provider: string, providerUserId: string): Promise<boolean>;
|
|
67
|
+
updateIdentityLogin(provider: string, providerUserId: string): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* External auth identity (mirrors core auth_identities table)
|
|
71
|
+
*/
|
|
72
|
+
interface AuthIdentity {
|
|
73
|
+
id: string;
|
|
74
|
+
user_id: string;
|
|
75
|
+
provider: string;
|
|
76
|
+
provider_user_id: string;
|
|
77
|
+
provider_email: string | null;
|
|
78
|
+
metadata: Record<string, unknown> | null;
|
|
79
|
+
linked_at: string;
|
|
80
|
+
last_login_at: string | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Input for linking an external identity to a Nexus user
|
|
84
|
+
*/
|
|
85
|
+
interface LinkIdentityInput {
|
|
86
|
+
userId: string;
|
|
87
|
+
provider: string;
|
|
88
|
+
providerUserId: string;
|
|
89
|
+
providerEmail?: string | null;
|
|
90
|
+
metadata?: Record<string, unknown>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Normalized user info from any OAuth/OIDC provider.
|
|
94
|
+
* Adapters map provider-specific responses to this common shape.
|
|
95
|
+
*
|
|
96
|
+
* @example Google/PocketID (OIDC)
|
|
97
|
+
* { providerUserId: userInfo.sub, email: userInfo.email, name: userInfo.name }
|
|
98
|
+
*
|
|
99
|
+
* @example GitHub (OAuth 2.0)
|
|
100
|
+
* { providerUserId: String(user.id), email: user.email, name: user.name || user.login }
|
|
101
|
+
*/
|
|
102
|
+
interface AuthPluginUserInfo {
|
|
103
|
+
/** Provider's user ID (OIDC `sub` or GitHub `id.toString()`) */
|
|
104
|
+
providerUserId: string;
|
|
105
|
+
/** User's email (may be null if not public/granted) */
|
|
106
|
+
email: string | null;
|
|
107
|
+
/** User's display name */
|
|
108
|
+
name: string | null;
|
|
109
|
+
/** Raw provider response for metadata storage */
|
|
110
|
+
raw: Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Config service interface for auth plugins.
|
|
114
|
+
* Created by `createAuthConfigModule()`.
|
|
115
|
+
*/
|
|
116
|
+
interface AuthPluginConfigService<TConfig = unknown> {
|
|
117
|
+
getConfig(): Promise<TConfig | null>;
|
|
118
|
+
isEnabled(): Promise<boolean>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Auth Plugin Adapter Interface
|
|
123
|
+
*
|
|
124
|
+
* Strategy pattern: each auth plugin implements this interface
|
|
125
|
+
* to handle provider-specific OAuth/OIDC details.
|
|
126
|
+
*
|
|
127
|
+
* The base service (`createAuthPluginService`) handles all shared logic
|
|
128
|
+
* (state management, identity resolution, session creation) and delegates
|
|
129
|
+
* provider-specific operations to the adapter.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Base configuration shared by all auth plugins.
|
|
134
|
+
* Plugins can extend this with provider-specific fields
|
|
135
|
+
* (e.g., `hosted_domain` for Google, `issuer_url` for PocketID).
|
|
136
|
+
*/
|
|
137
|
+
interface AuthPluginBaseConfig {
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
client_id: string;
|
|
140
|
+
client_secret: string;
|
|
141
|
+
scopes: string;
|
|
142
|
+
allowed_domains: string | null;
|
|
143
|
+
default_role: string;
|
|
144
|
+
}
|
|
145
|
+
/** Parameters for building the authorization URL */
|
|
146
|
+
interface BuildAuthUrlParams {
|
|
147
|
+
redirectUri: string;
|
|
148
|
+
state: string;
|
|
149
|
+
nonce: string;
|
|
150
|
+
scopes: string[];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Adapter that each auth plugin must implement.
|
|
154
|
+
*
|
|
155
|
+
* @example OIDC adapter (Google, PocketID)
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const adapter: AuthPluginAdapter<GoogleConfig> = {
|
|
158
|
+
* provider: 'google',
|
|
159
|
+
* getValidConfig: () => configService.getConfig(),
|
|
160
|
+
* buildAuthorizationUrl: (config, params) => oidcClient.buildAuthorizationUrl(...),
|
|
161
|
+
* exchangeCodeAndGetUserInfo: async (config, code, redirectUri, nonce) => {
|
|
162
|
+
* const tokens = await oidcClient.exchangeCode(...)
|
|
163
|
+
* const userInfo = await oidcClient.getUserInfo(...)
|
|
164
|
+
* return { providerUserId: userInfo.sub, email: userInfo.email, ... }
|
|
165
|
+
* }
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @example OAuth 2.0 adapter (GitHub)
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const adapter: AuthPluginAdapter<GitHubConfig> = {
|
|
172
|
+
* provider: 'github',
|
|
173
|
+
* getValidConfig: () => configService.getConfig(),
|
|
174
|
+
* buildAuthorizationUrl: (config, params) => {
|
|
175
|
+
* return `https://github.com/login/oauth/authorize?${new URLSearchParams(...)}`
|
|
176
|
+
* },
|
|
177
|
+
* exchangeCodeAndGetUserInfo: async (config, code, redirectUri) => {
|
|
178
|
+
* const token = await ofetch(GITHUB_TOKEN_URL, ...)
|
|
179
|
+
* const user = await ofetch(GITHUB_USER_URL, ...)
|
|
180
|
+
* return { providerUserId: String(user.id), email: user.email, ... }
|
|
181
|
+
* }
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
interface AuthPluginAdapter<TConfig extends AuthPluginBaseConfig = AuthPluginBaseConfig> {
|
|
186
|
+
/** Provider identifier (e.g., 'google', 'github', 'pocketid') */
|
|
187
|
+
provider: string;
|
|
188
|
+
/** Get validated config or throw ForbiddenError if disabled/misconfigured */
|
|
189
|
+
getValidConfig(): Promise<TConfig>;
|
|
190
|
+
/** Build the provider's authorization URL */
|
|
191
|
+
buildAuthorizationUrl(config: TConfig, params: BuildAuthUrlParams): Promise<string>;
|
|
192
|
+
/**
|
|
193
|
+
* Exchange authorization code for user info.
|
|
194
|
+
* Handles the full token exchange + user info retrieval.
|
|
195
|
+
*
|
|
196
|
+
* For OIDC: exchange code, validate ID token, get userinfo
|
|
197
|
+
* For OAuth 2.0: exchange code, call user API
|
|
198
|
+
*
|
|
199
|
+
* @param config - Validated provider config
|
|
200
|
+
* @param code - Authorization code from callback
|
|
201
|
+
* @param redirectUri - Redirect URI used in authorization request
|
|
202
|
+
* @param nonce - Nonce for OIDC ID token validation (empty string for OAuth 2.0)
|
|
203
|
+
*/
|
|
204
|
+
exchangeCodeAndGetUserInfo(config: TConfig, code: string, redirectUri: string, nonce: string): Promise<AuthPluginUserInfo>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Auth plugin service returned by `createAuthPluginService()`.
|
|
209
|
+
* All auth plugins expose this same interface.
|
|
210
|
+
*/
|
|
211
|
+
interface AuthPluginService {
|
|
212
|
+
/** Generate authorization URL and redirect state */
|
|
213
|
+
getAuthorizationUrl(redirectUri: string, linkUserId?: string, returnUrl?: string): Promise<{
|
|
214
|
+
url: string;
|
|
215
|
+
state: string;
|
|
216
|
+
}>;
|
|
217
|
+
/** Handle OAuth/OIDC callback after provider redirect */
|
|
218
|
+
handleCallback(code: string, state: string): Promise<AuthPluginSessionResult>;
|
|
219
|
+
/** Verify state is valid (non-destructive peek) */
|
|
220
|
+
verifyState(state: string): Promise<AuthPluginState | null>;
|
|
221
|
+
/** Clear state after use */
|
|
222
|
+
clearState(state: string): Promise<void>;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Build the backend's callback URL from the request.
|
|
226
|
+
* Supports BACKEND_URL env var override (consistent across all plugins).
|
|
227
|
+
*/
|
|
228
|
+
declare function buildCallbackUrl(moduleName: string, req?: Request): string;
|
|
229
|
+
/**
|
|
230
|
+
* Create an auth plugin service from an adapter.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const service = createAuthPluginService({
|
|
235
|
+
* adapter: createGoogleAdapter(ctx),
|
|
236
|
+
* ctx
|
|
237
|
+
* })
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
declare function createAuthPluginService<TConfig extends AuthPluginBaseConfig>(options: {
|
|
241
|
+
adapter: AuthPluginAdapter<TConfig>;
|
|
242
|
+
ctx: ModuleContext;
|
|
243
|
+
}): AuthPluginService;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Auth Plugin Controller Factory
|
|
247
|
+
*
|
|
248
|
+
* Generates the 4 standard action definitions that every auth plugin needs:
|
|
249
|
+
* - authorize: Start OAuth/OIDC flow (GET, skipAuth)
|
|
250
|
+
* - callback: Handle provider callback (GET, skipAuth)
|
|
251
|
+
* - link: Link existing account (GET, requires auth)
|
|
252
|
+
* - status: Check if provider is linked (GET, requires auth)
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
interface AuthControllerOptions {
|
|
256
|
+
/** Provider identifier (e.g., 'google', 'github') */
|
|
257
|
+
provider: string;
|
|
258
|
+
/** Module name for URL paths (e.g., 'google_auth') */
|
|
259
|
+
moduleName: string;
|
|
260
|
+
/** CASL subject for permissions (e.g., 'GoogleAuth') */
|
|
261
|
+
caslSubject: string;
|
|
262
|
+
/** Additional friendly error messages for the callback handler */
|
|
263
|
+
friendlyErrors?: Record<string, string>;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Create the 4 standard auth plugin actions.
|
|
267
|
+
*
|
|
268
|
+
* @param options - Controller configuration
|
|
269
|
+
* @param getAuthService - Getter for the auth plugin service (deferred to avoid init order issues)
|
|
270
|
+
*/
|
|
271
|
+
declare function createAuthPluginActions(options: AuthControllerOptions, getAuthService: () => AuthPluginService): ActionDefinition[];
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Unified Auth Providers Config Entity
|
|
275
|
+
*
|
|
276
|
+
* Single table `auth_providers_config` with one row per provider.
|
|
277
|
+
* Replaces separate tables (google_auth_config, pocketid_config, github_auth_config).
|
|
278
|
+
*
|
|
279
|
+
* Provider-specific fields (hosted_domain, issuer_url) go in `extra_config` JSON.
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Unified config entity for all auth providers.
|
|
284
|
+
*
|
|
285
|
+
* Each provider gets one row, identified by the `provider` column.
|
|
286
|
+
* The `scopeField: 'provider'` makes each provider a separate "scope",
|
|
287
|
+
* so the config UI shows each provider's settings independently.
|
|
288
|
+
*
|
|
289
|
+
* Usage: Include this entity in the core auth module's definitions.
|
|
290
|
+
*
|
|
291
|
+
* @example Backend auth module
|
|
292
|
+
* ```typescript
|
|
293
|
+
* import { authProvidersConfigEntity } from '@gzl10/nexus-sdk'
|
|
294
|
+
*
|
|
295
|
+
* export const authModule: ModuleManifest = {
|
|
296
|
+
* definitions: [..., authProvidersConfigEntity],
|
|
297
|
+
* }
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
declare const authProvidersConfigEntity: SingleEntityDefinition;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Auth Config Module Factory
|
|
304
|
+
*
|
|
305
|
+
* Creates a module that seeds the provider's row in the unified
|
|
306
|
+
* `auth_providers_config` table and registers a config service.
|
|
307
|
+
*
|
|
308
|
+
* The entity itself is registered by the core auth module.
|
|
309
|
+
* This module only handles seeding + config service registration.
|
|
310
|
+
*/
|
|
311
|
+
|
|
312
|
+
interface AuthConfigModuleOptions {
|
|
313
|
+
/** Module name (e.g., 'google_auth_config') */
|
|
314
|
+
name: string;
|
|
315
|
+
/** Module label */
|
|
316
|
+
label: LocalizedString;
|
|
317
|
+
/** Provider identifier (e.g., 'google', 'github', 'pocketid') */
|
|
318
|
+
provider: string;
|
|
319
|
+
/** Environment variable prefix (e.g., 'GOOGLE' reads GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET) */
|
|
320
|
+
envPrefix: string;
|
|
321
|
+
/** Default scopes for this provider */
|
|
322
|
+
defaultScopes: string;
|
|
323
|
+
/** Default role for new users (default: 'USER') */
|
|
324
|
+
defaultRole?: string;
|
|
325
|
+
/** Extra config values for the seed (e.g., { issuer_url: '...' }) */
|
|
326
|
+
extraConfig?: Record<string, unknown>;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Create the config module for an auth plugin.
|
|
330
|
+
*
|
|
331
|
+
* This module:
|
|
332
|
+
* 1. Seeds the provider's row from environment variables
|
|
333
|
+
* 2. Registers a config service scoped to this provider
|
|
334
|
+
*
|
|
335
|
+
* Note: The `auth_providers_config` entity is registered by the core auth module.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* const configModule = createAuthConfigModule({
|
|
340
|
+
* name: 'google_auth_config',
|
|
341
|
+
* label: { en: 'Google Auth Config' },
|
|
342
|
+
* provider: 'google',
|
|
343
|
+
* envPrefix: 'GOOGLE',
|
|
344
|
+
* defaultScopes: 'openid profile email',
|
|
345
|
+
* extraConfig: { hosted_domain: null }
|
|
346
|
+
* })
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function createAuthConfigModule(options: AuthConfigModuleOptions): ModuleManifest;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Auth Module Factory
|
|
353
|
+
*
|
|
354
|
+
* Creates the complete auth module for a plugin, including:
|
|
355
|
+
* - Auth plugin service (state management, identity resolution, session creation)
|
|
356
|
+
* - Auth controller (4 actions: authorize, callback, link, status)
|
|
357
|
+
* - AuthProviderService registration (for dynamic login buttons in UI)
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
interface AuthModuleOptions<TConfig extends AuthPluginBaseConfig = AuthPluginBaseConfig> {
|
|
361
|
+
/** Module name (e.g., 'google_auth') */
|
|
362
|
+
name: string;
|
|
363
|
+
/** Module label */
|
|
364
|
+
label: LocalizedString;
|
|
365
|
+
/** Config module dependency name (e.g., 'google_auth_config') */
|
|
366
|
+
configDependency: string;
|
|
367
|
+
/** Provider identifier (e.g., 'google') */
|
|
368
|
+
provider: string;
|
|
369
|
+
/** CASL subject for permissions (e.g., 'GoogleAuth') */
|
|
370
|
+
caslSubject: string;
|
|
371
|
+
/** Provider info for the dynamic login button (icon, color, label) */
|
|
372
|
+
providerInfo: Omit<AuthProviderInfo, 'authorizeEndpoint'>;
|
|
373
|
+
/** Factory function to create the provider-specific adapter */
|
|
374
|
+
createAdapter: (ctx: ModuleContext) => AuthPluginAdapter<TConfig>;
|
|
375
|
+
/** Additional friendly error messages for the callback */
|
|
376
|
+
friendlyErrors?: Record<string, string>;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Create the auth module for a plugin.
|
|
380
|
+
*
|
|
381
|
+
* @example Google Auth
|
|
382
|
+
* ```typescript
|
|
383
|
+
* const authModule = createAuthModule({
|
|
384
|
+
* name: 'google_auth',
|
|
385
|
+
* label: { en: 'Google Auth' },
|
|
386
|
+
* configDependency: 'google_auth_config',
|
|
387
|
+
* provider: 'google',
|
|
388
|
+
* caslSubject: 'GoogleAuth',
|
|
389
|
+
* providerInfo: {
|
|
390
|
+
* code: 'GOOGLE_AUTH',
|
|
391
|
+
* provider: 'google',
|
|
392
|
+
* icon: 'mdi:google',
|
|
393
|
+
* label: { en: 'Sign in with Google' },
|
|
394
|
+
* color: '#4285F4'
|
|
395
|
+
* },
|
|
396
|
+
* createAdapter: createGoogleAdapter
|
|
397
|
+
* })
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
declare function createAuthModule<TConfig extends AuthPluginBaseConfig = AuthPluginBaseConfig>(options: AuthModuleOptions<TConfig>): ModuleManifest;
|
|
401
|
+
|
|
402
|
+
export { type AuthConfigModuleOptions, type AuthControllerOptions, type AuthIdentity, type AuthModuleOptions, type AuthPluginAdapter, type AuthPluginBaseConfig, type AuthPluginConfigService, type AuthPluginService, type AuthPluginSessionResult, type AuthPluginState, type AuthPluginUserInfo, type BuildAuthUrlParams, type CoreAuthService, type LinkIdentityInput, authProvidersConfigEntity, buildCallbackUrl, createAuthConfigModule, createAuthModule, createAuthPluginActions, createAuthPluginService };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
authProvidersConfigEntity,
|
|
3
|
+
buildCallbackUrl,
|
|
4
|
+
createAuthConfigModule,
|
|
5
|
+
createAuthModule,
|
|
6
|
+
createAuthPluginActions,
|
|
7
|
+
createAuthPluginService
|
|
8
|
+
} from "../chunk-TPBCCFGG.js";
|
|
9
|
+
export {
|
|
10
|
+
authProvidersConfigEntity,
|
|
11
|
+
buildCallbackUrl,
|
|
12
|
+
createAuthConfigModule,
|
|
13
|
+
createAuthModule,
|
|
14
|
+
createAuthPluginActions,
|
|
15
|
+
createAuthPluginService
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/image.png
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gzl10/nexus-plugin-auth-providers",
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Consolidated auth providers plugin for Nexus BaaS (Google, GitHub, GitLab, Microsoft, PocketID, Generic OIDC)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./shared": {
|
|
13
|
+
"import": "./dist/shared/index.js",
|
|
14
|
+
"types": "./dist/shared/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"image.png"
|
|
20
|
+
],
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@gzl10/nexus-sdk": ">=0.14.0",
|
|
23
|
+
"express": "^5.0.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependenciesMeta": {
|
|
26
|
+
"express": {
|
|
27
|
+
"optional": true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"ofetch": "^1.4.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@gzl10/nexus-sdk": "0.15.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"lint": "eslint .",
|
|
39
|
+
"test": "vitest run --passWithNoTests",
|
|
40
|
+
"typecheck": "tsc --noEmit"
|
|
41
|
+
}
|
|
42
|
+
}
|