More http signature reworking

master
Bob Mottram 2019-08-15 23:12:58 +01:00
parent 977160eecf
commit 8dca9dc9cc
2 changed files with 18 additions and 6 deletions

View File

@ -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:

View File

@ -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: