-
Notifications
You must be signed in to change notification settings - Fork 544
/
Copy pathoidc_auth_delayed.ts
35 lines (30 loc) · 1 KB
/
oidc_auth_delayed.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
34
35
import https = require('https');
import request = require('request');
import { Authenticator } from './auth';
import { User } from './config_types';
export class DelayedOpenIDConnectAuth implements Authenticator {
private delegate?: Authenticator;
public constructor() {
this.delegate = undefined;
}
public isAuthProvider(user: User): boolean {
if (!user.authProvider) {
return false;
}
return user.authProvider.name === 'oidc';
}
/**
* Setup the authentication header for oidc authed clients
* @param user user info
* @param opts request options
* @param overrideClient for testing, a preconfigured oidc client
*/
public async applyAuthentication(
user: User,
opts: request.Options | https.RequestOptions,
overrideClient?: any,
): Promise<void> {
const oidc = await import('./oidc_auth');
return new oidc.OpenIDConnectAuth().applyAuthentication(user, opts, overrideClient);
}
}