mirror of https://gitlab.com/bashrc2/epicyon
group resource type within webfinger
parent
883d48f934
commit
bee0a4bcf5
24
person.py
24
person.py
|
@ -227,13 +227,15 @@ def getDefaultPersonContext() -> str:
|
|||
def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||
httpPrefix: str, saveToFile: bool,
|
||||
manualFollowerApproval: bool,
|
||||
password: str = None) -> (str, str, {}, {}):
|
||||
groupAccount: bool,
|
||||
password: str) -> (str, str, {}, {}):
|
||||
"""Returns the private key, public key, actor and webfinger endpoint
|
||||
"""
|
||||
privateKeyPem, publicKeyPem = generateRSAKey()
|
||||
webfingerEndpoint = \
|
||||
createWebfingerEndpoint(nickname, domain, port,
|
||||
httpPrefix, publicKeyPem)
|
||||
httpPrefix, publicKeyPem,
|
||||
groupAccount)
|
||||
if saveToFile:
|
||||
storeWebfingerEndpoint(nickname, domain, port,
|
||||
baseDir, webfingerEndpoint)
|
||||
|
@ -243,6 +245,8 @@ def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
|||
domain = getFullDomain(domain, port)
|
||||
|
||||
personType = 'Person'
|
||||
if groupAccount:
|
||||
personType = 'Group'
|
||||
# Enable follower approval by default
|
||||
approveFollowers = manualFollowerApproval
|
||||
personName = nickname
|
||||
|
@ -436,8 +440,8 @@ def createGroup(baseDir: str, nickname: str, domain: str, port: int,
|
|||
newPerson, webfingerEndpoint) = createPerson(baseDir, nickname,
|
||||
domain, port,
|
||||
httpPrefix, saveToFile,
|
||||
False, password)
|
||||
newPerson['type'] = 'Group'
|
||||
False, password, True)
|
||||
|
||||
return privateKeyPem, publicKeyPem, newPerson, webfingerEndpoint
|
||||
|
||||
|
||||
|
@ -458,7 +462,8 @@ def savePersonQrcode(baseDir: str,
|
|||
def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
||||
httpPrefix: str, saveToFile: bool,
|
||||
manualFollowerApproval: bool,
|
||||
password: str = None) -> (str, str, {}, {}):
|
||||
password: str,
|
||||
groupAccount: bool = False) -> (str, str, {}, {}):
|
||||
"""Returns the private key, public key, actor and webfinger endpoint
|
||||
"""
|
||||
if not validNickname(domain, nickname):
|
||||
|
@ -484,6 +489,7 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
|||
httpPrefix,
|
||||
saveToFile,
|
||||
manualFollowerApproval,
|
||||
groupAccount,
|
||||
password)
|
||||
if not getConfigParam(baseDir, 'admin'):
|
||||
if nickname != 'news':
|
||||
|
@ -554,7 +560,7 @@ def createSharedInbox(baseDir: str, nickname: str, domain: str, port: int,
|
|||
"""Generates the shared inbox
|
||||
"""
|
||||
return _createPersonBase(baseDir, nickname, domain, port, httpPrefix,
|
||||
True, True, None)
|
||||
True, True, False, None)
|
||||
|
||||
|
||||
def createNewsInbox(baseDir: str, domain: str, port: int,
|
||||
|
@ -1216,7 +1222,8 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
|||
handle.startswith('http') or \
|
||||
handle.startswith('hyper'):
|
||||
if detectedUsersPath == '/c/':
|
||||
requiresWebfinger = False
|
||||
# requiresWebfinger = False
|
||||
requiresWebfinger = True
|
||||
# format: https://domain/@nick
|
||||
originalHandle = handle
|
||||
if not hasUsersPath(originalHandle):
|
||||
|
@ -1258,7 +1265,8 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
|||
elif handle.startswith('!'):
|
||||
# handle for a group
|
||||
handle = handle[1:]
|
||||
requiresWebfinger = False
|
||||
# requiresWebfinger = False
|
||||
requiresWebfinger = True
|
||||
if '@' not in handle:
|
||||
if not quiet:
|
||||
print('getActorJsonSyntax: --actor nickname@domain')
|
||||
|
|
27
webfinger.py
27
webfinger.py
|
@ -139,7 +139,8 @@ def storeWebfingerEndpoint(nickname: str, domain: str, port: int,
|
|||
|
||||
|
||||
def createWebfingerEndpoint(nickname: str, domain: str, port: int,
|
||||
httpPrefix: str, publicKeyPem) -> {}:
|
||||
httpPrefix: str, publicKeyPem: str,
|
||||
groupAccount: bool) -> {}:
|
||||
"""Creates a webfinger endpoint for a user
|
||||
"""
|
||||
originalDomain = domain
|
||||
|
@ -147,7 +148,10 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int,
|
|||
|
||||
personName = nickname
|
||||
personId = httpPrefix + "://" + domain + "/users/" + personName
|
||||
subjectStr = "acct:" + personName + "@" + originalDomain
|
||||
if not groupAccount:
|
||||
subjectStr = "acct:" + personName + "@" + originalDomain
|
||||
else:
|
||||
subjectStr = "group:" + personName + "@" + originalDomain
|
||||
profilePageHref = httpPrefix + "://" + domain + "/@" + nickname
|
||||
if nickname == 'inbox' or nickname == originalDomain:
|
||||
personName = 'actor'
|
||||
|
@ -225,17 +229,20 @@ def webfingerLookup(path: str, baseDir: str,
|
|||
if not path.startswith('/.well-known/webfinger?'):
|
||||
return None
|
||||
handle = None
|
||||
if 'resource=acct:' in path:
|
||||
handle = path.split('resource=acct:')[1].strip()
|
||||
handle = urllib.parse.unquote(handle)
|
||||
if debug:
|
||||
print('DEBUG: WEBFINGER handle ' + handle)
|
||||
else:
|
||||
if 'resource=acct%3A' in path:
|
||||
handle = path.split('resource=acct%3A')[1]
|
||||
resourceTypes = ('acct', 'group')
|
||||
for resType in resourceTypes:
|
||||
if 'resource=' + resType + ':' in path:
|
||||
handle = path.split('resource=' + resType + ':')[1].strip()
|
||||
handle = urllib.parse.unquote(handle)
|
||||
if debug:
|
||||
print('DEBUG: WEBFINGER handle ' + handle)
|
||||
break
|
||||
elif 'resource=' + resType + '%3A' in path:
|
||||
handle = path.split('resource=' + resType + '%3A')[1]
|
||||
handle = urllib.parse.unquote(handle.strip())
|
||||
if debug:
|
||||
print('DEBUG: WEBFINGER handle ' + handle)
|
||||
break
|
||||
if not handle:
|
||||
if debug:
|
||||
print('DEBUG: WEBFINGER handle missing')
|
||||
|
|
Loading…
Reference in New Issue