mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 23:54:42 -04:00
refactor(frontend-config): return auth providers as array
This change removes the customAuthNames property and redefines the authProviders property of the frontend-config DTO. Instead of an map from auth providers to their enabled-state (boolean), there is now an array that just includes the configured auth providers while also having the identifier and providerName of custom auth providers. Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
dcfb00adc1
commit
20b0ded223
3 changed files with 229 additions and 234 deletions
|
@ -17,9 +17,9 @@ import externalServicesConfiguration, {
|
|||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
||||
import {
|
||||
AuthProviders,
|
||||
AuthProviderDto,
|
||||
AuthProviderType,
|
||||
BrandingDto,
|
||||
CustomAuthNamesDto,
|
||||
FrontendConfigDto,
|
||||
IframeCommunicationDto,
|
||||
SpecialUrlsDto,
|
||||
|
@ -48,7 +48,6 @@ export class FrontendConfigService {
|
|||
allowRegister: this.authConfig.local.enableRegister,
|
||||
authProviders: this.getAuthProviders(),
|
||||
branding: this.getBranding(),
|
||||
customAuthNames: this.getCustomAuthNames(),
|
||||
iframeCommunication: this.getIframeCommunication(),
|
||||
maxDocumentLength: this.appConfig.maxDocumentLength,
|
||||
plantUmlServer: this.externalServicesConfig.plantUmlServer
|
||||
|
@ -60,48 +59,67 @@ export class FrontendConfigService {
|
|||
};
|
||||
}
|
||||
|
||||
private getAuthProviders(): AuthProviders {
|
||||
return {
|
||||
dropbox: !!this.authConfig.dropbox.clientID,
|
||||
facebook: !!this.authConfig.facebook.clientID,
|
||||
github: !!this.authConfig.github.clientID,
|
||||
gitlab: this.authConfig.gitlab.length !== 0,
|
||||
google: !!this.authConfig.google.clientID,
|
||||
local: this.authConfig.local.enableLogin,
|
||||
ldap: this.authConfig.ldap.length !== 0,
|
||||
oauth2: this.authConfig.oauth2.length !== 0,
|
||||
saml: this.authConfig.saml.length !== 0,
|
||||
twitter: !!this.authConfig.twitter.consumerKey,
|
||||
};
|
||||
}
|
||||
|
||||
private getCustomAuthNames(): CustomAuthNamesDto {
|
||||
return {
|
||||
gitlab: this.authConfig.gitlab.map((entry) => {
|
||||
return {
|
||||
identifier: entry.identifier,
|
||||
providerName: entry.providerName,
|
||||
};
|
||||
}),
|
||||
ldap: this.authConfig.ldap.map((entry) => {
|
||||
return {
|
||||
identifier: entry.identifier,
|
||||
providerName: entry.providerName,
|
||||
};
|
||||
}),
|
||||
oauth2: this.authConfig.oauth2.map((entry) => {
|
||||
return {
|
||||
identifier: entry.identifier,
|
||||
providerName: entry.providerName,
|
||||
};
|
||||
}),
|
||||
saml: this.authConfig.saml.map((entry) => {
|
||||
return {
|
||||
identifier: entry.identifier,
|
||||
providerName: entry.providerName,
|
||||
};
|
||||
}),
|
||||
};
|
||||
private getAuthProviders(): AuthProviderDto[] {
|
||||
const providers: AuthProviderDto[] = [];
|
||||
if (this.authConfig.local.enableLogin) {
|
||||
providers.push({
|
||||
type: AuthProviderType.LOCAL,
|
||||
});
|
||||
}
|
||||
if (this.authConfig.dropbox.clientID) {
|
||||
providers.push({
|
||||
type: AuthProviderType.DROPBOX,
|
||||
});
|
||||
}
|
||||
if (this.authConfig.facebook.clientID) {
|
||||
providers.push({
|
||||
type: AuthProviderType.FACEBOOK,
|
||||
});
|
||||
}
|
||||
if (this.authConfig.github.clientID) {
|
||||
providers.push({
|
||||
type: AuthProviderType.GITHUB,
|
||||
});
|
||||
}
|
||||
if (this.authConfig.google.clientID) {
|
||||
providers.push({
|
||||
type: AuthProviderType.GOOGLE,
|
||||
});
|
||||
}
|
||||
if (this.authConfig.twitter.consumerKey) {
|
||||
providers.push({
|
||||
type: AuthProviderType.TWITTER,
|
||||
});
|
||||
}
|
||||
this.authConfig.gitlab.forEach((gitLabEntry) => {
|
||||
providers.push({
|
||||
type: AuthProviderType.GITLAB,
|
||||
providerName: gitLabEntry.providerName,
|
||||
identifier: gitLabEntry.identifier,
|
||||
});
|
||||
});
|
||||
this.authConfig.ldap.forEach((ldapEntry) => {
|
||||
providers.push({
|
||||
type: AuthProviderType.LDAP,
|
||||
providerName: ldapEntry.providerName,
|
||||
identifier: ldapEntry.identifier,
|
||||
});
|
||||
});
|
||||
this.authConfig.oauth2.forEach((oauth2Entry) => {
|
||||
providers.push({
|
||||
type: AuthProviderType.OAUTH2,
|
||||
providerName: oauth2Entry.providerName,
|
||||
identifier: oauth2Entry.identifier,
|
||||
});
|
||||
});
|
||||
this.authConfig.saml.forEach((samlEntry) => {
|
||||
providers.push({
|
||||
type: AuthProviderType.SAML,
|
||||
providerName: samlEntry.providerName,
|
||||
identifier: samlEntry.identifier,
|
||||
});
|
||||
});
|
||||
return providers;
|
||||
}
|
||||
|
||||
private getBranding(): BrandingDto {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue