Try alternative webfinger resource

main
Bob Mottram 2022-02-26 11:01:50 +00:00
parent d559d59abe
commit d6864e9ee3
1 changed files with 20 additions and 0 deletions

View File

@ -100,6 +100,26 @@ def webfinger_handle(session, handle: str, http_prefix: str,
print('ERROR: webfinger_handle ' + wf_handle + ' ' + str(ex))
return None
# if the first attempt fails then try specifying the webfinger
# resource in a different way
if not result:
resource = handle
if handle == wf_handle:
# reconstruct the actor
resource = http_prefix + '://' + wf_domain + '/users/' + nickname
# try again using the actor as the resource
# See https://datatracker.ietf.org/doc/html/rfc7033 section 4.5
par = {
'resource': '{}'.format(resource)
}
try:
result = \
get_json(signing_priv_key_pem, session, url, hdr, par,
debug, project_version, http_prefix, from_domain)
except Exception as ex:
print('ERROR: webfinger_handle ' + wf_handle + ' ' + str(ex))
return None
if result:
store_webfinger_in_cache(wf_handle, result, cached_webfingers)
else: