|
1 | 1 | import { RequestHandler } from 'express'; |
2 | 2 | import { auth } from 'express-openid-connect'; |
| 3 | +import { DependencyContainer } from 'tsyringe'; |
| 4 | +import { SERVICES } from '@src/common/constants'; |
| 5 | +import type { ConfigType } from '@src/common/config'; |
| 6 | + |
| 7 | +export function openidAuthMiddlewareFactory(container: DependencyContainer): RequestHandler { |
| 8 | + const config = container.resolve<ConfigType>(SERVICES.CONFIG); |
| 9 | + |
| 10 | + const authConfig = config.get('auth.openid'); |
3 | 11 |
|
4 | | -export function openidAuthMiddlewareFactory(): RequestHandler { |
5 | 12 | return auth({ |
6 | | - clientID: 'my-local-app', |
7 | | - issuerBaseURL: 'http://localhost:8080/realms/my-local-realm', |
8 | | - baseURL: 'http://localhost:5173', |
| 13 | + clientID: authConfig.clientId, |
| 14 | + issuerBaseURL: authConfig.issuerBaseUrl, |
| 15 | + baseURL: authConfig.baseUrl, |
9 | 16 | authRequired: true, |
10 | 17 | authorizationParams: { |
11 | 18 | // eslint-disable-next-line @typescript-eslint/naming-convention |
12 | 19 | response_type: 'code', |
13 | | - scope: 'openid profile email', |
| 20 | + scope: authConfig.scopes, |
14 | 21 | }, |
15 | | - secret: 'sdfsdasdsadsadsadsadsadas', |
16 | | - clientSecret: '78vaqxyFyyf1xeTHXzgzNlhCVtW83Zi7', |
| 22 | + secret: authConfig.secret, |
| 23 | + clientSecret: authConfig.clientSecret, |
17 | 24 | auth0Logout: false, |
18 | 25 | }); |
19 | 26 | } |
0 commit comments