diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx
index 29e371b469..6ff4da0fe3 100644
--- a/packages/app/src/App.tsx
+++ b/packages/app/src/App.tsx
@@ -35,7 +35,7 @@ const app = createApp({
return (
);
},
diff --git a/packages/core-api/src/apis/definitions/auth.ts b/packages/core-api/src/apis/definitions/auth.ts
index 6dfe9595b0..8f0a4b6595 100644
--- a/packages/core-api/src/apis/definitions/auth.ts
+++ b/packages/core-api/src/apis/definitions/auth.ts
@@ -108,6 +108,9 @@ export type SamlApi = {
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 75aefda7f5..cb93dcea97 100644
--- a/packages/core-api/src/apis/implementations/auth/saml/SamlAuth.ts
+++ b/packages/core-api/src/apis/implementations/auth/saml/SamlAuth.ts
@@ -35,9 +35,6 @@ import {
type CreateOptions = {
apiOrigin: string;
basePath: string;
-
- // oauthRequestApi?: OAuthRequestApi;
-
environment?: string;
provider?: AuthProvider & { id: string };
};
@@ -61,9 +58,6 @@ class SamlAuth implements SamlApi {
environment = 'development',
provider = DEFAULT_PROVIDER,
}: CreateOptions) {
- // eslint-disable-next-line no-console
- console.log('this is from SamlAuth');
-
const connector = new SamlAuthConnector({
apiOrigin,
basePath,
@@ -87,37 +81,27 @@ class SamlAuth implements SamlApi {
sessionState$(): Observable {
return this.sessionManager.sessionState$();
}
- // constructor(private readonly sessionManager: any) {}
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
- constructor(private readonly sessionManager: SessionManager) {
- // eslint-disable-next-line no-console
- console.log('this is the constructor');
- }
+
+ constructor(private readonly sessionManager: SessionManager) {}
async getBackstageIdentity(
options: AuthRequestOptions,
): Promise {
- // eslint-disable-next-line no-console
- console.log('===> Saml getBackstageIdentity()');
const session = await this.sessionManager.getSession(options);
- // eslint-disable-next-line no-console
- console.log('this this thish lkkdfkkfkfji');
- // eslint-disable-next-line no-console
- console.log(session);
return session?.backstageIdentity;
}
async getProfile(options: AuthRequestOptions = {}) {
- // eslint-disable-next-line no-console
- console.log('==> samlauth getprofile()');
const session = await this.sessionManager.getSession(options);
- // eslint-disable-next-line no-console
- console.log('+++ this is the session from getProfile()');
- // eslint-disable-next-line no-console
- console.log(session);
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/app/AppIdentity.ts b/packages/core-api/src/app/AppIdentity.ts
index 1a6cdac3e6..69ee5d28ac 100644
--- a/packages/core-api/src/app/AppIdentity.ts
+++ b/packages/core-api/src/app/AppIdentity.ts
@@ -67,10 +67,6 @@ export class AppIdentity implements IdentityApi {
// This is indirectly called by the sign-in page to continue into the app.
setSignInResult(result: SignInResult) {
- // eslint-disable-next-line no-console
- console.log('this is from setSignInResult');
- // eslint-disable-next-line no-console
- console.log(result);
if (this.hasIdentity) {
return;
}
diff --git a/packages/core-api/src/lib/AuthConnector/SamlAuthConnector.ts b/packages/core-api/src/lib/AuthConnector/SamlAuthConnector.ts
index 9dc0fca0a0..4a6babe224 100644
--- a/packages/core-api/src/lib/AuthConnector/SamlAuthConnector.ts
+++ b/packages/core-api/src/lib/AuthConnector/SamlAuthConnector.ts
@@ -36,7 +36,8 @@ export type SamlResponse = {
backstageIdentity: BackstageIdentity;
};
-export class SamlAuthConnector implements AuthConnector {
+export class SamlAuthConnector
+ implements AuthConnector {
private readonly apiOrigin: string;
private readonly basePath: string;
private readonly environment: string | undefined;
@@ -57,35 +58,25 @@ export class SamlAuthConnector implements AuthConnector {
- // eslint-disable-next-line no-console
- console.log('==> from SamlAuthConnector createSession');
-
const payload = await showLoginPopup({
- url: 'http://localhost:7000/auth/saml/start', // FIXME: this should be from app.config or somewhere
+ url: 'http://localhost:7000/auth/saml/start', // FIXME: remove hardcoded here. should do something like buildUrl
name: 'SAML Login', // FIXME: change this to provider name? and not hardcode the name
origin: this.apiOrigin,
width: 450,
height: 730,
});
- // eslint-disable-next-line no-console
- console.log(payload);
-
return {
...payload,
id: payload.profile.email,
};
}
- // TODO: do we need this for SAML?
- async refreshSession(): Promise {
- // eslint-disable-next-line no-console
- console.log('==> this is refresh session');
- }
+ // FIXME: do we need this for SAML?
+ async refreshSession(): Promise {}
async removeSession(): Promise {
- // eslint-disable-next-line no-console
- console.log('this removes the session');
+ // FIXME: remove hardcoded url here... should do something like buildUrl
const res = await fetch('http://localhost:7000/auth/saml/logout', {
method: 'POST',
headers: {
diff --git a/packages/core-api/src/lib/AuthSessionManager/SamlAuthSessionManager.ts b/packages/core-api/src/lib/AuthSessionManager/SamlAuthSessionManager.ts
index 9439684cf4..8a21bc05b9 100644
--- a/packages/core-api/src/lib/AuthSessionManager/SamlAuthSessionManager.ts
+++ b/packages/core-api/src/lib/AuthSessionManager/SamlAuthSessionManager.ts
@@ -15,10 +15,12 @@
*/
import { SessionManager, GetSessionOptions } from './types';
-import { SamlAuthConnector, SamlResponse } from '../AuthConnector/SamlAuthConnector';
+import {
+ SamlAuthConnector,
+ SamlResponse,
+} from '../AuthConnector/SamlAuthConnector';
import { SessionStateTracker } from './SessionStateTracker';
-
type Options = {
connector: SamlAuthConnector;
};
@@ -27,18 +29,15 @@ export class SamlAuthSessionManager implements SessionManager {
private readonly connector: SamlAuthConnector;
private readonly stateTracker = new SessionStateTracker();
- private currentSession: any | undefined; // FIXME: proper typing here
+ private currentSession: any | undefined; // FIXME: proper typing here?
constructor(options: Options) {
const { connector } = options;
this.connector = connector;
- // this.helper = new SessionScopeHelper
}
async getSession(options: GetSessionOptions): Promise {
- // eslint-disable-next-line no-console
- console.log('==> this is from SamlAuthSessionManager getSession()');
if (this.currentSession) {
return this.currentSession;
}
diff --git a/packages/core-api/src/lib/AuthSessionManager/SamlAuthSessionStore.ts b/packages/core-api/src/lib/AuthSessionManager/SamlAuthSessionStore.ts
index 53fba09b54..3afb07c4df 100644
--- a/packages/core-api/src/lib/AuthSessionManager/SamlAuthSessionStore.ts
+++ b/packages/core-api/src/lib/AuthSessionManager/SamlAuthSessionStore.ts
@@ -33,8 +33,6 @@ export class SamlAuthSessionStore implements SamlAuthSessionManager {
}
async getSession(options: GetSessionOptions): Promise {
- // eslint-disable-next-line no-console
- console.log('==>> this is from SamlAuthSessionStore getSession()');
const session = this.loadSession();
if (session) {
diff --git a/packages/core/src/layout/SignInPage/commonProvider.tsx b/packages/core/src/layout/SignInPage/commonProvider.tsx
index 88a53ec358..f9611342a2 100644
--- a/packages/core/src/layout/SignInPage/commonProvider.tsx
+++ b/packages/core/src/layout/SignInPage/commonProvider.tsx
@@ -36,11 +36,6 @@ const Component: ProviderComponent = ({ config, onResult }) => {
instantPopup: true,
});
- // eslint-disable-next-line no-console
- console.log('====++++++++++++++++++++++++++> handleLogin for commonProvider');
- // eslint-disable-next-line no-console
- console.log(identity);
-
const profile = await authApi.getProfile();
onResult({
userId: identity!.id,
diff --git a/packages/core/src/layout/SignInPage/providers.tsx b/packages/core/src/layout/SignInPage/providers.tsx
index 436078e49c..ff60eba228 100644
--- a/packages/core/src/layout/SignInPage/providers.tsx
+++ b/packages/core/src/layout/SignInPage/providers.tsx
@@ -26,7 +26,6 @@ import { SignInConfig, IdentityProviders, SignInProvider } from './types';
import { commonProvider } from './commonProvider';
import { guestProvider } from './guestProvider';
import { customProvider } from './customProvider';
-import { samlProvider } from './samlProvider';
const PROVIDER_STORAGE_KEY = '@backstage/core:SignInPage:provider';
@@ -42,7 +41,6 @@ const signInProviders: { [key: string]: SignInProvider } = {
guest: guestProvider,
custom: customProvider,
common: commonProvider,
- saml: samlProvider,
};
function validateIDs(id: string, providers: SignInProviderType): void {
diff --git a/packages/core/src/layout/SignInPage/samlProvider.tsx b/packages/core/src/layout/SignInPage/samlProvider.tsx
deleted file mode 100644
index e9673bca8c..0000000000
--- a/packages/core/src/layout/SignInPage/samlProvider.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2020 Spotify AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import React from 'react';
-import { Grid, Typography, Button } from '@material-ui/core';
-import { ProviderComponent, ProviderLoader, SignInProvider } from './types';
-import { useApi, errorApiRef /* samlAuthApiRef */ } from '@backstage/core-api';
-import { InfoCard } from '../InfoCard/InfoCard';
-
-const Component: ProviderComponent = ({ onResult }) => {
- // const samlApi = useApi(samlAuthApiRef);
- const errorApi = useApi(errorApiRef);
-
- const handleSSORedirect = () => {
- // FIXME: this shoudl be from identity API or something.
- window.open('http://localhost:7000/auth/saml/start');
- };
-
- const receiveMessage = (event: any) => {
- // FIXME: Should use the backstage identity API and not create this session storage.
- window.sessionStorage.setItem(
- 'helixSession',
- JSON.stringify(event.data.response),
- );
-
- onResult({
- userId: event.data.response.backstageIdentity,
- profile: {
- email: event.data.response.profile.email,
- displayName: event.data.response.profile.displayName,
- },
- });
- };
-
- const handleLogin = async () => {
- try {
- // FIXME: this should be handle through backstage API or something.
- handleSSORedirect();
- window.addEventListener('message', receiveMessage, false);
- } catch (error) {
- errorApi.post(error);
- }
- };
-
- return (
-
-
- Sign In
-
- }
- >
- Sign In using SAML lolololol
-
-
- );
-};
-
-const loader: ProviderLoader = async () => {
- // FIXME: should get the profile from identiy API not from storage session.
- const sessionRaw = window.sessionStorage.getItem('helixSession');
-
- if (!sessionRaw) {
- return undefined;
- }
-
- const session = JSON.parse(sessionRaw);
-
- return {
- userId: session.backstageIdentity,
- profile: {
- email: session.profile.email,
- displayName: session.profile.displayName,
- },
- };
-};
-
-export const samlProvider: SignInProvider = { Component, loader };
diff --git a/packages/core/src/layout/SignInPage/types.ts b/packages/core/src/layout/SignInPage/types.ts
index 74463f93b4..513fe9f674 100644
--- a/packages/core/src/layout/SignInPage/types.ts
+++ b/packages/core/src/layout/SignInPage/types.ts
@@ -36,7 +36,7 @@ export type SignInConfig = {
| ApiRef;
};
-export type IdentityProviders = ('guest' | 'custom' | 'saml' | SignInConfig)[];
+export type IdentityProviders = ('guest' | 'custom' | SignInConfig)[];
export type ProviderComponent = ComponentType<
SignInPageProps & { config: SignInConfig }
@@ -44,9 +44,9 @@ export type ProviderComponent = ComponentType<
export type ProviderLoader = (
apis: ApiHolder,
- apiRef: ApiRef<
- OAuthApi & ProfileInfoApi & BackstageIdentityApi & SessionStateApi
- >,
+ apiRef:
+ | ApiRef
+ | ApiRef,
) => Promise;
export type SignInProvider = {
diff --git a/plugins/auth-backend/src/providers/saml/provider.ts b/plugins/auth-backend/src/providers/saml/provider.ts
index fe6bb87b6d..f790228107 100644
--- a/plugins/auth-backend/src/providers/saml/provider.ts
+++ b/plugins/auth-backend/src/providers/saml/provider.ts
@@ -55,17 +55,6 @@ export class SamlAuthProvider implements AuthProviderRouteHandlers {
// for non-oauth auth flows.
// TODO: This flow doesn't issue an identity token that can be used to validate
// the identity of the user in other backends, which we need in some form.
- console.log('===>');
- console.log('===>');
- console.log('===>');
- console.log('===>');
- console.log('===>');
- console.log('===>');
- console.log('===>');
- console.log('===>');
- console.log('===>');
- console.log('===>');
- console.log('===>');
console.log('===> SamlAuthProvider constructor');
console.log(profile);
done(undefined, {