-
Notifications
You must be signed in to change notification settings - Fork 70
/
component.ts
33 lines (32 loc) · 1.07 KB
/
component.ts
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
// Copyright (c) 2023 Sourcefuse Technologies
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {
Binding,
Component,
CoreBindings,
inject,
ProviderMap,
} from '@loopback/core';
import {Class, Model, Repository} from '@loopback/repository';
import {RestApplication} from '@loopback/rest';
import {SwaggerAuthenticationBindings} from './keys';
import {AuthenticateSwaggerMiddlewareInterceptor} from './middlewares';
import {HttpAuthenticationVerifierProvider} from './providers/http-authentication.verifier';
export class SwaggerAuthenticationComponent implements Component {
providers?: ProviderMap;
bindings: Binding[] = [];
repositories?: Class<Repository<Model>>[];
models?: Class<Model>[];
constructor(
@inject(CoreBindings.APPLICATION_INSTANCE)
private readonly application: RestApplication,
) {
this.providers = {
[SwaggerAuthenticationBindings.VERIFIER.key]:
HttpAuthenticationVerifierProvider,
};
this.application.middleware(AuthenticateSwaggerMiddlewareInterceptor);
}
}