diff --git a/.dockerignore b/.dockerignore index 05edb62..f341c68 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,3 +6,5 @@ packages/*/src packages/*/node_modules plugins *.local.yaml +github-integration.yaml +k8s-config.yaml diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index 056402f..28c9b5b 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -27,7 +27,7 @@ import { entityPage } from './components/catalog/EntityPage'; import { searchPage } from './components/search/SearchPage'; import { Root } from './components/Root'; -import { AlertDisplay, OAuthRequestDialog } from '@backstage/core-components'; +import {AlertDisplay, OAuthRequestDialog, ProxiedSignInPage} from '@backstage/core-components'; import { createApp } from '@backstage/app-defaults'; import { AppRouter, FlatRoutes } from '@backstage/core-app-api'; import { CatalogGraphPage } from '@backstage/plugin-catalog-graph'; @@ -36,6 +36,9 @@ import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/ const app = createApp({ apis, + components: { + SignInPage: (props) => , + }, bindRoutes({ bind }) { bind(catalogPlugin.externalRoutes, { createComponent: scaffolderPlugin.routes.root, diff --git a/packages/backend/src/plugins/auth.ts b/packages/backend/src/plugins/auth.ts index 77eb6aa..9790887 100644 --- a/packages/backend/src/plugins/auth.ts +++ b/packages/backend/src/plugins/auth.ts @@ -5,6 +5,7 @@ import { } from '@backstage/plugin-auth-backend'; import { Router } from 'express'; import { PluginEnvironment } from '../types'; +import {DEFAULT_NAMESPACE, stringifyEntityRef} from "@backstage/catalog-model"; export default async function createPlugin( env: PluginEnvironment, @@ -17,7 +18,39 @@ export default async function createPlugin( tokenManager: env.tokenManager, providerFactories: { ...defaultAuthProviderFactories, + oauth2Proxy: providers.oauth2Proxy.create({ + signIn: { + async resolver({ result }, ctx) { + console.log(result) + const name = result.getHeader('x-forwarded-preferred-username'); + if (!name) { + throw new Error('Request did not contain a user'); + } + try { + // Attempts to sign in existing user + const signedInUser = await ctx.signInWithCatalogUser({ + entityRef: { name }, + }); + + return Promise.resolve(signedInUser); + } catch (e) { + // Create stub user + const userEntityRef = stringifyEntityRef({ + kind: 'User', + name: name, + namespace: DEFAULT_NAMESPACE, + }); + return ctx.issueToken({ + claims: { + sub: userEntityRef, + ent: [userEntityRef], + }, + }); + } + }, + }, + }), // This replaces the default GitHub auth provider with a customized one. // The `signIn` option enables sign-in for this provider, using the // identity resolution logic that's provided in the `resolver` callback. @@ -35,20 +68,20 @@ export default async function createPlugin( // your own, see the auth documentation for more details: // // https://backstage.io/docs/auth/identity-resolver - github: providers.github.create({ - signIn: { - resolver(_, ctx) { - const userRef = 'user:default/guest'; // Must be a full entity reference - return ctx.issueToken({ - claims: { - sub: userRef, // The user's own identity - ent: [userRef], // A list of identities that the user claims ownership through - }, - }); - }, - // resolver: providers.github.resolvers.usernameMatchingUserEntityName(), - }, - }), + // github: providers.github.create({ + // signIn: { + // resolver(_, ctx) { + // const userRef = 'user:default/guest'; // Must be a full entity reference + // return ctx.issueToken({ + // claims: { + // sub: userRef, // The user's own identity + // ent: [userRef], // A list of identities that the user claims ownership through + // }, + // }); + // }, + // // resolver: providers.github.resolvers.usernameMatchingUserEntityName(), + // }, + // }), }, }); } diff --git a/plugins/workflows/dev/index.tsx b/plugins/workflows/dev/index.tsx deleted file mode 100644 index bdf809b..0000000 --- a/plugins/workflows/dev/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -// import React from 'react'; -// import { createDevApp } from '@backstage/dev-utils'; -// import { workflowsPlugin, EntityWorkflowsContent } from '../src/plugin'; -// -// createDevApp() -// .registerPlugin(workflowsPlugin) -// .addPage({ -// element: , -// title: 'Root Page', -// path: '/workflows' -// }) -// .render(); diff --git a/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.test.tsx b/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.test.tsx deleted file mode 100644 index 24974f5..0000000 --- a/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.test.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -import { ExampleComponent } from './ExampleComponent'; -import { rest } from 'msw'; -import { setupServer } from 'msw/node'; -import { screen } from '@testing-library/react'; -import { - setupRequestMockHandlers, - renderInTestApp, -} from "@backstage/test-utils"; - -describe('ExampleComponent', () => { - const server = setupServer(); - // Enable sane handlers for network requests - setupRequestMockHandlers(server); - - // setup mock response - beforeEach(() => { - server.use( - rest.get('/*', (_, res, ctx) => res(ctx.status(200), ctx.json({}))), - ); - }); - - it('should render', async () => { - await renderInTestApp(); - expect(screen.getByText('Welcome to workflows!')).toBeInTheDocument(); - }); -}); diff --git a/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.test.tsx.bak b/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.test.tsx.bak new file mode 100644 index 0000000..b82191b --- /dev/null +++ b/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.test.tsx.bak @@ -0,0 +1,26 @@ +// import React from 'react'; +// import { rest } from 'msw'; +// import { setupServer } from 'msw/node'; +// import { screen } from '@testing-library/react'; +// import { +// setupRequestMockHandlers, +// renderInTestApp, +// } from "@backstage/test-utils"; + +// describe('ExampleComponent', () => { +// const server = setupServer(); +// // Enable sane handlers for network requests +// setupRequestMockHandlers(server); +// +// // setup mock response +// beforeEach(() => { +// server.use( +// rest.get('/*', (_, res, ctx) => res(ctx.status(200), ctx.json({}))), +// ); +// }); +// +// it('should render', async () => { +// await renderInTestApp(); +// expect(screen.getByText('Welcome to workflows!')).toBeInTheDocument(); +// }); +// }); diff --git a/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.tsx b/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.tsx index c422b5d..483b759 100644 --- a/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.tsx +++ b/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.tsx @@ -1,27 +1,21 @@ import React from 'react'; -import {Typography, Grid, IconButton} from '@material-ui/core'; -import DeleteIcon from '@material-ui/icons/Delete'; -import ClearIcon from '@material-ui/icons/Clear' -import LinkOffRounded from "@material-ui/icons/LinkOffRounded"; +import {Grid} from '@material-ui/core'; import { - InfoCard, - Header, Page, Content, - HeaderLabel, } from '@backstage/core-components'; import {FetchTFState, ManageBlueprint} from "./FetchTFState"; export const BlueprintsComponent = () => ( - {/**/} + {/* */} {/* A description of your plugin goes here.*/} - {/**/} + {/* */} - {/**/} + {/* */} {/* */} {/* Manage this blueprint deployment*/} {/* */} @@ -34,7 +28,7 @@ export const BlueprintsComponent = () => ( {/* */} {/* */} {/* */} - {/**/} + {/* */} diff --git a/plugins/workflows/src/components/BlueprintComponent/FetchTFState.tsx b/plugins/workflows/src/components/BlueprintComponent/FetchTFState.tsx index 1b3f7b7..05f5ef3 100644 --- a/plugins/workflows/src/components/BlueprintComponent/FetchTFState.tsx +++ b/plugins/workflows/src/components/BlueprintComponent/FetchTFState.tsx @@ -17,14 +17,13 @@ import { DialogContentText, DialogTitle, IconButton, - PaperProps, Typography } from "@material-ui/core"; import DeleteIcon from "@material-ui/icons/Delete"; import ClearIcon from "@material-ui/icons/Clear"; import LinkOffRounded from "@material-ui/icons/LinkOffRounded"; -const token = "" +const token = "..---" type TFState = { terraform_version: string