0.1.0 • Published 8 months ago

@armyknife/backstage-github-auth v0.1.0

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

Backstage GitHub Authentication

This package provides GitHub authentication for Backstage.

Installation

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

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

Usage

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

auth:
  environment: development
  providers:
    github:
      development:
        clientId: ${GITHUB_CLIENT_ID}
        clientSecret: ${GITHUB_CLIENT_SECRET}
        # For GitHub Enterprise
        enterpriseInstanceUrl: ${GITHUB_ENTERPRISE_URL} # Optional: for GitHub Enterprise
        # For standard GitHub, you can omit this

# Catalog configuration for GitHub
catalog:
  providers:
    github:
      myGithubInstance:
        organization: ${GITHUB_ORGANIZATION} # Your GitHub organization
        catalogPath: /catalog-info.yaml # Path to catalog file
        filters:
          branch: main # Optional: default branch to use
        # For GitHub Enterprise
        host: ${GITHUB_ENTERPRISE_HOST} # Optional: for GitHub Enterprise
        # token is required for private repositories
        token: ${GITHUB_TOKEN}

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

import { githubAuthApiRef, GitHubAuth } from '@armyknife/backstage-github-auth';

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

Environment Variables

You'll need to set the following environment variables:

GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
GITHUB_ORGANIZATION=your-github-organization
GITHUB_TOKEN=your-github-personal-access-token

# For GitHub Enterprise
GITHUB_ENTERPRISE_URL=https://github.yourdomain.com
GITHUB_ENTERPRISE_HOST=github.yourdomain.com

License

Apache-2.0