From ce33ee01cd3806201b676c318e9aa930032921b2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 18 Dec 2017 11:53:04 +0100 Subject: Use RsaSignature2017 --- server/controllers/api/videos/index.ts | 2 -- server/helpers/activitypub.ts | 4 ++-- server/helpers/custom-jsonld-signature.ts | 6 +++--- server/helpers/custom-validators/activitypub/signature.ts | 2 +- server/helpers/peertube-crypto.ts | 3 ++- .../video-file-optimizer-handler.ts | 1 - server/models/activitypub/actor.ts | 14 +++++++++++++- 7 files changed, 21 insertions(+), 11 deletions(-) (limited to 'server') diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 3e65e844b..8283f2e4e 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -252,7 +252,6 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi if (video.privacy === VideoPrivacy.PRIVATE) return videoCreated await sendCreateVideo(video, t) - // TODO: share by video channel await shareVideoByServerAndChannel(video, t) logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) @@ -309,7 +308,6 @@ async function updateVideo (req: express.Request, res: express.Response) { // Video is not private anymore, send a create action to remote servers if (wasPrivateVideo === true && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE) { await sendCreateVideo(videoInstanceUpdated, t) - // TODO: Send by video channel await shareVideoByServerAndChannel(videoInstanceUpdated, t) } }) diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index 5850fc19f..b6207c915 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts @@ -10,6 +10,7 @@ function activityPubContextify (data: T) { 'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', { + 'RsaSignature2017': 'https://w3id.org/security#RsaSignature2017', 'Hashtag': 'as:Hashtag', 'uuid': 'http://schema.org/identifier', 'category': 'http://schema.org/category', @@ -17,8 +18,7 @@ function activityPubContextify (data: T) { 'nsfw': 'as:sensitive', 'language': 'http://schema.org/inLanguage', 'views': 'http://schema.org/Number', - 'size': 'http://schema.org/Number', - 'VideoChannel': 'https://peertu.be/ns/VideoChannel' + 'size': 'http://schema.org/Number' } ] }) diff --git a/server/helpers/custom-jsonld-signature.ts b/server/helpers/custom-jsonld-signature.ts index afb960618..e4f28018e 100644 --- a/server/helpers/custom-jsonld-signature.ts +++ b/server/helpers/custom-jsonld-signature.ts @@ -1,9 +1,7 @@ import * as AsyncLRU from 'async-lru' -import * as jsonld from 'jsonld' +import * as jsonld from 'jsonld/' import * as jsig from 'jsonld-signatures' -jsig.use('jsonld', jsonld) - const nodeDocumentLoader = jsonld.documentLoaders.node() const lru = new AsyncLRU({ @@ -17,4 +15,6 @@ jsonld.documentLoader = (url, cb) => { lru.get(url, cb) } +jsig.use('jsonld', jsonld) + export { jsig } diff --git a/server/helpers/custom-validators/activitypub/signature.ts b/server/helpers/custom-validators/activitypub/signature.ts index 683ed2b1c..cfb65361e 100644 --- a/server/helpers/custom-validators/activitypub/signature.ts +++ b/server/helpers/custom-validators/activitypub/signature.ts @@ -2,7 +2,7 @@ import { exists } from '../misc' import { isActivityPubUrlValid } from './misc' function isSignatureTypeValid (signatureType: string) { - return exists(signatureType) && signatureType === 'GraphSignature2012' + return exists(signatureType) && signatureType === 'RsaSignature2017' } function isSignatureCreatorValid (signatureCreator: string) { diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index a0c9112b9..313c12e26 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts @@ -43,7 +43,8 @@ function isSignatureVerified (fromActor: ActorModel, signedDocument: object) { function signObject (byActor: ActorModel, data: any) { const options = { privateKeyPem: byActor.privateKey, - creator: byActor.url + creator: byActor.url, + algorithm: 'RsaSignature2017' } return jsig.promises.sign(data, options) diff --git a/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts b/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts index cde4948de..47b12e66f 100644 --- a/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts +++ b/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts @@ -37,7 +37,6 @@ async function onSuccess (jobId: number, video: VideoModel, jobScheduler: JobSch // Now we'll add the video's meta data to our followers await sendCreateVideo(video, undefined) - // TODO: share by channel await shareVideoByServerAndChannel(video, undefined) const originalFileHeight = await videoDatabase.getOriginalFileHeight() diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index ecaa43dcf..8cedcc2bc 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -7,7 +7,7 @@ import { Column, CreatedAt, DataType, - Default, + Default, DefaultScope, ForeignKey, HasMany, HasOne, @@ -41,6 +41,14 @@ enum ScopeNames { FULL = 'FULL' } +@DefaultScope({ + include: [ + { + model: () => ServerModel, + required: false + } + ] +}) @Scopes({ [ScopeNames.FULL]: { include: [ @@ -51,6 +59,10 @@ enum ScopeNames { { model: () => VideoChannelModel, required: false + }, + { + model: () => ServerModel, + required: false } ] } -- cgit v1.2.3