1.0.0 • Published 3 months ago

@seatgeek/plugin-catalog-backend-module-okta v1.0.0

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

@seatgeek/plugin-catalog-backend-module-okta

npm latest version

This plugin offers the ability to ingest users and groups from the Okta API into the Backstage catalog.

Installation

Install the @seatgeek/catalog-backend-module-okta package in your backend package:

# From your Backstage root directory
yarn add --cwd packages/backend @seatgeek/catalog-backend-module-okta

Then add the following config to your app-config.yml:

catalog:
  providers:
    okta:
      myOrganizationOkta:
        apiToken: ${OKTA_TOKEN}
        url: https://my-organization.okta.com

Then import OktaOrgDiscoveryEntityProvider into your Backstage application's packages/backend/src/plugins/catalog.ts and add it to the CatalogBuilder.

import { OktaOrgDiscoveryEntityProvider } from '@seatgeek/plugin-catalog-backend-module-okta';

// ...

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  const builder = await CatalogBuilder.create(env);
  builder.addEntityProvider(
    ...OktaOrgDiscoveryEntityProvider.fromConfig(env.config, {
      logger: env.logger,
      schedule: env.scheduler.createScheduledTaskRunner({
        frequency: { days: 1 },
      }),
      // query params passed to the okta api groups request
      listGroupsRequest: {
        filter: 'type Eq "TEAM"',
      },
      // transforms the okta api user object into a UserEntity
      userTransformer: oktaUser => ({
        apiVersion: 'backstage.io/v1alpha1',
        kind: 'User',
        metadata: {
          name: oktaUser.profile!.email!.split('@')[0],
        },
        spec: {
          profile: {
            displayName: oktaUser.profile!.displayName!,
          },
          memberOf: [],
        },
      }),
      // transforms the group api user object into a GroupEntity
      groupTransformer: oktaGroup => ({
        apiVersion: 'backstage.io/v1alpha1',
        kind: 'Group',
        metadata: {
          name: oktaGroup.profile!.name!.toLowerCase(),
          description: oktaGroup.profile?.description || '',
        },
        type: 'team',
        children: [],
        profile: {
          displayName: oktaGroup.profile!.name!,
        },
      }),
    }),
  );
  // ...
}