Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backstage update #771

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,29 @@ The Diamond Light Source developer portal, built with backstage for deployment o
- Set `remote.containers.dockerPath` to `podman`
- Set `remote.containers.dockerComposePath` to your `docker-compose`
- Disable buildkit by adding `export DOCKER_BUILDKIT=0` to your `~/.bashrc`
- Open Development Container
- Create a `.env` file in the `.devcontainer` directory containing the [necessary secrets](#necessary-secrets)
- Open Development Container
- Install package dependencies with `yarn --cwd backstage install`
- Start the app, with `yarn --cwd backstage dev`

## Contributing changes

The following can be run locally to see if changes will pass CI

- `yarn --cwd backstage run test`
- `a` when prompted to run all tests
- `yarn --cwd backstage run prettier . --check`
- `yarn --cwd backstage run tsc`
- `yarn --cwd backstage backstage-cli repo lint`

## Updating Backstage version

After package install, backstage package dependencies can be updated with

`yarn --cwd backstage backstage-cli versions:bump`

https://backstage.io/docs/getting-started/keeping-backstage-updated

## Deploying on Kubernetes (Diamond Light Source)

- Access the cluster with `module load argus`
Expand Down
52 changes: 36 additions & 16 deletions backstage/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,12 @@ techdocs:
auth:
environment: development
providers:
guest: {}
github:
development:
clientId: ${GITHUB_APP_CLIENT_ID}
clientSecret: ${GITHUB_APP_SECRET}

ldap:
providers:
- target: ldap://ralfed.cclrc.ac.uk
users:
dn: ou=dls,dc=fed,dc=cclrc,dc=ac,dc=uk
options:
filter: (memberOf=cn=DLSLTD_Staff,OU=Automatic Groups,DC=fed,DC=cclrc,DC=ac,DC=uk)
paged: true
map:
name: cn
displayName: displayName
groups:
dn: dc=fed,dc=cclrc,dc=ac,dc=uk
options:
filter: (objectClass=group)

catalog:
readonly: true
import:
Expand Down Expand Up @@ -113,3 +98,38 @@ catalog:
minutes: 60
timeout:
minutes: 30
ldapOrg:
default:
target: ldap://ralfed.cclrc.ac.uk
bind:
dn: uid=ldap-reader-user,ou=people,ou=example,dc=example,dc=net
secret: dW5hdXRoZW50aWNhdGVkIExEQVAK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a fake secret because the field has to be provided, but the server is unauthenticated.

schedule:
frequency: PT1H
timeout: PT10M
users:
dn: ou=dls,dc=fed,dc=cclrc,dc=ac,dc=uk
options:
filter: (memberOf=cn=DLSLTD_Staff,OU=Automatic Groups,DC=fed,DC=cclrc,DC=ac,DC=uk)
paged: true
map:
name: cn
displayName: displayName
groups:
dn: dc=fed,dc=cclrc,dc=ac,dc=uk
options:
filter: (objectClass=group)

search:
collators:
catalog:
schedule:
# Give the backend server a chance to initiaize before collators are executed
initialDelay: { seconds: 3 }
frequency: { minutes: 10 }
timeout: { minutes: 15 }
techdocs:
schedule:
initialDelay: { seconds: 3 }
frequency: { minutes: 10 }
timeout: { minutes: 15 }
2 changes: 1 addition & 1 deletion backstage/backstage.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.20.3"
"version": "1.35.0"
}
2 changes: 1 addition & 1 deletion backstage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
]
},
"devDependencies": {
"@backstage/cli": "^0.26.2",
"@backstage/cli": "^0.29.5",
"@spotify/prettier-config": "^15.0.0",
"concurrently": "^9.0.1",
"lerna": "^8.0.0",
Expand Down
54 changes: 27 additions & 27 deletions backstage/packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,30 @@
"cy:run": "cypress run --browser chrome"
},
"dependencies": {
"@backstage/app-defaults": "^1.4.5",
"@backstage/catalog-model": "^1.4.3",
"@backstage/cli": "^0.26.2",
"@backstage/core-app-api": "^1.11.1",
"@backstage/core-components": "^0.14.0",
"@backstage/core-plugin-api": "^1.8.0",
"@backstage/integration-react": "^1.1.21",
"@backstage/plugin-api-docs": "^0.11.0",
"@backstage/plugin-catalog": "^1.15.1",
"@backstage/plugin-catalog-common": "^1.0.18",
"@backstage/plugin-catalog-graph": "^0.4.0",
"@backstage/plugin-catalog-import": "^0.12.0",
"@backstage/plugin-catalog-react": "^1.9.1",
"@backstage/plugin-github-actions": "^0.6.8",
"@backstage/plugin-home": "^0.7.2",
"@backstage/plugin-org": "^0.6.17",
"@backstage/plugin-permission-react": "^0.4.17",
"@backstage/plugin-scaffolder": "^1.16.1",
"@backstage/plugin-search": "^1.4.3",
"@backstage/plugin-search-react": "^1.7.3",
"@backstage/plugin-techdocs": "^1.9.1",
"@backstage/plugin-techdocs-module-addons-contrib": "^1.1.2",
"@backstage/plugin-techdocs-react": "^1.1.13",
"@backstage/plugin-user-settings": "^0.8.0",
"@backstage/theme": "^0.5.0",
"@backstage/app-defaults": "^1.5.16",
"@backstage/catalog-model": "^1.7.3",
"@backstage/cli": "^0.29.5",
"@backstage/core-app-api": "^1.15.4",
"@backstage/core-components": "^0.16.3",
"@backstage/core-plugin-api": "^1.10.3",
"@backstage/integration-react": "^1.2.3",
"@backstage/plugin-api-docs": "^0.12.3",
"@backstage/plugin-catalog": "^1.26.1",
"@backstage/plugin-catalog-common": "^1.1.3",
"@backstage/plugin-catalog-graph": "^0.4.15",
"@backstage/plugin-catalog-import": "^0.12.9",
"@backstage/plugin-catalog-react": "^1.15.1",
"@backstage/plugin-home": "^0.8.4",
"@backstage/plugin-org": "^0.6.35",
"@backstage/plugin-permission-react": "^0.4.30",
"@backstage/plugin-scaffolder": "^1.27.4",
"@backstage/plugin-search": "^1.4.22",
"@backstage/plugin-search-react": "^1.8.5",
"@backstage/plugin-techdocs": "^1.12.1",
"@backstage/plugin-techdocs-module-addons-contrib": "^1.1.20",
"@backstage/plugin-techdocs-react": "^1.2.13",
"@backstage/plugin-user-settings": "^0.8.18",
"@backstage/theme": "^0.6.3",
"@immobiliarelabs/backstage-plugin-gitlab": "^6.0.0",
"@internal/plugin-viewdocs-react": "^0.1.0",
"@material-ui/core": "^4.12.2",
Expand All @@ -53,10 +52,11 @@
"react-dom": "^17.0.2",
"react-router": "^6.8.2",
"react-router-dom": "^6.3.0",
"react-use": "^17.2.4"
"react-use": "^17.2.4",
"@backstage-community/plugin-github-actions": "^0.6.16"
},
"devDependencies": {
"@backstage/test-utils": "^1.4.5",
"@backstage/test-utils": "^1.7.4",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^14.0.0",
Expand Down
23 changes: 22 additions & 1 deletion backstage/packages/app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { createApp } from '@backstage/app-defaults';
import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
import { AlertDisplay, OAuthRequestDialog } from '@backstage/core-components';
import {
AlertDisplay,
OAuthRequestDialog,
SignInPage,
} from '@backstage/core-components';
import { githubAuthApiRef } from '@backstage/core-plugin-api';
import { apiDocsPlugin } from '@backstage/plugin-api-docs';
import {
CatalogEntityPage,
Expand Down Expand Up @@ -39,6 +44,22 @@ import { searchPage } from './components/search/SearchPage';
import { PrefixNavigate } from './components/utils/PrefixNavigate';

const app = createApp({
components: {
SignInPage: props => (
<SignInPage
{...props}
providers={[
'guest',
{
id: 'github-auth-provider',
title: 'GitHub',
message: 'Sign in using GitHub',
apiRef: githubAuthApiRef,
},
]}
/>
),
Comment on lines +48 to +61
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in thinking this shows up before the user is able to perform any other action? If so, can we somehow make guest the default and only require additional sign-in when a privileged action is requested (e.g. component template creation)?

Copy link
Contributor Author

@GDYendell GDYendell Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does, you have to click Enter as guest user when first launched. I don't know if that is possible, but I will investigate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guests can go to Settings > Authentication Providers to login via GitHub.

We might need a custom auth resolver to automatically login as guest. This might also be a problem:

This provider makes all users share a single "guest" identity. This is useful for testing purposes and quickly getting started locally, but is not safe for use in production and that particular provider will refuse to work there.

Copy link
Member

@garryod garryod Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A custom auth resolver sounds like a good call

The shared guest identity isn't an issue for us as we run backstage in an immutable configuration. If you were to allow people to edit things in the UI it would certainly be an issue

},
apis,
bindRoutes({ bind }) {
bind(catalogPlugin.externalRoutes, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
import {
EntityGithubActionsContent,
isGithubActionsAvailable,
} from '@backstage/plugin-github-actions';
} from '@backstage-community/plugin-github-actions';
import {
EntityGroupProfileCard,
EntityMembersListCard,
Expand Down
51 changes: 29 additions & 22 deletions backstage/packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,34 @@
"build-image": "docker build ../.. -f Dockerfile --tag backstage"
},
"dependencies": {
"@backstage/backend-common": "^0.23.2",
"@backstage/backend-tasks": "^0.5.12",
"@backstage/catalog-client": "^1.4.6",
"@backstage/catalog-model": "^1.4.3",
"@backstage/config": "^1.1.1",
"@backstage/integration": "^1.9.0",
"@backstage/plugin-auth-backend": "^0.22.3",
"@backstage/plugin-auth-node": "^0.4.1",
"@backstage/plugin-catalog-backend": "^1.15.0",
"@backstage/plugin-catalog-backend-module-github": "^0.6.0",
"@backstage/plugin-catalog-backend-module-gitlab": "^0.3.4",
"@backstage/plugin-catalog-backend-module-ldap": "^0.7.0",
"@backstage/plugin-catalog-backend-module-openapi": "^0.1.24",
"@backstage/plugin-permission-common": "^0.8.0",
"@backstage/plugin-permission-node": "^0.8.0",
"@backstage/plugin-proxy-backend": "^0.5.2",
"@backstage/plugin-scaffolder-backend": "^1.19.1",
"@backstage/plugin-search-backend": "^1.4.7",
"@backstage/plugin-search-backend-module-pg": "^0.5.16",
"@backstage/plugin-search-backend-node": "^1.2.11",
"@backstage/plugin-techdocs-backend": "^1.9.0",
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-defaults": "^0.7.0",
"@backstage/backend-plugin-api": "^1.1.1",
"@backstage/backend-tasks": "^0.6.1",
"@backstage/catalog-client": "^1.9.1",
"@backstage/catalog-model": "^1.7.3",
"@backstage/config": "^1.3.2",
"@backstage/integration": "^1.16.1",
"@backstage/plugin-auth-backend": "^0.24.2",
"@backstage/plugin-auth-backend-module-github-provider": "^0.2.4",
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.4",
"@backstage/plugin-auth-node": "^0.5.6",
"@backstage/plugin-catalog-backend": "^1.30.0",
"@backstage/plugin-catalog-backend-module-github": "^0.7.9",
"@backstage/plugin-catalog-backend-module-gitlab": "^0.6.2",
"@backstage/plugin-catalog-backend-module-ldap": "^0.11.1",
"@backstage/plugin-catalog-backend-module-openapi": "^0.2.6",
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model": "^0.2.4",
"@backstage/plugin-permission-common": "^0.8.4",
"@backstage/plugin-permission-node": "^0.8.7",
"@backstage/plugin-proxy-backend": "^0.5.10",
"@backstage/plugin-scaffolder-backend": "^1.29.0",
"@backstage/plugin-search-backend": "^1.8.1",
"@backstage/plugin-search-backend-module-catalog": "^0.3.0",
"@backstage/plugin-search-backend-module-pg": "^0.5.40",
"@backstage/plugin-search-backend-module-techdocs": "^0.3.5",
"@backstage/plugin-search-backend-node": "^1.3.7",
"@backstage/plugin-techdocs-backend": "^1.11.5",
"@diamondlightsource/plugin-scaffolder-backend-module-copier": "^0.3.4",
"@immobiliarelabs/backstage-plugin-gitlab-backend": "^6.0.0",
"better-sqlite3": "^11.0.0",
Expand All @@ -47,7 +54,7 @@
"winston": "^3.2.1"
},
"devDependencies": {
"@backstage/cli": "^0.26.2",
"@backstage/cli": "^0.29.5",
"@types/dockerode": "^3.3.0",
"@types/express": "^4.17.6",
"@types/express-serve-static-core": "^5.0.1",
Expand Down
Loading
Loading