Optional password for basic auth when creating person

master
Bob Mottram 2019-07-03 20:10:24 +01:00
parent 407f3e702b
commit 5b6c812f91
1 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ from Crypto.PublicKey import RSA
from webfinger import createWebfingerEndpoint from webfinger import createWebfingerEndpoint
from webfinger import storeWebfingerEndpoint from webfinger import storeWebfingerEndpoint
from posts import createOutbox from posts import createOutbox
from auth import storeBasicCredentials
def generateRSAKey() -> (str,str): def generateRSAKey() -> (str,str):
key = RSA.generate(2048) key = RSA.generate(2048)
@ -22,7 +23,7 @@ def generateRSAKey() -> (str,str):
return privateKeyPem,publicKeyPem return privateKeyPem,publicKeyPem
def createPerson(baseDir: str,nickname: str,domain: str,port: int, \ def createPerson(baseDir: str,nickname: str,domain: str,port: int, \
httpPrefix: str, saveToFile: bool) -> (str,str,{},{}): httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
"""Returns the private key, public key, actor and webfinger endpoint """Returns the private key, public key, actor and webfinger endpoint
""" """
privateKeyPem,publicKeyPem=generateRSAKey() privateKeyPem,publicKeyPem=generateRSAKey()
@ -102,6 +103,9 @@ def createPerson(baseDir: str,nickname: str,domain: str,port: int, \
with open(filename, "w") as text_file: with open(filename, "w") as text_file:
print(publicKeyPem, file=text_file) print(publicKeyPem, file=text_file)
if password:
storeBasicCredentials(baseDir,nickname,password)
return privateKeyPem,publicKeyPem,newPerson,webfingerEndpoint return privateKeyPem,publicKeyPem,newPerson,webfingerEndpoint
def validNickname(nickname: str) -> bool: def validNickname(nickname: str) -> bool: