0.1.0 • Published 8 months ago

@armyknife/backstage-gitlab-auth v0.1.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
8 months ago

Backstage GitLab Authentication

This package provides GitLab authentication for Backstage.

Installation

# npm
npm install @armyknife/backstage-gitlab-auth

# yarn
yarn add @armyknife/backstage-gitlab-auth

Usage

Create a file called app-config.gitlab.yaml in your Backstage root directory:

auth:
  environment: development
  providers:
    gitlab:
      development:
        clientId: ${GITLAB_CLIENT_ID}
        clientSecret: ${GITLAB_CLIENT_SECRET}
        # For self-hosted GitLab instances
        audience: https://gitlab.example.com
        # Optional: for self-hosted instances
        baseUrl: https://gitlab.example.com
        # Optional: for self-hosted instances
        apiBaseUrl: https://gitlab.example.com/api/v4

# Catalog configuration for GitLab
catalog:
  providers:
    gitlab:
      myGitlabInstance:
        host: gitlab.example.com # or gitlab.com for GitLab SaaS
        token: ${GITLAB_TOKEN}
        group: my-organization # Optional: filter by group
        entityFilename: catalog-info.yaml # Optional: default is catalog-info.yaml

Then, in your packages/app/src/App.tsx file:

import { gitlabAuthApiRef, GitLabAuth } from '@armyknife/backstage-gitlab-auth';

// Inside your createApp configuration:
apis: [
  // ... other API factories
  createApiFactory({
    api: gitlabAuthApiRef,
    deps: {
      discoveryApi: discoveryApiRef,
      oauthRequestApi: oauthRequestApiRef,
      configApi: configApiRef,
    },
    factory: ({ discoveryApi, oauthRequestApi, configApi }) =>
      GitLabAuth.create({
        discoveryApi,
        oauthRequestApi,
        configApi,
      }),
  }),
]

Environment Variables

You'll need to set the following environment variables:

GITLAB_CLIENT_ID=your-gitlab-client-id
GITLAB_CLIENT_SECRET=your-gitlab-client-secret
GITLAB_TOKEN=your-gitlab-personal-access-token

License

Apache-2.0