Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
fe97dda2
Verified
Commit
fe97dda2
authored
Apr 26, 2021
by
les
Browse files
create instance in any case
parent
ddd0e6d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/federation/helpers.js
View file @
fe97dda2
...
...
@@ -27,7 +27,6 @@ const Helpers = {
]
if
(
urlToIgnore
.
includes
(
req
.
path
))
{
log
.
debug
(
`Ignore noisy fediverse
${
req
.
path
}
`
)
log
.
debug
(
req
)
return
res
.
status
(
404
).
send
(
'
Not Found
'
)
}
next
()
...
...
@@ -161,16 +160,17 @@ const Helpers = {
})
.
catch
(
e
=>
{
log
.
error
(
e
)
return
false
return
Instance
.
create
({
name
:
domain
,
domain
,
blocked
:
false
})
})
return
instance
},
// ref: https://blog.joinmastodon.org/2018/07/how-to-make-friends-and-verify-requests/
async
verifySignature
(
req
,
res
,
next
)
{
// TODO: why do I need instance?
const
instance
=
await
Helpers
.
getInstance
(
req
.
body
.
actor
)
if
(
!
instance
)
{
log
.
warn
(
`
[AP]
Verify Signature: Instance not found
${
req
.
body
.
actor
}
`
)
log
.
warn
(
`Verify Signature: Instance not found
${
req
.
body
.
actor
}
`
)
return
res
.
status
(
401
).
send
(
'
Instance not found
'
)
}
if
(
instance
.
blocked
)
{
...
...
@@ -188,11 +188,17 @@ const Helpers = {
return
res
.
status
(
401
).
send
(
'
User blocked
'
)
}
// little hack -> https://github.com/joyent/node-http-signature/pull/83
// req.headers.authorization = 'Signature ' + req.headers.signature
req
.
fedi_user
=
user
// TODO: check Digest // cannot do this with json bodyparser
// const digest = crypto.createHash('sha256')
// .update(req.body)
// .digest('base64')
// if (`SHA-256=${digest}` !== req.headers.signature) {
// log.warning(`Signature mismatch ${req.headers.signature} - ${digest}`)
// return res.status(401).send('Signature mismatch')
// }
// another little hack :/
// https://github.com/joyent/node-http-signature/issues/87
req
.
url
=
'
/federation
'
+
req
.
url
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment