From 8dca9dc9ccd3dbe866ecb87d514e1cc8290c1f50 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 15 Aug 2019 23:12:58 +0100 Subject: [PATCH] More http signature reworking --- daemon.py | 19 +++++++++++++++---- inbox.py | 5 +++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/daemon.py b/daemon.py index 44137ad6..11caa124 100644 --- a/daemon.py +++ b/daemon.py @@ -134,7 +134,7 @@ def readFollowList(filename: str): return followlist class PubServer(BaseHTTPRequestHandler): - protocol_version = 'HTTP/1.1' + protocol_version = 'HTTP/1.0' def _login_headers(self,fileFormat: str,length: int) -> None: self.send_response(200) @@ -390,8 +390,19 @@ class PubServer(BaseHTTPRequestHandler): if len(self.server.inboxQueue)>=self.server.maxQueueLength: print('Inbox queue is full') return 1 - - # save the json for later queue processing + + #TODO convert headers to dict + headersDict={} + headersDict['host']=self.headers['host'] + headersDict['signature']=self.headers['signature'] + if self.headers.get('Date'): + headersDict['Date']=self.headers['Date'] + if self.headers.get('digest'): + headersDict['digest']=self.headers['digest'] + if self.headers.get('Content-type'): + headersDict['Content-type']=self.headers['Content-type'] + + # save the json for later queue processing queueFilename = \ savePostToInboxQueue(self.server.baseDir, \ self.server.httpPrefix, \ @@ -400,7 +411,7 @@ class PubServer(BaseHTTPRequestHandler): messageJson, self.headers['host'], self.headers['signature'], - self.headers, + headersDict, '/'+self.path.split('/')[-1], self.server.debug) if queueFilename: diff --git a/inbox.py b/inbox.py index ca48f6f2..ffc5115b 100644 --- a/inbox.py +++ b/inbox.py @@ -164,7 +164,7 @@ def validPublishedDate(published) -> bool: return False return True -def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str,postJsonObject: {},host: str,headers: str,httpHeaders: str,postPath: str,debug: bool) -> str: +def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str,postJsonObject: {},host: str,headers: str,httpHeaders: {},postPath: str,debug: bool) -> str: """Saves the give json to the inbox queue for the person keyId specifies the actor sending the post """ @@ -1140,7 +1140,8 @@ def runInboxQueue(projectVersion: str, \ print('DEBUG: checking http headers') pprint(queueJson['headers']) if not verifyPostHeaders(httpPrefix, \ - pubKey,queueJson['headers'], \ + pubKey, \ + queueJson['httpHeaders'], \ queueJson['path'],False, \ json.dumps(queueJson['post'])): if debug: