From 5288ce0deeddfce29857a39a01c71864fc84b296 Mon Sep 17 00:00:00 2001 From: "J Shamsul Bahri (jibone))" Date: Mon, 21 Sep 2020 17:43:05 +0800 Subject: [PATCH] Remove getAccessToken func --- app-config.yaml | 5 ++--- packages/core-api/src/apis/definitions/auth.ts | 4 ---- .../src/apis/implementations/auth/saml/SamlAuth.ts | 6 ------ .../core-api/src/lib/AuthConnector/SamlAuthConnector.ts | 9 ++------- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/app-config.yaml b/app-config.yaml index 6fda32f175..60ecb813f7 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -160,9 +160,8 @@ auth: $secret: env: GITLAB_BASE_URL saml: - development: - entryPoint: 'http://localhost:7001/' - issuer: 'passport-saml' + entryPoint: 'http://localhost:7001/' + issuer: 'passport-saml' okta: development: clientId: diff --git a/packages/core-api/src/apis/definitions/auth.ts b/packages/core-api/src/apis/definitions/auth.ts index 933a78b693..b536d74801 100644 --- a/packages/core-api/src/apis/definitions/auth.ts +++ b/packages/core-api/src/apis/definitions/auth.ts @@ -101,16 +101,12 @@ export type OAuthApi = { * This API provides access to SAML 2 credentials. Verify user access with identity provider. */ export type SamlApi = { - // Not sure what Promise call back should have. getBackstageIdentity( options?: AuthRequestOptions, ): Promise; getProfile(options?: AuthRequestOptions): Promise; - // FIXME: is this needed? - getAccessToken(options?: AuthRequestOptions): Promise; - // Not sure if this is needed. logout(): Promise; }; diff --git a/packages/core-api/src/apis/implementations/auth/saml/SamlAuth.ts b/packages/core-api/src/apis/implementations/auth/saml/SamlAuth.ts index aeede356ef..c06a6274fd 100644 --- a/packages/core-api/src/apis/implementations/auth/saml/SamlAuth.ts +++ b/packages/core-api/src/apis/implementations/auth/saml/SamlAuth.ts @@ -92,12 +92,6 @@ class SamlAuth implements SamlApi { return session?.profile; } - // FIXME: Is this needed?... - async getAccessToken(options: AuthRequestOptions) { - const session = await this.sessionManager.getSession(options); - return session?.userId ?? ''; - } - async logout() { await this.sessionManager.removeSession(); } diff --git a/packages/core-api/src/lib/AuthConnector/SamlAuthConnector.ts b/packages/core-api/src/lib/AuthConnector/SamlAuthConnector.ts index 47d8f25820..30de81536d 100644 --- a/packages/core-api/src/lib/AuthConnector/SamlAuthConnector.ts +++ b/packages/core-api/src/lib/AuthConnector/SamlAuthConnector.ts @@ -19,7 +19,6 @@ import { BackstageIdentity, DiscoveryApi, } from '../../apis/definitions'; -import { AuthConnector } from './types'; import { showLoginPopup } from '../loginPopup'; type Options = { @@ -34,8 +33,7 @@ export type SamlResponse = { backstageIdentity: BackstageIdentity; }; -export class SamlAuthConnector - implements AuthConnector { +export class SamlAuthConnector { private readonly discoveryApi: DiscoveryApi; private readonly environment: string | undefined; private readonly provider: AuthProvider & { id: string }; @@ -52,7 +50,7 @@ export class SamlAuthConnector const popupUrl = await this.buildUrl('/start'); const payload = await showLoginPopup({ url: popupUrl, - name: 'SAML Login', // FIXME: change this to provider name? and not hardcode the name + name: `${this.provider.title} Login`, origin: new URL(popupUrl).origin, width: 450, height: 730, @@ -64,9 +62,6 @@ export class SamlAuthConnector }; } - // FIXME: do we need this for SAML? - async refreshSession(): Promise {} - async removeSession(): Promise { const res = await fetch(await this.buildUrl('/logout'), { method: 'POST',