backstage: š Bug Report: Trying to add custom SCMAUTH for GHE. Documentation not so clear
š Description
Hello,
We were able to build and deploy backstage in an OpenShift cluster, but now we want to use the user token for the user currently logged in backstage.
We configured the authentication and user/groups for GHE and is working properly. The user can authenticate with corporate GHE user and we can see the user details in the settings page. Also we can āchooseā a template that publish a repo in the organization.
But we also wanted to use the
requestUserCredentials:
secretsKey: USER_OAUTH_TOKEN
in a template to allow the user to publish in his own GHE account. So we tried to follow
this https://backstage.io/docs/auth/#scaffolder-configuration-software-templates
If you want to use the authentication capabilities of the [Repository Picker](https://backstage.io/docs/features/software-templates/writing-templates#the-repository-picker) inside your software templates you will need to configure the [ScmAuthApi](https://backstage.io/docs/reference/integration-react.scmauthapi) alongside your authentication provider. It is an API used to authenticate towards different SCM systems in a generic way, based on what resource is being accessed.
and https://backstage.io/docs/auth/#custom-scmauthapi-implementation
to implement a new ScmAuthAPI for GHE, but we canāt build the image in Openshift in Dockerfile. We are getting compile errors
š Expected behavior
A correct build
š Actual Behavior with Screenshots
[2/3] STEP 14/15: RUN --mount=type=cache,target=/opt/app-root/src/.cache/yarn,uid=1001,gid=0 yarn tsc && yarn --cwd packages/backend build yarn run v1.22.21 $ tsc [96mpackages/app/src/apis.ts[0m:[93m39[0m:[93m29[0m - [91merror[0m[90m TS2304: [0mCannot find name āApiRefā.
[7m39[0m export const gheAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & SessionApi> = [7m [0m [91m ~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m39[0m:[93m29[0m - [91merror[0m[90m TS4025: [0mExported variable āgheAuthApiRefā has or is using private name āApiRefā.
[7m39[0m export const gheAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & SessionApi> = [7m [0m [91m ~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m39[0m:[93m36[0m - [91merror[0m[90m TS2304: [0mCannot find name āOAuthApiā.
[7m39[0m export const gheAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & SessionApi> = [7m [0m [91m ~~~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m39[0m:[93m36[0m - [91merror[0m[90m TS4025: [0mExported variable āgheAuthApiRefā has or is using private name āOAuthApiā.
[7m39[0m export const gheAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & SessionApi> = [7m [0m [91m ~~~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m39[0m:[93m47[0m - [91merror[0m[90m TS2304: [0mCannot find name āProfileInfoApiā.
[7m39[0m export const gheAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & SessionApi> = [7m [0m [91m ~~~~~~~~~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m39[0m:[93m47[0m - [91merror[0m[90m TS4025: [0mExported variable āgheAuthApiRefā has or is using private name āProfileInfoApiā.
[7m39[0m export const gheAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & SessionApi> = [7m [0m [91m ~~~~~~~~~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m39[0m:[93m64[0m - [91merror[0m[90m TS2304: [0mCannot find name āSessionApiā.
[7m39[0m export const gheAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & SessionApi> = [7m [0m [91m ~~~~~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m39[0m:[93m64[0m - [91merror[0m[90m TS4025: [0mExported variable āgheAuthApiRefā has or is using private name āSessionApiā.
[7m39[0m export const gheAuthApiRef: ApiRef<OAuthApi & ProfileInfoApi & SessionApi> = [7m [0m [91m ~~~~~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m59[0m:[93m7[0m - [91merror[0m[90m TS2304: [0mCannot find name āGithubAuthā.
[7m59[0m GithubAuth.create({ [7m [0m [91m ~~~~~~~~~~[0m
[96mpackages/app/src/apis.ts[0m:[93m77[0m:[93m27[0m - [91merror[0m[90m TS2345: [0mArgument of type āunknownā is not assignable to parameter of type āOAuthApiā.
[7m77[0m ScmAuth.forGithub(gheAuthApi, { [7m [0m [91m ~~~~~~~~~~[0m
[96mpackages/backend/src/plugins/kubernetes.ts[0m:[93m10[0m:[93m60[0m - [91merror[0m[90m TS2345: [0mArgument of type ā{ logger: winston.Logger; config: Config; catalogApi: CatalogClient; }ā is not assignable to parameter of type āKubernetesEnvironmentā. Property āpermissionsā is missing in type ā{ logger: winston.Logger; config: Config; catalogApi: CatalogClient; }ā but required in type āKubernetesEnvironmentā.
[7m 10[0m const { router } = await KubernetesBuilder.createBuilder({
[7m [0m [91m ~[0m
[7m 11[0m logger: env.logger,
[7m [0m [91m~~~~~~~~[0m~[0m
[7m 14[0m }).build();
[7m [0m [91m[0m
[7mā¦[0m
[7m 13[0m catalogApi,
[7m [0m [91m
[96mnode_modules/@backstage/plugin-kubernetes-backend/dist/index.d.ts[0m:[93m272[0m:[93m5[0m [7m272[0m permissions: PermissionEvaluator; [7m [0m [96m ~~~~~~~~~~~[0m āpermissionsā is declared here.
Found 11 errors in 2 files.
Errors Files 10 packages/app/src/apis.ts[90m:39[0m 1 packages/backend/src/plugins/kubernetes.ts[90m:10[0m
š Reproduction steps
yarn install --verbose --frozen-lockfile --network-timeout 600000
š Provide the context for the Bug.
No response
š„ļø Your Environment
OS: Linux 4.4.0-19041-Microsoft - linux/x64 node: v18.14.0 yarn: 1.22.19 cli: 0.25.1 (installed) backstage: 1.22.1
Dependencies: @backstage/app-defaults 1.4.7 @backstage/backend-app-api 0.5.10 @backstage/backend-common 0.20.1 @backstage/backend-dev-utils 0.1.3 @backstage/backend-openapi-utils 0.1.2 @backstage/backend-plugin-api 0.6.9 @backstage/backend-tasks 0.5.14 @backstage/catalog-client 1.5.2 @backstage/catalog-model 1.4.3 @backstage/cli-common 0.1.13 @backstage/cli-node 0.2.2 @backstage/cli 0.25.1 @backstage/config-loader 1.6.1 @backstage/config 1.1.1 @backstage/core-app-api 1.11.3 @backstage/core-compat-api 0.1.1 @backstage/core-components 0.13.10 @backstage/core-plugin-api 1.8.2 @backstage/errors 1.2.3 @backstage/eslint-plugin 0.1.4 @backstage/frontend-plugin-api 0.5.0 @backstage/integration-aws-node 0.1.8 @backstage/integration-react 1.1.23 @backstage/integration 1.8.0 @backstage/plugin-api-docs 0.10.3 @backstage/plugin-app-backend 0.3.57 @backstage/plugin-app-node 0.1.9 @backstage/plugin-auth-backend-module-atlassian-provider 0.1.1 @backstage/plugin-auth-backend-module-gcp-iap-provider 0.2.3 @backstage/plugin-auth-backend-module-github-provider 0.1.6 @backstage/plugin-auth-backend-module-gitlab-provider 0.1.6 @backstage/plugin-auth-backend-module-google-provider 0.1.6 @backstage/plugin-auth-backend-module-oauth2-provider 0.1.6 @backstage/plugin-auth-backend-module-oauth2-proxy-provider 0.1.1 @backstage/plugin-auth-backend-module-okta-provider 0.0.2 @backstage/plugin-auth-backend 0.20.3 @backstage/plugin-auth-node 0.4.3 @backstage/plugin-catalog-backend-module-github 0.4.7 @backstage/plugin-catalog-backend-module-scaffolder-entity-model 0.1.6 @backstage/plugin-catalog-backend 1.16.1 @backstage/plugin-catalog-common 1.0.20 @backstage/plugin-catalog-graph 0.3.3 @backstage/plugin-catalog-import 0.10.5 @backstage/plugin-catalog-node 1.6.1 @backstage/plugin-catalog-react 1.9.3 @backstage/plugin-catalog 1.16.1 @backstage/plugin-events-node 0.2.18 @backstage/plugin-github-actions 0.6.10 @backstage/plugin-kubernetes-backend 0.14.1 @backstage/plugin-kubernetes-common 0.7.3 @backstage/plugin-kubernetes-node 0.1.3 @backstage/plugin-kubernetes-react 0.2.1 @backstage/plugin-kubernetes 0.11.4 @backstage/plugin-org 0.6.19 @backstage/plugin-permission-common 0.7.12 @backstage/plugin-permission-node 0.7.20 @backstage/plugin-permission-react 0.4.19 @backstage/plugin-proxy-backend 0.4.7 @backstage/plugin-scaffolder-backend-module-azure 0.1.1 @backstage/plugin-scaffolder-backend-module-bitbucket 0.1.1 @backstage/plugin-scaffolder-backend-module-gerrit 0.1.1 @backstage/plugin-scaffolder-backend-module-github 0.1.1 @backstage/plugin-scaffolder-backend-module-gitlab 0.2.12 @backstage/plugin-scaffolder-backend 1.20.0 @backstage/plugin-scaffolder-common 1.4.5 @backstage/plugin-scaffolder-node 0.2.10 @backstage/plugin-scaffolder-react 1.7.1 @backstage/plugin-scaffolder 1.17.1 @backstage/plugin-search-backend-module-catalog 0.1.13 @backstage/plugin-search-backend-module-pg 0.5.18 @backstage/plugin-search-backend-module-techdocs 0.1.13 @backstage/plugin-search-backend-node 1.2.13 @backstage/plugin-search-backend 1.4.9 @backstage/plugin-search-common 1.2.10 @backstage/plugin-search-react 1.7.5 @backstage/plugin-search 1.4.5 @backstage/plugin-tech-radar 0.6.12 @backstage/plugin-techdocs-backend 1.9.2 @backstage/plugin-techdocs-module-addons-contrib 1.1.4 @backstage/plugin-techdocs-node 1.11.1 @backstage/plugin-techdocs-react 1.1.15 @backstage/plugin-techdocs 1.9.3 @backstage/plugin-user-settings 0.8.0 @backstage/release-manifests 0.0.11 @backstage/test-utils 1.4.7 @backstage/theme 0.5.0 @backstage/types 1.1.1 @backstage/version-bridge 1.0.7
š Have you spent some time to check if this bug has been raised before?
- I checked and didnāt find similar issue
š¢ Have you read the Code of Conduct?
- I have read the Code of Conduct
Are you willing to submit PR?
No, I donāt have time to work on this right now
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 18 (6 by maintainers)
Hi @benjdlambert
More infoā¦
In local itās working correctly, Iāve created an OAuth App for local development with
and another OAuth App for Openshift with
With backstage in local I receive a popup request to do the login, for this permission
Then, when requesting the location from template
Iām getting another logging
and requesting more permissions
and Iām not getting the error
No auth provider available for 'https://github.ourcompany.com/user-account/testRepo', see https://backstage.io/link?scm-authAnd I can create the repo in a personal GHE account.
But the same code, in Openshift, Iām only getting the first login, and for the location Iām receiving the
No auth provider available for 'https://github.ourcompany.com/user-account/testRepo', see https://backstage.io/link?scm-authThe only difference between local and Openshift is in app-config.yaml, the baseUrl for app and backend