From bc741f7a8e4304763f165d04cf656fe0d15c7728 Mon Sep 17 00:00:00 2001 From: Simon Vareille Date: Sat, 8 Feb 2020 14:23:32 +0100 Subject: [PATCH] Revert "Add restriction to importing keys : only keys with at least one Esisar's UID are valid." This reverts commit fe9bf831e5713a5d2dd83cedcd1a05e278c5b456. --- src/service/pgp.js | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/service/pgp.js b/src/service/pgp.js index 6a8316a..d1949ed 100644 --- a/src/service/pgp.js +++ b/src/service/pgp.js @@ -67,14 +67,9 @@ class PGP { } // check for at least one valid user id - const {userIds, status} = await this.parseUserIds(key.users, primaryKey, verifyDate); + const userIds = await this.parseUserIds(key.users, primaryKey, verifyDate); if (!userIds.length) { - if (status == 1) { - util.throw(400, 'Invalid PGP key: no user ID comes from Esisar'); - } - else { - util.throw(400, 'Invalid PGP key: invalid user IDs'); - } + util.throw(400, 'Invalid PGP key: invalid user IDs'); } // get algorithm details from primary key @@ -121,11 +116,10 @@ class PGP { /** * Parse an array of user ids and verify signatures - * @param {Array} users A list of openpgp.js user objects + * @param {Array} users A list of openpgp.js user objects * @param {Object} primaryKey The primary key packet of the key - * @param {Date} verifyDate Verify user IDs at this point in time - * @return {Array, integer} An array of user id objects and a satus indicator. - * Values of status : 0 if no error, 1 if no address comes from Esisar. + * @param {Date} verifyDate Verify user IDs at this point in time + * @return {Array} An array of user id objects */ async parseUserIds(users, primaryKey, verifyDate = new Date()) { if (!users || !users.length) { @@ -133,7 +127,6 @@ class PGP { } // at least one user id must be valid, revoked or expired const result = []; - var isFromEsisar = false; for (const user of users) { const userStatus = await user.verify(primaryKey, verifyDate); if (userStatus !== openpgp.enums.keyStatus.invalid && user.userId && user.userId.userid) { @@ -147,18 +140,11 @@ class PGP { email: util.normalizeEmail(uid.email), verified: false }); - if(/^([a-z0-9\-.]+)@([a-z0-9.\-]*)esisar\.grenoble-inp\.fr$/.test(util.normalizeEmail(uid.email))) - isFromEsisar = true; } } catch (e) {} } } - var status = 0; - if(!isFromEsisar){ - result.length = 0; - status = 1; - } - return {userIds: result, status: status}; + return result; } /**