From 8af75436b69955774825b1fb336e15e228a64713 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Jun 2020 14:08:19 +0100 Subject: [PATCH] Add jsonld signatures to posts --- posts.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/posts.py b/posts.py index 36dea320..88db61ef 100644 --- a/posts.py +++ b/posts.py @@ -53,6 +53,7 @@ from blocking import isBlocked from filters import isFiltered from git import convertPostToPatch from semantic import labelAccusatoryPost +from jsonldsig import jsonldSign # try: # from BeautifulSoup import BeautifulSoup # except ImportError: @@ -1418,6 +1419,13 @@ def sendPost(projectVersion: str, return 7 postPath = inboxUrl.split(toDomain, 1)[1] + try: + signedPostJsonObject = jsonldSign(postJsonObject, privateKeyPem) + postJsonObject = signedPostJsonObject + except BaseException: + print('WARN: failed to JSON-LD sign post') + pass + # convert json to string so that there are no # subsequent conversions after creating message body digest postJsonStr = json.dumps(postJsonObject) @@ -1741,6 +1749,13 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str, addFollowersToPublicPost(postJsonObject) + try: + signedPostJsonObject = jsonldSign(postJsonObject, privateKeyPem) + postJsonObject = signedPostJsonObject + except BaseException: + print('WARN: failed to JSON-LD sign post') + pass + # convert json to string so that there are no # subsequent conversions after creating message body digest postJsonStr = json.dumps(postJsonObject)