|
1 | 1 | import { createBackend } from '@backstage/backend-defaults'; |
| 2 | +import { createBackendModule } from '@backstage/backend-plugin-api'; |
| 3 | +import { gitlabAuthenticator } from '@backstage/plugin-auth-backend-module-gitlab-provider'; |
| 4 | +import { |
| 5 | + authProvidersExtensionPoint, |
| 6 | + createOAuthProviderFactory, |
| 7 | +} from '@backstage/plugin-auth-node'; |
2 | 8 | import { |
3 | 9 | catalogPluginGitlabFillerProcessorModule, |
4 | 10 | gitlabPlugin, |
5 | 11 | } from '@immobiliarelabs/backstage-plugin-gitlab-backend'; |
6 | 12 |
|
| 13 | +const customAuth = createBackendModule({ |
| 14 | + // This ID must be exactly "auth" because that's the plugin it targets |
| 15 | + pluginId: 'auth', |
| 16 | + // This ID must be unique, but can be anything |
| 17 | + moduleId: 'custom-auth-provider', |
| 18 | + register(reg) { |
| 19 | + reg.registerInit({ |
| 20 | + deps: { providers: authProvidersExtensionPoint }, |
| 21 | + async init({ providers }) { |
| 22 | + providers.registerProvider({ |
| 23 | + providerId: 'gitlab', |
| 24 | + factory: createOAuthProviderFactory({ |
| 25 | + authenticator: gitlabAuthenticator, |
| 26 | + async signInResolver(info, ctx) { |
| 27 | + console.log(info); |
| 28 | + const userEntity = 'user:default/guest'; |
| 29 | + return ctx.issueToken({ |
| 30 | + claims: { |
| 31 | + sub: userEntity, |
| 32 | + ent: [userEntity], |
| 33 | + }, |
| 34 | + }); |
| 35 | + }, |
| 36 | + }), |
| 37 | + }); |
| 38 | + }, |
| 39 | + }); |
| 40 | + }, |
| 41 | +}); |
| 42 | + |
7 | 43 | const backend = createBackend(); |
8 | 44 |
|
9 | 45 | // Auth |
10 | 46 | backend.add(import('@backstage/plugin-auth-backend')); |
11 | | -backend.add(import('@backstage/plugin-auth-backend-module-guest-provider')); |
12 | | -backend.add(import('@backstage/plugin-auth-backend-module-gitlab-provider')); |
| 47 | +backend.add(customAuth); |
13 | 48 |
|
14 | 49 | // Catalog with Scaffolder module |
15 | 50 | backend.add(import('@backstage/plugin-catalog-backend')); |
|
0 commit comments