Add compatibility with other Linked Signature algorithms

This commit is contained in:
Chocobozzz 2018-10-23 11:38:48 +02:00
parent b83b8dd5ae
commit df66d81583
No known key found for this signature in database
GPG key ID: 583A612D890159BE
28 changed files with 1012 additions and 22 deletions

View file

@ -28,7 +28,7 @@ import { checkMissedConfig, checkFFmpeg } from './server/initializers/checker-be
// Do not use barrels because we don't want to load all modules here (we need to initialize database first)
import { logger } from './server/helpers/logger'
import { API_VERSION, CONFIG, CACHE } from './server/initializers/constants'
import { API_VERSION, CONFIG, CACHE, HTTP_SIGNATURE } from './server/initializers/constants'
const missed = checkMissedConfig()
if (missed.length !== 0) {
@ -96,6 +96,7 @@ import { RemoveOldJobsScheduler } from './server/lib/schedulers/remove-old-jobs-
import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-scheduler'
import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler'
import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler'
import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto'
// ----------- Command line -----------
@ -131,7 +132,11 @@ app.use(morgan('combined', {
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json({
type: [ 'application/json', 'application/*+json' ],
limit: '500kb'
limit: '500kb',
verify: (req: express.Request, _, buf: Buffer, encoding: string) => {
const valid = isHTTPSignatureDigestValid(buf, req)
if (valid !== true) throw new Error('Invalid digest')
}
}))
// Cookies
app.use(cookieParser())