-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmodule.ts
More file actions
50 lines (43 loc) · 1.27 KB
/
module.ts
File metadata and controls
50 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import {
coreServices,
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import { createRouter } from './service/router';
/**
* Coder OAuth backend plugin for the new Backstage backend system.
*
* This plugin provides OAuth authentication routes for Coder at /api/coder/oauth/callback.
*
* @public
*/
export default createBackendPlugin({
pluginId: 'coder',
register(env) {
env.registerInit({
deps: {
logger: coreServices.logger,
config: coreServices.rootConfig,
httpRouter: coreServices.httpRouter,
},
async init({ logger, config, httpRouter }) {
logger.info('Initializing Coder OAuth plugin');
const router = await createRouter({
logger: logger as any,
config,
});
// Allow unauthenticated access to OAuth routes
httpRouter.addAuthPolicy({
path: '/oauth',
allow: 'unauthenticated',
});
httpRouter.addAuthPolicy({
path: '/health',
allow: 'unauthenticated',
});
// Register the router (will be mounted at /api/coder)
httpRouter.use(router);
logger.info('Coder OAuth plugin initialized at /api/coder');
},
});
},
});