refactor: move app auth proviter to core api
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
committed by
Patrik Oldsberg
parent
feab471511
commit
b602171cc2
+6
-10
@@ -16,7 +16,6 @@
|
||||
|
||||
import React from 'react';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { componentsApiRef } from '@backstage/frontend-plugin-api';
|
||||
import { discoveryApiRef, fetchApiRef } from '@backstage/core-plugin-api';
|
||||
import { AppAuthProvider } from './AppAuthProvider';
|
||||
|
||||
@@ -47,15 +46,12 @@ jest.mock('@backstage/core-plugin-api', () => {
|
||||
};
|
||||
}
|
||||
|
||||
if (ref === componentsApiRef) {
|
||||
return {
|
||||
getComponent: jest
|
||||
.fn()
|
||||
.mockReturnValue(() => <div data-testid="progress" />),
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error(`Attempted to use an unmocked API reference: ${ref}`);
|
||||
// componentsApiRef
|
||||
return {
|
||||
getComponent: jest
|
||||
.fn()
|
||||
.mockReturnValue(() => <div data-testid="progress" />),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
-4
@@ -18,10 +18,6 @@ import React, { ReactNode } from 'react';
|
||||
import { CookieAuthRefreshProvider } from '@backstage/plugin-auth-react';
|
||||
import { isProtectedApp } from './isProtectedApp';
|
||||
|
||||
/**
|
||||
* @public
|
||||
* A provider that will protect the app when running in protected experimental mode.
|
||||
*/
|
||||
export function AppAuthProvider(props: { children: ReactNode }): JSX.Element {
|
||||
const { children } = props;
|
||||
|
||||
@@ -88,7 +88,7 @@ import { AppRouter, getBasePath } from './AppRouter';
|
||||
import { AppLanguageSelector } from '../apis/implementations/AppLanguageApi';
|
||||
import { I18nextTranslationApi } from '../apis/implementations/TranslationApi';
|
||||
import { overrideBaseUrlConfigs } from './overrideBaseUrlConfigs';
|
||||
import { isProtectedApp } from '@backstage/plugin-auth-react';
|
||||
import { isProtectedApp } from './isProtectedApp';
|
||||
|
||||
type CompatiblePlugin =
|
||||
| BackstagePlugin
|
||||
|
||||
@@ -29,7 +29,7 @@ import { isReactRouterBeta } from './isReactRouterBeta';
|
||||
import { RouteTracker } from '../routing/RouteTracker';
|
||||
import { Route, Routes } from 'react-router-dom';
|
||||
import { AppIdentityProxy } from '../apis/implementations/IdentityApi/AppIdentityProxy';
|
||||
import { AppAuthProvider } from '@backstage/plugin-auth-react';
|
||||
import { AppAuthProvider } from './AppAuthProvider';
|
||||
|
||||
/**
|
||||
* Get the app base path from the configured app baseUrl.
|
||||
|
||||
-4
@@ -14,10 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @public
|
||||
* An utility function that detects whether the app is operating in protected mode.
|
||||
*/
|
||||
export function isProtectedApp() {
|
||||
const element = document.querySelector('meta[name="backstage-app-mode"]');
|
||||
const appMode = element?.getAttribute('content') ?? 'public';
|
||||
@@ -38,11 +38,12 @@ import {
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { InternalAppContext } from '../wiring/InternalAppContext';
|
||||
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
|
||||
import { AppAuthProvider } from '../../../core-app-api/src/app/AppAuthProvider';
|
||||
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
|
||||
import { AppIdentityProxy } from '../../../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { RouteTracker } from '../routing/RouteTracker';
|
||||
import { getBasePath } from '../routing/getBasePath';
|
||||
import { AppAuthProvider } from '@backstage/plugin-auth-react';
|
||||
|
||||
export const AppRoot = createExtension({
|
||||
namespace: 'app',
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
import { default as React_2 } from 'react';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
// @public
|
||||
export function AppAuthProvider(props: { children: ReactNode }): JSX.Element;
|
||||
|
||||
// @public
|
||||
export function CookieAuthRedirect(): React_2.JSX.Element | null;
|
||||
|
||||
@@ -24,9 +21,6 @@ export type CookieAuthRefreshProviderProps = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
// @public
|
||||
export function isProtectedApp(): boolean;
|
||||
|
||||
// @public
|
||||
export function useCookieAuthRefresh(options: {
|
||||
pluginId: string;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export { isProtectedApp } from './isProtectedApp';
|
||||
export { AppAuthProvider } from './AppAuthProvider';
|
||||
@@ -17,6 +17,5 @@
|
||||
// The index file in ./components/ is typically responsible for selecting
|
||||
// which components are public API and should be exported from the package.
|
||||
|
||||
export * from './AppAuthProvider';
|
||||
export * from './CookieAuthRedirect';
|
||||
export * from './CookieAuthRefreshProvider';
|
||||
|
||||
Reference in New Issue
Block a user