Add ability to prevent OIDC redirect (#6544)
* Add ability to prevent OIDC redirect * Fix Typing on optional boolean * Fix lint * Fix lint * Rename var from PREVENT to DISABLE --------- Co-authored-by: Tom Moor <tom@getoutline.com>
This commit is contained in:
@@ -499,6 +499,16 @@ export class Environment {
|
||||
process.env.OIDC_USERINFO_URI
|
||||
);
|
||||
|
||||
/**
|
||||
* Disable autoredirect to the OIDC login page if there is only one
|
||||
* authentication method and that method is OIDC.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
public OIDC_DISABLE_REDIRECT = this.toOptionalBoolean(
|
||||
process.env.OIDC_DISABLE_REDIRECT
|
||||
);
|
||||
|
||||
/**
|
||||
* The OIDC logout endpoint.
|
||||
*/
|
||||
@@ -776,6 +786,26 @@ export class Environment {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string to an optional boolean. Supports the following:
|
||||
*
|
||||
* 0 = false
|
||||
* 1 = true
|
||||
* "true" = true
|
||||
* "false" = false
|
||||
* "" = undefined
|
||||
*
|
||||
* @param value The string to convert
|
||||
* @returns A boolean or undefined
|
||||
*/
|
||||
private toOptionalBoolean(value: string | undefined) {
|
||||
try {
|
||||
return value ? !!JSON.parse(value) : undefined;
|
||||
} catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const env = new Environment();
|
||||
|
||||
Reference in New Issue
Block a user