removed audit info from user object

This commit is contained in:
Andris Reinman 2019-10-02 11:35:31 +03:00
parent 7c5bf84c52
commit 7b8a863125
4 changed files with 16 additions and 69 deletions

View file

@ -17,13 +17,13 @@
},
"userlisting": {
"read:any": ["*", "!audit"]
"read:any": ["*"]
},
"users": {
"create:any": ["*", "!audit"],
"read:any": ["*", "!audit"],
"update:any": ["*", "!audit"],
"create:any": ["*"],
"read:any": ["*"],
"update:any": ["*"],
"delete:any": ["*"]
},
@ -108,13 +108,13 @@
},
"userlisting": {
"read:any": ["*", "!audit"]
"read:any": ["*"]
},
"users": {
"create:any": ["*", "!audit"],
"read:any": ["*", "!audit"],
"update:any": ["*", "!audit"],
"create:any": ["*"],
"read:any": ["*"],
"update:any": ["*"],
"delete:any": ["*"]
},
@ -167,8 +167,8 @@
},
"users": {
"read:any": ["*", "!audit"],
"update:any": ["*", "!audit"]
"read:any": ["*"],
"update:any": ["*"]
},
"asps": {
@ -237,12 +237,12 @@
},
"userlisting": {
"read:own": ["*", "!tags", "!metaData", "!disabledScopes", "!audit"]
"read:own": ["*", "!tags", "!metaData", "!disabledScopes"]
},
"users": {
"read:own": ["*", "!tags", "!metaData", "!disabledScopes", "!audit"],
"update:own": ["*", "!tags", "!metaData", "!disabledScopes", "!audit"]
"read:own": ["*", "!tags", "!metaData", "!disabledScopes"],
"update:own": ["*", "!tags", "!metaData", "!disabledScopes"]
},
"asps": {
@ -314,10 +314,7 @@
"audit": {
"users": {
"create:any": ["*"],
"read:any": ["*"],
"update:any": ["*"],
"delete:any": ["*"]
"read:any": ["*"]
},
"audit": {

View file

@ -247,8 +247,7 @@ module.exports = (db, server, userHandler) => {
disabled: true,
password: true,
encryptMessages: true,
encryptForwarded: true,
audit: true
encryptForwarded: true
}
},
// _id gets removed in response if not explicitly set in paginatedField
@ -298,7 +297,6 @@ module.exports = (db, server, userHandler) => {
allowed: Number(userData.quota) || config.maxStorage * 1024 * 1024,
used: Math.max(Number(userData.storageUsed) || 0, 0)
},
audit: userData.audit || false,
hasPasswordSet: !!userData.password || !!userData.tempPassword,
activated: userData.activated,
disabled: userData.disabled
@ -540,12 +538,6 @@ module.exports = (db, server, userHandler) => {
.truthy(['Y', 'true', 'yes', 'on', '1', 1])
.falsy(['N', 'false', 'no', 'off', '0', 0, ''])
.default(false),
audit: Joi.string()
.empty('')
.hex()
.lowercase()
.length(24)
.allow(false),
sess: Joi.string().max(255),
ip: Joi.string().ip({
@ -591,10 +583,6 @@ module.exports = (db, server, userHandler) => {
// filter out unallowed fields
result.value = permission.filter(result.value);
if (result.value.audit) {
result.value.audit = new ObjectID(result.value.audit);
}
let targets = result.value.targets;
if (targets) {
@ -1179,7 +1167,6 @@ module.exports = (db, server, userHandler) => {
tags: userData.tags || [],
disabledScopes: userData.disabledScopes || [],
audit: userData.audit || false,
hasPasswordSet: !!userData.password || !!userData.tempPassword,
activated: userData.activated,
disabled: userData.disabled
@ -1347,13 +1334,6 @@ module.exports = (db, server, userHandler) => {
.max(128)
),
audit: Joi.string()
.empty('')
.hex()
.lowercase()
.length(24)
.allow(false),
disabledScopes: Joi.array()
.items(Joi.string().valid(...consts.SCOPES))
.unique(),
@ -1393,10 +1373,6 @@ module.exports = (db, server, userHandler) => {
req.validate(permission);
result.value = permission.filter(result.value);
if (result.value.audit) {
result.value.audit = new ObjectID(result.value.audit);
}
if (result.value.password && !result.value.hashedPassword && !result.value.allowUnsafe) {
try {
let count = await pwnedpasswords(result.value.password);

View file

@ -59,31 +59,6 @@ class AuditHandler {
auditData._id = r.insertedId;
try {
// NB! this user might not exist anymore, so do not check if any users were updated or not
await this.users.collection('users').updateOne(
{
_id: auditData.user
},
{
$addToSet: {
audit: auditData._id
}
}
);
} catch (err) {
// try to rollback
err.code = err.code = 'InternalDatabaseError';
try {
await this.database.collection('audits').deleteOne({ _id: auditData._id });
} catch (e) {
// ignore
}
throw err;
}
try {
let now = new Date();
await this.database.collection('tasks').insertOne({

View file

@ -71,8 +71,7 @@ class FilterHandler {
encryptMessages: true,
encryptForwarded: true,
pubKey: true,
spamLevel: true,
audit: true
spamLevel: true
};
if (collection === 'users') {