-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathvalidateAuthConfig.ts
More file actions
24 lines (19 loc) · 919 Bytes
/
validateAuthConfig.ts
File metadata and controls
24 lines (19 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import type { Config } from './routes/Config.types';
const supportedAuthTypes = ['local', 'saml', 'saas'];
export default function validateAuthConfig(authConfig: Partial<Config['app']['auth']>) {
if (!authConfig.type || !supportedAuthTypes.includes(authConfig.type)) {
throw new Error(
'Authentication type was not configured properly. ' +
'Supported types are "local", "saml" and "saas". [auth.type]'
);
}
if (authConfig.type === 'saml' && !authConfig.certPath) {
throw new Error('SAML authentication is enabled, yet certificate path was not configured. [auth.certPath]');
}
if (!authConfig.loginPageUrl) {
throw new Error('Login page URL was not configured. [auth.loginPageUrl]');
}
if (!authConfig.afterLogoutUrl) {
throw new Error('After logout redirection URL was not configured. [auth.afterLogoutUrl]');
}
}