forked from indymedia/epicyon
Include port with domain
parent
aa87daa0a1
commit
6c85b39adc
|
@ -66,7 +66,7 @@ followerOfPerson(username,domain,'giraffe','trees.com',federationList)
|
|||
#sys.exit()
|
||||
|
||||
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(username,domain,https,True)
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(username,domain,port,https,True)
|
||||
#deleteAllPosts(username,domain)
|
||||
setPreferredUsername(username,domain,'badger')
|
||||
setBio(username,domain,'Some personal info')
|
||||
|
|
|
@ -114,7 +114,8 @@ def testHttpsigBase(withDigest):
|
|||
username='socrates'
|
||||
domain='argumentative.social'
|
||||
https=True
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(username,domain,https,False)
|
||||
port=80
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(username,domain,port,https,False)
|
||||
messageBodyJson = '{"a key": "a value", "another key": "A string"}'
|
||||
if not withDigest:
|
||||
headers = {'host': domain}
|
||||
|
|
11
person.py
11
person.py
|
@ -21,7 +21,7 @@ def generateRSAKey() -> (str,str):
|
|||
publicKeyPem = key.publickey().exportKey("PEM").decode("utf-8")
|
||||
return privateKeyPem,publicKeyPem
|
||||
|
||||
def createPerson(username: str,domain: str,https: bool, saveToFile: bool) -> (str,str,{},{}):
|
||||
def createPerson(username: str,domain: str,port: int,https: bool, saveToFile: bool) -> (str,str,{},{}):
|
||||
"""Returns the private key, public key, actor and webfinger endpoint
|
||||
"""
|
||||
prefix='https'
|
||||
|
@ -29,10 +29,14 @@ def createPerson(username: str,domain: str,https: bool, saveToFile: bool) -> (st
|
|||
prefix='http'
|
||||
|
||||
privateKeyPem,publicKeyPem=generateRSAKey()
|
||||
webfingerEndpoint=createWebfingerEndpoint(username,domain,https,publicKeyPem)
|
||||
webfingerEndpoint=createWebfingerEndpoint(username,domain,port,https,publicKeyPem)
|
||||
if saveToFile:
|
||||
storeWebfingerEndpoint(username,domain,webfingerEndpoint)
|
||||
|
||||
|
||||
handle=username.lower()+'@'+domain.lower()
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
newPerson = {'@context': ['https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
{'Emoji': 'toot:Emoji',
|
||||
|
@ -75,7 +79,6 @@ def createPerson(username: str,domain: str,https: bool, saveToFile: bool) -> (st
|
|||
|
||||
if saveToFile:
|
||||
# save person to file
|
||||
handle=username.lower()+'@'+domain.lower()
|
||||
baseDir=os.getcwd()
|
||||
peopleSubdir='/accounts'
|
||||
if not os.path.isdir(baseDir+peopleSubdir):
|
||||
|
|
|
@ -9,6 +9,8 @@ __status__ = "Production"
|
|||
import requests
|
||||
import json
|
||||
|
||||
baseDirectory=None
|
||||
|
||||
def createSession(onionRoute: bool):
|
||||
session = requests.session()
|
||||
if onionRoute:
|
||||
|
@ -42,3 +44,6 @@ def postJson(session,postJsonObject,federationList,inboxUrl: str,headers) -> str
|
|||
|
||||
postResult = session.post(url = inboxUrl, data = json.dumps(postJsonObject), headers=headers)
|
||||
return postResult.text
|
||||
|
||||
def getBaseDirectory():
|
||||
baseDirectory = os.getcwd()
|
||||
|
|
|
@ -77,13 +77,16 @@ def storeWebfingerEndpoint(username: str,domain: str,wfJson) -> bool:
|
|||
commentjson.dump(wfJson, fp, indent=4, sort_keys=False)
|
||||
return True
|
||||
|
||||
def createWebfingerEndpoint(username,domain,https,publicKeyPem) -> {}:
|
||||
def createWebfingerEndpoint(username,domain,port,https,publicKeyPem) -> {}:
|
||||
"""Creates a webfinger endpoint for a user
|
||||
"""
|
||||
prefix='https'
|
||||
if not https:
|
||||
prefix='http'
|
||||
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
account = {
|
||||
"aliases": [
|
||||
prefix+"://"+domain+"/@"+username,
|
||||
|
|
Loading…
Reference in New Issue