-
Notifications
You must be signed in to change notification settings - Fork 6
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
Feat/backstage auth info #852
Draft
jkleinlercher
wants to merge
7
commits into
main
Choose a base branch
from
feat/backstage_auth_info
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
52b6308
base info about backstage authorization and integration
phac008 f420230
base info about backstage authorization and integration
phac008 e4f7473
some minor changes
phac008 9fe2ad3
remove specific url
phac008 dee5c80
remove unused provider
phac008 035c0ba
adapt comments from draft
phac008 cc62aaa
Merge branch 'main' into feat/backstage_auth_info
jkleinlercher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Authentication/Integration in Backstage | ||
|
||
This document should give an overview how Backstage Authentication/Integration works in general and how we use that in kubriX environment | ||
|
||
backstage.io documentation link: | ||
- [Authentication](https://backstage.io/docs/auth/) | ||
- [Integration](https://backstage.io/docs/integrations/) | ||
|
||
## Authentication | ||
### Purpose | ||
- Sign-in and identification of users | ||
- Delegating access to 3rd party resources | ||
|
||
There are several build-in auth providers, also custom providers are possible. Only "one" will/should be used for sign-in, the rest provide access to external resources. | ||
For different showcases we have currently 2 providers active in our kubriX demo - GitHub and OIDC via Keyloak Instance | ||
|
||
``` | ||
auth: | ||
environment: development | ||
providers: | ||
github: | ||
development: | ||
clientId: ${GITHUB_CLIENT_ID} | ||
clientSecret: ${GITHUB_CLIENT_SECRET} | ||
oidc: | ||
development: | ||
metadataUrl: http://keycloak-service.keycloak.svc.cluster.local:8080/realms/sx-cnp-oss #.well-known/openid-configuration can be ommited | ||
callbackUrl: https://<backstageurl>/api/auth/oidc/handler/frame | ||
clientId: backstage | ||
``` | ||
GitHub secrets GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET are created by oauth app, alternativly they can get created by GitHub App: | ||
|
||
#### HINT | ||
[backstage.io documentation link](https://backstage.io/docs/integrations/github/github-apps) | ||
|
||
Difference between GitHub Apps and GitHub OAuth Apps: | ||
GitHub Apps handle OAuth scope at the app installation level, meaning that the scope parameter for the call to getAccessToken in the frontend has no effect. When calling getAccessToken in open source plugins, one should still include the appropriate scope, but also document in the plugin README what scopes are required for GitHub Apps. | ||
|
||
Authentication needs frontend and backend configuration | ||
- Backend: https://backstage.io/docs/auth/identity-resolver/ | ||
- Frontend: SignInPage | ||
|
||
### Scenario Examples | ||
- Authenticate Users to Backstage using their Github accounts | ||
- User Login | ||
- Perform API Actions on behalf of authenticated users, utilizing their permissions | ||
- Opening a PR or creating an Issue in behalf of a user | ||
- Access data that may require user specific scopes or to act as the user | ||
- User repositories, contributions | ||
|
||
#### Required Scopes | ||
- read:user: Access basic profile information | ||
- user:email: Access the user’s email addresses | ||
- repo: Access private repositories (if needed) | ||
- workflow: Access GitHub Actions workflows (if needed) | ||
- write:discussion: For creating or managing discussions (if your Backstage setup involves GitHub Discussions) | ||
|
||
### Scaffolder | ||
Integrated Identity Resolver | [backstage.io documentation link](https://backstage.io/docs/features/software-templates/writing-templates#accessing-the-signed-in-users-details) | ||
|
||
Integrated Authentication Capabilities | [backstage.io documentation link](https://backstage.io/docs/auth/#scaffolder-configuration-software-templates) | ||
|
||
tbd - access crontrol to certain parameter | ||
[Scaffolder and Permission framework](https://backstage.io/docs/features/software-templates/authorizing-scaffolder-template-details) | ||
|
||
### Token issuer | ||
Authentication backend generates and manages its own signing keys automatically for any issued backstage token | ||
They have short lifetime and do not persist after instance restarts! | ||
|
||
tbd - solution for this | ||
[backstage.io documentation link](https://backstage.io/docs/auth/#configuring-token-issuers) | ||
|
||
## Integrations | ||
|
||
### Purpose | ||
- Service account for automated GitHub API Requests | ||
- Allow Backstage to read or publish data using external providers (Github,…) | ||
- Performing static, non-user-specific tasks, such as reading repo data, fetching org information or indexing repos | ||
|
||
For github (located at root level in app-config.yaml since it is used by many Backstage core features) | ||
``` | ||
integrations: | ||
github: | ||
- host: github.com | ||
token: ${GITHUB_TOKEN} | ||
``` | ||
|
||
### Scenario Example | ||
- Github discovery processor | ||
- Scanning Github Repos for catalog files | ||
- Github API requests | ||
- Where admin don't want user specific access | ||
- CI/CD pipelines interacting with GitHub via Backstage | ||
- Backstage scanning GitHub repos and does not need user authentication (sign-in) | ||
- Running Github integration Plugin, that requires persistent access to certain data | ||
- Fetching GitHub Actions logs for a Backstage plugin | ||
|
||
#### Required Scopes | ||
- repo: Full control of private repositories (read/write) | ||
- read:org: Read access to organization membership | ||
- admin:org: If the token needs to manage organization settings (rare) | ||
- read:discussion: To read GitHub Discussions | ||
- workflow: To access workflow runs and logs | ||
- write:packages: If interacting with GitHub Packages | ||
|
||
## GitHub comparison | ||
|Feature|GitHub OAuth App|GitHub PAT| | ||
| ------ | ------ | ------ | | ||
|User Athentication|✅ Yes|❌ No| | ||
|Delegated User Permission|✅ Yes(based on user scopes)|❌ No| | ||
|Access to Private Repos|✅ Yes(if user grants access)|✅ Yes (with repo scope)| | ||
|Machine to GitHub API Access|❌ Limited (depends on user)|✅ Yes (using Service Account)| | ||
|CI/CD integration|❌ No, not ideal!|✅ Yes| | ||
|Setup Complexity|Medium|Low| | ||
|
||
## Best Practices in kubriX environment | ||
- We use **OAuth App** for user-related actions, user authentication, and any actions that need to happen on **behalf of a user**. | ||
- Use **PAT** for service-level access where **user context is not required**, such as scanning repositories, reading data, or performing automated tasks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for me it is not clear what these "required scopes" refer to. Are these specific settings in an oauth app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are the scopes the oauth app requests as additional permissions from customer they install app in their account or in that organization