/
auth-microsoft.provider.ts
46 lines (42 loc) · 1.05 KB
/
auth-microsoft.provider.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
36
37
38
39
40
41
42
43
44
45
46
import {
MSAL_CONFIG,
MSAL_CONFIG_ANGULAR,
MsalAngularConfiguration,
MsalService
} from '@azure/msal-angular';
import { Configuration } from 'msal';
import { ConfigService } from '@igo2/core';
import { AuthMicrosoftOptions } from './auth.interface';
export function MSALConfigFactory(config: ConfigService): Configuration {
const msConf: AuthMicrosoftOptions = config.getConfig('auth.microsoft') || {};
return {
auth: {
clientId: msConf.clientId,
authority: 'https://login.microsoftonline.com/organizations', // 'common'
redirectUri: window.location.href
},
cache: {
cacheLocation: 'sessionStorage'
}
};
}
export function MSALAngularConfigFactory(): MsalAngularConfiguration {
return {
popUp: true,
consentScopes: ['user.read']
};
}
export function provideAuthMicrosoft() {
return [
{
provide: MSAL_CONFIG,
useFactory: MSALConfigFactory,
deps: [ConfigService]
},
{
provide: MSAL_CONFIG_ANGULAR,
useFactory: MSALAngularConfigFactory
},
MsalService
];
}