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