From 01746913f8e38c49e7b82da1744d392a0e7b56e4 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 4 Nov 2020 11:56:57 +0100 Subject: [PATCH 1/4] Fix password proofs created for registration not working --- src/models/UserPasswordComponent.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/models/UserPasswordComponent.ts b/src/models/UserPasswordComponent.ts index fab9b86..810ca9e 100644 --- a/src/models/UserPasswordComponent.ts +++ b/src/models/UserPasswordComponent.ts @@ -38,6 +38,7 @@ export class PasswordAuthProof implements AuthProof { public static createAuthorizedProofForRegistration(session: Express.Session): PasswordAuthProof { const proofForSession = new PasswordAuthProof(session); proofForSession.authorized = true; + proofForSession.forRegistration = true; proofForSession.save(); return proofForSession; } @@ -47,13 +48,15 @@ export class PasswordAuthProof implements AuthProof { } private readonly session: Express.Session; - private userId: number | null; private authorized: boolean; + private forRegistration: boolean = false; + private userId: number | null; private userPassword: UserPasswordComponent | null = null; private constructor(session: Express.Session) { this.session = session; this.authorized = session.auth_password_proof?.authorized || false; + this.forRegistration = session.auth_password_proof?.forRegistration || false; this.userId = session.auth_password_proof?.userId || null; } @@ -72,7 +75,8 @@ export class PasswordAuthProof implements AuthProof { } public async isValid(): Promise { - return Boolean(await this.getResource()); + return (this.forRegistration || Boolean(await this.getResource())) && + await this.isAuthorized(); } public async revoke(): Promise { @@ -98,6 +102,7 @@ export class PasswordAuthProof implements AuthProof { private save() { this.session.auth_password_proof = { authorized: this.authorized, + forRegistration: this.forRegistration, userId: this.userId, }; } From aebc03d5e9ae1edece20882cb3355c415a8e83d6 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 4 Nov 2020 11:57:16 +0100 Subject: [PATCH 2/4] Upgrade wms-core --- yarn.lock | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 57efc10..0a6c583 100644 --- a/yarn.lock +++ b/yarn.lock @@ -798,13 +798,20 @@ "@babel/types" "^7.4.4" esutils "^2.0.2" -"@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7": +"@babel/runtime@^7.8.4": version "7.12.1" resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz#b4116a6b6711d010b2dad3b7b6e43bf1b9954740" integrity sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA== dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.8.7": + version "7.12.5" + resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" + integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.10.4", "@babel/template@^7.3.3": version "7.10.4" resolved "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz#3251996c4200ebc71d1a8fc405fba940f36ba278" @@ -9387,9 +9394,9 @@ widest-line@^3.1.0: string-width "^4.0.0" wms-core@^0.22.0: - version "0.22.4" - resolved "https://registry.npmjs.org/wms-core/-/wms-core-0.22.4.tgz#220d94573add450758ab42dac0579dd2b0322277" - integrity sha512-tR8dbAVjRih9maeNVaHoBSNpXN1ctZ0G9jOASIIG9L6a/S011gGXTJCPhwNu9lzzMbeqxrgSF+LgJVfE2aml+g== + version "0.22.5" + resolved "https://registry.npmjs.org/wms-core/-/wms-core-0.22.5.tgz#7967cb63cf278e00a3cd05399502b72a90a4590a" + integrity sha512-2XnvNytgirZFpEmiB9WH6xQGr3ANhlMC85sZThdtkADVE1FFJqXVQ1V+F00SnChJvXvm5+5cT3T+lpm0pfrC1A== dependencies: argon2 "^0.27.0" compression "^1.7.4" From 43848e93a31f0bd9f08dad1153609b450776326f Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 4 Nov 2020 12:05:23 +0100 Subject: [PATCH 3/4] Fix registration password proof set too early --- src/controllers/AuthController.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/AuthController.ts b/src/controllers/AuthController.ts index 61ece83..6f5c3ab 100644 --- a/src/controllers/AuthController.ts +++ b/src/controllers/AuthController.ts @@ -88,8 +88,6 @@ export default class AuthController extends _AuthController { try { await this.getApp().as(AuthComponent).getAuthGuard().authenticateOrRegister(req.session, passwordAuthProof, undefined, async (connection, user) => { - passwordAuthProof.setResource(user); - const callbacks: RegisterCallback[] = []; // Password @@ -99,6 +97,9 @@ export default class AuthController extends _AuthController { user.as(UserNameComponent).name = req.body.username; return callbacks; + }, async (connection, user) => { + passwordAuthProof.setResource(user); + return []; }); } catch (e) { if (e instanceof PendingApprovalAuthError) { From 2ba40f9860034080f52f1ddc929572f68e7e1673 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 4 Nov 2020 12:05:43 +0100 Subject: [PATCH 4/4] Version 2.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index edb3f44..55547bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rainbox.email", - "version": "2.0.1", + "version": "2.0.2", "description": "ISP mail provider manager with mysql and integrated LDAP server", "repository": "https://gitlab.com/ArisuOngaku/rainbox.email", "author": "Alice Gaudon ",