handle errors during signature validation. use lowercase in ids

This commit is contained in:
Will Murphy 2019-09-25 21:45:52 -05:00
parent e47dd9286f
commit bf58e27748
3 changed files with 27 additions and 18 deletions

View file

@ -0,0 +1,4 @@
db.objects.find({type: "Group"}).forEach(function(d){
d.id = d.id.toLowerCase();
db.objects.save(d);
});

View file

@ -16,6 +16,7 @@ function auth (req, res, next) {
} }
async function verifySignature (req, res, next) { async function verifySignature (req, res, next) {
try {
if (!req.get('authorization') && !req.get('signature')) { if (!req.get('authorization') && !req.get('signature')) {
// support for apps not using signature extension to ActivityPub // support for apps not using signature extension to ActivityPub
const actor = await pub.object.resolveObject(pub.utils.actorFromActivity(req.body)) const actor = await pub.object.resolveObject(pub.utils.actorFromActivity(req.body))
@ -33,4 +34,8 @@ async function verifySignature (req, res, next) {
return res.status(400).send('Invalid http signature') return res.status(400).send('Invalid http signature')
} }
next() next()
} catch (err) {
console.log('error during signature verification', err)
return res.status(500).send()
}
} }

View file

@ -38,21 +38,21 @@ function toJSONLD (obj) {
} }
function usernameToIRI (user) { function usernameToIRI (user) {
return `https://${config.DOMAIN}/u/${user}` return `https://${config.DOMAIN}/u/${user}`.toLowerCase()
} }
function objectIdToIRI (oid) { function objectIdToIRI (oid) {
if (oid.toHexString) { if (oid.toHexString) {
oid = oid.toHexString() oid = oid.toHexString()
} }
return `https://${config.DOMAIN}/o/${oid}` return `https://${config.DOMAIN}/o/${oid}`.toLowerCase()
} }
function actvityIdToIRI (oid) { function actvityIdToIRI (oid) {
if (oid.toHexString) { if (oid.toHexString) {
oid = oid.toHexString() oid = oid.toHexString()
} }
return `https://${config.DOMAIN}/s/${oid}` return `https://${config.DOMAIN}/s/${oid}`.toLowerCase()
} }
function validateObject (object) { function validateObject (object) {