Revert "Add restriction to importing keys : only keys with at least one Esisar's UID are valid."

This reverts commit fe9bf831e5.
esisar-restrictions
Simon Vareille 2020-02-08 14:23:32 +01:00
parent fe9bf831e5
commit bc741f7a8e
No known key found for this signature in database
GPG Key ID: 008AE8E706CC19F9
1 changed files with 6 additions and 20 deletions

View File

@ -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;
}
/**