Config: Add identifier to all multi auth provider to AuthConfig

These are used in the /config private API call and needed to distinguish with which of the multiple auth providers a login should occur.
This also fixes the types of the multiple auth provider arrays to something that works, as `[{}]` specifics exactly on object in an array.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-03-01 21:07:43 +01:00 committed by David Mehren
parent e3f1d1b0f4
commit 22081756b0
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -40,19 +40,18 @@ export interface AuthConfig {
clientSecret: string;
apiKey: string;
};
gitlab: [
{
gitlab: {
identifier: string;
providerName: string;
baseURL: string;
clientID: string;
clientSecret: string;
scope: GitlabScope;
version: GitlabVersion;
},
];
}[];
// ToDo: tlsOptions exist in config.json.example. See https://nodejs.org/api/tls.html#tls_tls_connect_options_callback
ldap: [
{
ldap: {
identifier: string;
providerName: string;
url: string;
bindDn: string;
@ -63,10 +62,9 @@ export interface AuthConfig {
usernameField: string;
useridField: string;
tlsCa: string[];
},
];
saml: [
{
}[];
saml: {
identifier: string;
providerName: string;
idpSsoUrl: string;
idpCert: string;
@ -82,10 +80,9 @@ export interface AuthConfig {
username: string;
email: string;
};
},
];
oauth2: [
{
}[];
oauth2: {
identifier: string;
providerName: string;
baseURL: string;
userProfileURL: string;
@ -100,8 +97,7 @@ export interface AuthConfig {
scope: string;
rolesClaim: string;
accessRole: string;
},
];
}[];
}
const authSchema = Joi.object({
@ -146,6 +142,7 @@ const authSchema = Joi.object({
gitlab: Joi.array()
.items(
Joi.object({
identifier: Joi.string(),
providerName: Joi.string().default('Gitlab').optional(),
baseURL: Joi.string(),
clientID: Joi.string(),
@ -165,6 +162,7 @@ const authSchema = Joi.object({
ldap: Joi.array()
.items(
Joi.object({
identifier: Joi.string(),
providerName: Joi.string().default('LDAP').optional(),
url: Joi.string(),
bindDn: Joi.string().optional(),
@ -184,6 +182,7 @@ const authSchema = Joi.object({
saml: Joi.array()
.items(
Joi.object({
identifier: Joi.string(),
providerName: Joi.string().default('SAML').optional(),
idpSsoUrl: Joi.string(),
idpCert: Joi.string(),
@ -208,6 +207,7 @@ const authSchema = Joi.object({
oauth2: Joi.array()
.items(
Joi.object({
identifier: Joi.string(),
providerName: Joi.string().default('OAuth2').optional(),
baseURL: Joi.string(),
userProfileURL: Joi.string(),
@ -246,6 +246,7 @@ export default registerAs('authConfig', () => {
const gitlabs = gitlabNames.map((gitlabName) => {
return {
identifier: gitlabName,
providerName: process.env[`HD_AUTH_GITLAB_${gitlabName}_PROVIDER_NAME`],
baseURL: process.env[`HD_AUTH_GITLAB_${gitlabName}_BASE_URL`],
clientID: process.env[`HD_AUTH_GITLAB_${gitlabName}_CLIENT_ID`],
@ -257,6 +258,7 @@ export default registerAs('authConfig', () => {
const ldaps = ldapNames.map((ldapName) => {
return {
identifier: ldapName,
providerName: process.env[`HD_AUTH_LDAP_${ldapName}_PROVIDER_NAME`],
url: process.env[`HD_AUTH_LDAP_${ldapName}_URL`],
bindDn: process.env[`HD_AUTH_LDAP_${ldapName}_BIND_DN`],
@ -275,6 +277,7 @@ export default registerAs('authConfig', () => {
const samls = samlNames.map((samlName) => {
return {
identifier: samlName,
providerName: process.env[`HD_AUTH_SAML_${samlName}_PROVIDER_NAME`],
idpSsoUrl: process.env[`HD_AUTH_SAML_${samlName}_IDP_SSO_URL`],
idpCert: process.env[`HD_AUTH_SAML_${samlName}_IDP_CERT`],
@ -303,6 +306,7 @@ export default registerAs('authConfig', () => {
const oauth2s = oauth2Names.map((oauth2Name) => {
return {
identifier: oauth2Name,
providerName: process.env[`HD_AUTH_OAUTH2_${oauth2Name}_PROVIDER_NAME`],
baseURL: process.env[`HD_AUTH_OAUTH2_${oauth2Name}_BASE_URL`],
userProfileURL: