Validate nicknames

master
Bob Mottram 2019-07-04 19:26:37 +01:00
parent e500d32b15
commit 327ba62bbe
1 changed files with 6 additions and 2 deletions

View File

@ -26,8 +26,7 @@ def createPerson(baseDir: str,nickname: str,domain: str,port: int, \
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
"""Returns the private key, public key, actor and webfinger endpoint
"""
reservedNames=['inbox','outbox','followers','following','sharedInbox','publicKey']
if nickname in reservedNames:
if not validNickname(nickname):
return None,None,None,None
privateKeyPem,publicKeyPem=generateRSAKey()
webfingerEndpoint= \
@ -120,11 +119,16 @@ def validNickname(nickname: str) -> bool:
for c in forbiddenChars:
if c in nickname:
return False
reservedNames=['inbox','outbox','following','followers','sharedInbox']
if nickname in reservedNames:
return False
return True
def personLookup(domain: str,path: str,baseDir: str) -> {}:
"""Lookup the person for an given nickname
"""
if path.endswith('#main-key'):
path=path.replace('#main-key','')
notPersonLookup=['/inbox','/outbox','/outboxarchive', \
'/followers','/following','/featured', \
'.png','.jpg','.gif','.mpv']