mirror of https://gitlab.com/bashrc2/epicyon
Set accept type for signed header
parent
0af91ce4b6
commit
20b5805e9a
|
@ -202,15 +202,17 @@ def createSignedHeader(dateStr: str, privateKeyPem: str, nickname: str,
|
|||
domain: str, port: int,
|
||||
toDomain: str, toPort: int,
|
||||
path: str, httpPrefix: str, withDigest: bool,
|
||||
messageBodyJsonStr: str) -> {}:
|
||||
messageBodyJsonStr: str,
|
||||
contentType: str) -> {}:
|
||||
"""Note that the domain is the destination, not the sender
|
||||
"""
|
||||
headerDomain = getFullDomain(toDomain, toPort)
|
||||
|
||||
if not dateStr:
|
||||
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
|
||||
if not withDigest:
|
||||
if not contentType:
|
||||
contentType = 'application/activity+json'
|
||||
if not withDigest:
|
||||
headers = {
|
||||
'(request-target)': f'get {path}',
|
||||
'host': headerDomain,
|
||||
|
@ -222,7 +224,6 @@ def createSignedHeader(dateStr: str, privateKeyPem: str, nickname: str,
|
|||
domain, port, toDomain, toPort,
|
||||
path, httpPrefix, None)
|
||||
else:
|
||||
contentType = 'application/activity+json'
|
||||
bodyDigest = messageContentDigest(messageBodyJsonStr)
|
||||
contentLength = len(messageBodyJsonStr)
|
||||
headers = {
|
||||
|
|
6
posts.py
6
posts.py
|
@ -2244,7 +2244,8 @@ def sendPost(signingPrivateKeyPem: str, projectVersion: str,
|
|||
signatureHeaderJson = \
|
||||
createSignedHeader(None, privateKeyPem, nickname, domain, port,
|
||||
toDomain, toPort,
|
||||
postPath, httpPrefix, withDigest, postJsonStr)
|
||||
postPath, httpPrefix, withDigest, postJsonStr,
|
||||
None)
|
||||
|
||||
# if the "to" domain is within the shared items
|
||||
# federation list then send the token for this domain
|
||||
|
@ -2603,7 +2604,8 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
|
|||
signatureHeaderJson = \
|
||||
createSignedHeader(None, privateKeyPem, nickname, domain, port,
|
||||
toDomain, toPort,
|
||||
postPath, httpPrefix, withDigest, postJsonStr)
|
||||
postPath, httpPrefix, withDigest, postJsonStr,
|
||||
None)
|
||||
# optionally add a token so that the receiving instance may access
|
||||
# your shared items catalog
|
||||
if sharedItemsToken:
|
||||
|
|
|
@ -179,10 +179,13 @@ def _getJsonSigned(session, url: str, domainFull: str, sessionHeaders: {},
|
|||
path = '/' + url.split(toDomainFull + '/')[1]
|
||||
else:
|
||||
path = '/actor'
|
||||
contentType = 'application/activity+json'
|
||||
if sessionHeaders.get('Accept'):
|
||||
contentType = sessionHeaders['Accept']
|
||||
signatureHeaderJson = \
|
||||
createSignedHeader(None, signingPrivateKeyPem, 'actor', domain, port,
|
||||
toDomain, toPort, path, httpPrefix, withDigest,
|
||||
messageStr)
|
||||
messageStr, contentType)
|
||||
if debug:
|
||||
print('Signed GET signatureHeaderJson ' + str(signatureHeaderJson))
|
||||
# update the session headers from the signature headers
|
||||
|
|
Loading…
Reference in New Issue