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