Skip to content

Commit

Permalink
Fix federation with Pleroma
Browse files Browse the repository at this point in the history
  • Loading branch information
shuymn committed Jul 29, 2023
1 parent dae93ff commit 42ba0ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/src/utils/http-signing.ts
Expand Up @@ -15,21 +15,21 @@ export async function signRequest(request: Request, key: CryptoKey, keyId: URL):
)
mySigner.alg = 'hs2019' as Algorithm

if (!request.headers.has('Date')) {
request.headers.set('Date', new Date().toUTCString())
}
if (!request.headers.has('Host')) {
const url = new URL(request.url)
request.headers.set('Host', url.host)
}

const components = ['@request-target', 'host']
const components = ['@request-target', 'date', 'host']
if (request.method == 'POST') {
components.push('digest')
}

await sign(request, {
components: components,
parameters: {
created: Math.floor(Date.now() / 1000),
},
keyId: keyId.toString(),
signer: mySigner,
})
Expand Down

0 comments on commit 42ba0ed

Please sign in to comment.