Back to no port number on webfinger acct

master
Bob Mottram 2019-07-19 15:41:32 +01:00
parent bc93a289f8
commit 1551c20420
2 changed files with 12 additions and 9 deletions

View File

@ -97,7 +97,7 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.debug: if self.server.debug:
print('DEBUG: WEBFINGER lookup '+self.path+' '+str(self.server.baseDir)) print('DEBUG: WEBFINGER lookup '+self.path+' '+str(self.server.baseDir))
wfResult=webfingerLookup(self.path,self.server.baseDir,self.server.debug) wfResult=webfingerLookup(self.path,self.server.baseDir,self.server.port,self.server.debug)
if wfResult: if wfResult:
self._set_headers('application/jrd+json') self._set_headers('application/jrd+json')
self.wfile.write(json.dumps(wfResult).encode('utf-8')) self.wfile.write(json.dumps(wfResult).encode('utf-8'))

View File

@ -41,14 +41,13 @@ def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}) ->
return None return None
nickname, domain = parseHandle(handle) nickname, domain = parseHandle(handle)
print('wfTest2 '+nickname+' '+domain)
if not nickname: if not nickname:
return None return None
wfDomain=domain wfDomain=domain
if ':' in wfDomain: if ':' in wfDomain:
wfPort=int(wfDomain.split(':')[1]) #wfPort=int(wfDomain.split(':')[1])
if wfPort==80 or wfPort==443: #if wfPort==80 or wfPort==443:
wfDomain=wfDomain.split(':')[0] wfDomain=wfDomain.split(':')[0]
wf=getWebfingerFromCache(nickname+'@'+wfDomain,cachedWebfingers) wf=getWebfingerFromCache(nickname+'@'+wfDomain,cachedWebfingers)
if wf: if wf:
return wf return wf
@ -93,6 +92,7 @@ def createWebfingerEndpoint(nickname: str,domain: str,port: int, \
httpPrefix: str,publicKeyPem) -> {}: httpPrefix: str,publicKeyPem) -> {}:
"""Creates a webfinger endpoint for a user """Creates a webfinger endpoint for a user
""" """
originalDomain=domain
if port!=80 and port!=443: if port!=80 and port!=443:
domain=domain+':'+str(port) domain=domain+':'+str(port)
@ -130,7 +130,7 @@ def createWebfingerEndpoint(nickname: str,domain: str,port: int, \
"template": httpPrefix+"://"+domain+"/authorize_interaction?uri={uri}" "template": httpPrefix+"://"+domain+"/authorize_interaction?uri={uri}"
} }
], ],
"subject": "acct:"+nickname+"@"+domain "subject": "acct:"+nickname+"@"+originalDomain
} }
return account return account
@ -149,7 +149,7 @@ def webfingerMeta() -> str:
" </Link>" \ " </Link>" \
"</XRD>" "</XRD>"
def webfingerLookup(path: str,baseDir: str,debug: bool) -> {}: def webfingerLookup(path: str,baseDir: str,port: int,debug: bool) -> {}:
"""Lookup the webfinger endpoint for an account """Lookup the webfinger endpoint for an account
""" """
if not path.startswith('/.well-known/webfinger?'): if not path.startswith('/.well-known/webfinger?'):
@ -161,7 +161,7 @@ def webfingerLookup(path: str,baseDir: str,debug: bool) -> {}:
print('DEBUG: WEBFINGER handle '+handle) print('DEBUG: WEBFINGER handle '+handle)
else: else:
if 'resource=acct%3A' in path: if 'resource=acct%3A' in path:
handle=path.split('resource=acct%3A')[1].replace('%40','@').replace('%3A',':').strip() handle=path.split('resource=acct%3A')[1].replace('%40','@',1).replace('%3A',':',1).strip()
if debug: if debug:
print('DEBUG: WEBFINGER handle '+handle) print('DEBUG: WEBFINGER handle '+handle)
if not handle: if not handle:
@ -176,9 +176,12 @@ def webfingerLookup(path: str,baseDir: str,debug: bool) -> {}:
if debug: if debug:
print('DEBUG: WEBFINGER no @ in handle '+handle) print('DEBUG: WEBFINGER no @ in handle '+handle)
return None return None
if port!=80 and port !=443:
if ':' not in handle:
handle=handle+':'+str(port)
filename=baseDir+'/wfendpoints/'+handle.lower()+'.json' filename=baseDir+'/wfendpoints/'+handle.lower()+'.json'
if debug: if debug:
print('DEBUG: WEBFINGER filename'+filename) print('DEBUG: WEBFINGER filename '+filename)
if not os.path.isfile(filename): if not os.path.isfile(filename):
if debug: if debug:
print('DEBUG: WEBFINGER filename not found '+filename) print('DEBUG: WEBFINGER filename not found '+filename)