Package Exports
- @backstage/plugin-auth-backend
- @backstage/plugin-auth-backend/package.json
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@backstage/plugin-auth-backend) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Auth Backend
WORK IN PROGRESS
This is the backend part of the auth plugin.
It responds to auth requests from the frontend, and fulfills them by delegating to the appropriate provider in the backend.
Local development
Choose your OAuth Providers, replace x with actual value and then start backend:
Example for Google OAuth Provider at root directory:
export AUTH_GOOGLE_CLIENT_ID=x
export AUTH_GOOGLE_CLIENT_SECRET=x
yarn --cwd packages/backend startexport AUTH_GOOGLE_CLIENT_ID=x
export AUTH_GOOGLE_CLIENT_SECRET=xGitHub
Creating a GitHub OAuth application
Follow this link, Create new OAuth App.
- Set Application Name to
backstage-devor something along those lines. - You can set the Homepage URL to whatever you want to.
- The Authorization Callback URL should match the redirect URI set in Backstage.
- Set this to
http://localhost:7000/api/auth/githubfor local development. - Set this to
http://{APP_FQDN}:{APP_BACKEND_PORT}/api/auth/githubfor non-local deployments.
- Set this to
export AUTH_GITHUB_CLIENT_ID=x
export AUTH_GITHUB_CLIENT_SECRET=xFor GitHub Enterprise:
export AUTH_GITHUB_CLIENT_ID=x
export AUTH_GITHUB_CLIENT_SECRET=x
export AUTH_GITHUB_ENTERPRISE_INSTANCE_URL=https://xGitLab
Creating a GitLab OAuth application
Follow this link, Add new application.
- Set Application Name to
backstage-devor something along those lines. - The Authorization Callback URL should match the redirect URI set in Backstage.
- Set this to
http://localhost:7000/api/auth/gitlab/handler/framefor local development. - Set this to
http://{APP_FQDN}:{APP_BACKEND_PORT}/api/auth/gitlab/handler/framefor non-local deployments. - Select the following scopes from the list:
-
read_userGrants read-only access to the authenticated user's profile through the /user API endpoint, which includes username, public email, and full name. Also grants access to read-only API endpoints under /users. -
read_repositoryGrants read-only access to repositories on private projects using Git-over-HTTP (not using the API). -
write_repositoryGrants read-write access to repositories on private projects using Git-over-HTTP (not using the API). -
openidGrants permission to authenticate with GitLab using OpenID Connect. Also gives read-only access to the user's profile and group memberships. -
profileGrants read-only access to the user's profile data using OpenID Connect. -
emailGrants read-only access to the user's primary email address using OpenID Connect.
-
- Set this to
export GITLAB_BASE_URL=https://gitlab.com
export AUTH_GITLAB_CLIENT_ID=x # GitLab calls this the Application ID
export AUTH_GITLAB_CLIENT_SECRET=xCreating a GitLab Enterprise OAuth application
If you have GitLab Enterprise, perform the steps above, replacing gitlab.example.com in the following
with the domain of your GitLab Enterprise host:
Create new application at: https://gitlab.example.com/profile/applications.
export GITLAB_BASE_URL=https://gitlab.example.com
export AUTH_GITLAB_CLIENT_ID=x # GitLab calls this the Application ID
export AUTH_GITLAB_CLIENT_SECRET=xOkta
Add a new Okta application using the following URI conventions:
Login redirect URI's: http://localhost:7000/api/auth/okta/handler/frame
Logout redirect URI's: http://localhost:7000/api/auth/okta/logout
Initiate login URI's: http://localhost:7000/api/auth/okta/start
Then configure the following environment variables to be used in the app-config.yaml file:
export AUTH_OKTA_AUDIENCE=https://example.okta.com
export AUTH_OKTA_CLIENT_ID=x
export AUTH_OKTA_CLIENT_SECRET=xAuth0
export AUTH_AUTH0_DOMAIN=x
export AUTH_AUTH0_CLIENT_ID=x
export AUTH_AUTH0_CLIENT_SECRET=xMicrosoft
Creating an Azure AD App Registration
An Azure AD App Registration is required to be able to sign in using Azure AD and the Microsoft Graph API. Click here to create a new one.
- Click on the
New Registrationbutton. - Give the app a name. e.g.
backstage-dev - Select
Accounts in this organizational directory onlyunder supported account types. - Enter the callback URL for your backstage backend instance:
- For local development, this is likely
http://localhost:7000/api/auth/microsoft/handler/frame - For non-local deployments, this will be
https://{APP_FQDN}:{APP_BACKEND_PORT}/auth/microsoft/handler/frame
- For local development, this is likely
- Click
Register.
We also need to generate a client secret so Backstage can authenticate as this app.
- Click on the
Certificates & secretsmenu item. - Under
Client secrets, click onNew client secret. - Add a description for the new secret. e.g.
auth-backend-plugin - Select an expiry time;
1 Year,2 YearsorNever. - Click
Add.
The secret value will then be displayed on the screen. You will not be able to retrieve it again after leaving the page.
Starting the Auth Backend
cd packages/backend
export AUTH_MICROSOFT_CLIENT_ID=x
export AUTH_MICROSOFT_CLIENT_SECRET=x
export AUTH_MICROSOFT_TENANT_ID=x
yarn startSAML
To try out SAML, you can use the mock identity provider:
./scripts/start-saml-idp.sh