mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 17:56:30 -05:00
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:
parent
e3f1d1b0f4
commit
22081756b0
1 changed files with 65 additions and 61 deletions
|
@ -40,68 +40,64 @@ 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;
|
||||||
bindCredentials: string;
|
bindCredentials: string;
|
||||||
searchBase: string;
|
searchBase: string;
|
||||||
searchFilter: string;
|
searchFilter: string;
|
||||||
searchAttributes: string[];
|
searchAttributes: string[];
|
||||||
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;
|
clientCert: string;
|
||||||
clientCert: string;
|
issuer: string;
|
||||||
issuer: string;
|
identifierFormat: string;
|
||||||
identifierFormat: string;
|
disableRequestedAuthnContext: string;
|
||||||
disableRequestedAuthnContext: string;
|
groupAttribute: string;
|
||||||
groupAttribute: string;
|
requiredGroups: string[];
|
||||||
requiredGroups: string[];
|
externalGroups: string;
|
||||||
externalGroups: string;
|
attribute: {
|
||||||
attribute: {
|
id: string;
|
||||||
id: string;
|
username: string;
|
||||||
username: string;
|
email: string;
|
||||||
email: string;
|
};
|
||||||
};
|
}[];
|
||||||
},
|
oauth2: {
|
||||||
];
|
identifier: string;
|
||||||
oauth2: [
|
providerName: string;
|
||||||
{
|
baseURL: string;
|
||||||
providerName: string;
|
userProfileURL: string;
|
||||||
baseURL: string;
|
userProfileIdAttr: string;
|
||||||
userProfileURL: string;
|
userProfileUsernameAttr: string;
|
||||||
userProfileIdAttr: string;
|
userProfileDisplayNameAttr: string;
|
||||||
userProfileUsernameAttr: string;
|
userProfileEmailAttr: string;
|
||||||
userProfileDisplayNameAttr: string;
|
tokenURL: string;
|
||||||
userProfileEmailAttr: string;
|
authorizationURL: string;
|
||||||
tokenURL: string;
|
clientID: string;
|
||||||
authorizationURL: string;
|
clientSecret: string;
|
||||||
clientID: string;
|
scope: string;
|
||||||
clientSecret: string;
|
rolesClaim: string;
|
||||||
scope: string;
|
accessRole: string;
|
||||||
rolesClaim: 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:
|
||||||
|
|
Loading…
Reference in a new issue