feat: change email auth config to local

This was done to use the same term. Also email was the old term from HedgeDoc 1 and wildly inaccurate. As we never checked any mail addresses, in fact it was more of a username than anything else.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-09-04 19:24:32 +02:00 committed by David Mehren
parent 43242cccc9
commit e7eb6694a6
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
5 changed files with 24 additions and 24 deletions

View file

@ -17,9 +17,9 @@ import {
export interface AuthConfig {
session: {
secret: string;
lifeTime: number;
lifetime: number;
};
email: {
local: {
enableLogin: boolean;
enableRegister: boolean;
};
@ -108,20 +108,20 @@ export interface AuthConfig {
const authSchema = Joi.object({
session: {
secret: Joi.string().label('HD_SESSION_SECRET'),
lifeTime: Joi.number()
.default(100000)
lifetime: Joi.number()
.default(1209600000) // 14 * 24 * 60 * 60 * 1000ms = 14 days
.optional()
.label('HD_SESSION_LIFE_TIME'),
.label('HD_SESSION_LIFETIME'),
},
email: {
local: {
enableLogin: Joi.boolean()
.default(false)
.optional()
.label('HD_AUTH_EMAIL_ENABLE_LOGIN'),
.label('HD_AUTH_LOCAL_ENABLE_LOGIN'),
enableRegister: Joi.boolean()
.default(false)
.optional()
.label('HD_AUTH_EMAIL_ENABLE_REGISTER'),
.label('HD_AUTH_LOCAL_ENABLE_REGISTER'),
},
facebook: {
clientID: Joi.string().optional().label('HD_AUTH_FACEBOOK_CLIENT_ID'),
@ -211,7 +211,7 @@ const authSchema = Joi.object({
attribute: {
id: Joi.string().default('NameId').optional(),
username: Joi.string().default('NameId').optional(),
email: Joi.string().default('NameId').optional(),
local: Joi.string().default('NameId').optional(),
},
}).optional(),
)
@ -309,7 +309,7 @@ export default registerAs('authConfig', () => {
attribute: {
id: process.env[`HD_AUTH_SAML_${samlName}_ATTRIBUTE_ID`],
username: process.env[`HD_AUTH_SAML_${samlName}_ATTRIBUTE_USERNAME`],
email: process.env[`HD_AUTH_SAML_${samlName}_ATTRIBUTE_USERNAME`],
local: process.env[`HD_AUTH_SAML_${samlName}_ATTRIBUTE_USERNAME`],
},
};
});
@ -346,11 +346,11 @@ export default registerAs('authConfig', () => {
{
session: {
secret: process.env.HD_SESSION_SECRET,
lifeTime: parseOptionalInt(process.env.HD_SESSION_LIFE_TIME),
lifetime: parseOptionalInt(process.env.HD_SESSION_LIFETIME),
},
email: {
enableLogin: process.env.HD_AUTH_EMAIL_ENABLE_LOGIN,
enableRegister: process.env.HD_AUTH_EMAIL_ENABLE_REGISTER,
local: {
enableLogin: process.env.HD_AUTH_LOCAL_ENABLE_LOGIN,
enableRegister: process.env.HD_AUTH_LOCAL_ENABLE_REGISTER,
},
facebook: {
clientID: process.env.HD_AUTH_FACEBOOK_CLIENT_ID,

View file

@ -8,9 +8,9 @@ import { registerAs } from '@nestjs/config';
export default registerAs('authConfig', () => ({
session: {
secret: 'my_secret',
lifeTime: 1209600000,
lifetime: 1209600000,
},
email: {
local: {
enableLogin: true,
enableRegister: true,
},

View file

@ -71,10 +71,10 @@ export class AuthProviders {
oauth2: boolean;
/**
* Is internal auth available?
* Is local auth available?
*/
@IsBoolean()
internal: boolean;
local: boolean;
}
export class BrandingDto {

View file

@ -25,9 +25,9 @@ describe('FrontendConfigService', () => {
const emptyAuthConfig: AuthConfig = {
session: {
secret: 'my-secret',
lifeTime: 1209600000,
lifetime: 1209600000,
},
email: {
local: {
enableLogin: false,
enableRegister: false,
},
@ -197,7 +197,7 @@ describe('FrontendConfigService', () => {
};
const authConfig: AuthConfig = {
...emptyAuthConfig,
email: {
local: {
enableLogin,
enableRegister,
},
@ -262,7 +262,7 @@ describe('FrontendConfigService', () => {
expect(config.authProviders.google).toEqual(
!!authConfig.google.clientID,
);
expect(config.authProviders.internal).toEqual(
expect(config.authProviders.local).toEqual(
enableLogin,
);
expect(config.authProviders.twitter).toEqual(

View file

@ -44,7 +44,7 @@ export class FrontendConfigService {
return {
// ToDo: use actual value here
allowAnonymous: false,
allowRegister: this.authConfig.email.enableRegister,
allowRegister: this.authConfig.local.enableRegister,
authProviders: this.getAuthProviders(),
branding: this.getBranding(),
customAuthNames: this.getCustomAuthNames(),
@ -66,7 +66,7 @@ export class FrontendConfigService {
github: !!this.authConfig.github.clientID,
gitlab: this.authConfig.gitlab.length !== 0,
google: !!this.authConfig.google.clientID,
internal: this.authConfig.email.enableLogin,
local: this.authConfig.local.enableLogin,
ldap: this.authConfig.ldap.length !== 0,
oauth2: this.authConfig.oauth2.length !== 0,
saml: this.authConfig.saml.length !== 0,