From f1919c1ed9d617b68ef23225c9c33bf3a71d7f36 Mon Sep 17 00:00:00 2001 From: flyinghermit Date: Tue, 2 Jul 2024 11:12:15 -0400 Subject: [PATCH 1/2] process SAML IdP service provider preset in app type --- web/packages/teleport/src/Discover/SelectResource/types.ts | 3 ++- web/packages/teleport/src/services/apps/apps.test.ts | 5 +++++ web/packages/teleport/src/services/apps/makeApps.ts | 6 ++++++ web/packages/teleport/src/services/apps/types.ts | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/web/packages/teleport/src/Discover/SelectResource/types.ts b/web/packages/teleport/src/Discover/SelectResource/types.ts index cce21de26d7f1..7abe35622f901 100644 --- a/web/packages/teleport/src/Discover/SelectResource/types.ts +++ b/web/packages/teleport/src/Discover/SelectResource/types.ts @@ -69,7 +69,8 @@ export enum KubeLocation { Aws, } -/** SamlServiceProviderPreset defines SAML service provider preset types. +/** + * SamlServiceProviderPreset defines SAML service provider preset types. * Used to define custom or pre-defined configuration flow. */ export enum SamlServiceProviderPreset { diff --git a/web/packages/teleport/src/services/apps/apps.test.ts b/web/packages/teleport/src/services/apps/apps.test.ts index f393341102201..689f8a7887f6c 100644 --- a/web/packages/teleport/src/services/apps/apps.test.ts +++ b/web/packages/teleport/src/services/apps/apps.test.ts @@ -47,6 +47,7 @@ test('correct formatting of apps fetch response', async () => { userGroups: [], samlApp: false, samlAppSsoUrl: '', + samlAppPreset: 'unspecified', integration: '', }, { @@ -68,6 +69,7 @@ test('correct formatting of apps fetch response', async () => { userGroups: [], samlApp: false, samlAppSsoUrl: '', + samlAppPreset: 'unspecified', integration: '', }, { @@ -89,6 +91,7 @@ test('correct formatting of apps fetch response', async () => { userGroups: [], samlApp: false, samlAppSsoUrl: '', + samlAppPreset: 'unspecified', integration: '', }, { @@ -110,6 +113,7 @@ test('correct formatting of apps fetch response', async () => { userGroups: [], samlApp: true, samlAppSsoUrl: 'http://localhost/enterprise/saml-idp/login/saml-app', + samlAppPreset: 'gcp-workforce', integration: '', }, ], @@ -168,6 +172,7 @@ const mockResponse = { name: 'saml-app', description: 'SAML Application', samlApp: true, + samlAppPreset: 'gcp-workforce', }, ], startKey: 'mockKey', diff --git a/web/packages/teleport/src/services/apps/makeApps.ts b/web/packages/teleport/src/services/apps/makeApps.ts index 6b220809bb2b9..9356aad271eb6 100644 --- a/web/packages/teleport/src/services/apps/makeApps.ts +++ b/web/packages/teleport/src/services/apps/makeApps.ts @@ -20,6 +20,8 @@ import { AwsRole } from 'shared/services/apps'; import cfg from 'teleport/config'; +import { SamlServiceProviderPreset } from 'teleport/Discover/SelectResource/types'; + import { App } from './types'; export default function makeApp(json: any): App { @@ -65,6 +67,9 @@ export default function makeApp(json: any): App { if (samlApp) { samlAppSsoUrl = `${cfg.baseUrl}/enterprise/saml-idp/login/${name}`; } + const samlAppPreset = json.samlAppPreset + ? json.samlAppPreset + : SamlServiceProviderPreset.Unspecified; return { kind: 'app', @@ -84,6 +89,7 @@ export default function makeApp(json: any): App { friendlyName, userGroups, samlApp, + samlAppPreset, samlAppSsoUrl, requiresRequest, integration, diff --git a/web/packages/teleport/src/services/apps/types.ts b/web/packages/teleport/src/services/apps/types.ts index 8f020456fc7de..183aae8d1b044 100644 --- a/web/packages/teleport/src/services/apps/types.ts +++ b/web/packages/teleport/src/services/apps/types.ts @@ -20,6 +20,8 @@ import { AwsRole } from 'shared/services/apps'; import { ResourceLabel } from 'teleport/services/agents'; +import type { SamlServiceProviderPreset } from 'teleport/Discover/SelectResource/types'; + export interface App { kind: 'app'; id: string; @@ -44,6 +46,8 @@ export interface App { samlApp: boolean; // samlAppSsoUrl is the URL that triggers IdP-initiated SSO for SAML Application; samlAppSsoUrl?: string; + // samlAppPreset is used to identify SAML service provider preset type. + samlAppPreset?: SamlServiceProviderPreset; // Integration is the integration name that must be used to access this Application. // Only applicable to AWS App Access. integration?: string; From 83d6b5c47e7c0c97b513d309b9a99c877b8f21a5 Mon Sep 17 00:00:00 2001 From: flyinghermit Date: Wed, 3 Jul 2024 10:43:42 -0400 Subject: [PATCH 2/2] remove default value assignment --- web/packages/teleport/src/services/apps/apps.test.ts | 3 --- web/packages/teleport/src/services/apps/makeApps.ts | 6 +----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/web/packages/teleport/src/services/apps/apps.test.ts b/web/packages/teleport/src/services/apps/apps.test.ts index 689f8a7887f6c..c9a7148c4e483 100644 --- a/web/packages/teleport/src/services/apps/apps.test.ts +++ b/web/packages/teleport/src/services/apps/apps.test.ts @@ -47,7 +47,6 @@ test('correct formatting of apps fetch response', async () => { userGroups: [], samlApp: false, samlAppSsoUrl: '', - samlAppPreset: 'unspecified', integration: '', }, { @@ -69,7 +68,6 @@ test('correct formatting of apps fetch response', async () => { userGroups: [], samlApp: false, samlAppSsoUrl: '', - samlAppPreset: 'unspecified', integration: '', }, { @@ -91,7 +89,6 @@ test('correct formatting of apps fetch response', async () => { userGroups: [], samlApp: false, samlAppSsoUrl: '', - samlAppPreset: 'unspecified', integration: '', }, { diff --git a/web/packages/teleport/src/services/apps/makeApps.ts b/web/packages/teleport/src/services/apps/makeApps.ts index 9356aad271eb6..069598c46fde9 100644 --- a/web/packages/teleport/src/services/apps/makeApps.ts +++ b/web/packages/teleport/src/services/apps/makeApps.ts @@ -20,8 +20,6 @@ import { AwsRole } from 'shared/services/apps'; import cfg from 'teleport/config'; -import { SamlServiceProviderPreset } from 'teleport/Discover/SelectResource/types'; - import { App } from './types'; export default function makeApp(json: any): App { @@ -38,6 +36,7 @@ export default function makeApp(json: any): App { friendlyName = '', requiresRequest, integration = '', + samlAppPreset, } = json; const canCreateUrl = fqdn && clusterId && publicAddr; @@ -67,9 +66,6 @@ export default function makeApp(json: any): App { if (samlApp) { samlAppSsoUrl = `${cfg.baseUrl}/enterprise/saml-idp/login/${name}`; } - const samlAppPreset = json.samlAppPreset - ? json.samlAppPreset - : SamlServiceProviderPreset.Unspecified; return { kind: 'app',