Add log messages for debugging connection to auth server
This commit is contained in:
parent
4355e6dc42
commit
b01f233208
1 changed files with 7 additions and 1 deletions
|
@ -61,28 +61,34 @@ class Provider(AuthProviderSettings):
|
|||
if self.info_url is not None:
|
||||
try:
|
||||
provider_info = await client.get(self.info_url)
|
||||
except Exception:
|
||||
except Exception as err:
|
||||
logger.debug("Provider_info: cannot connect")
|
||||
logger.exception(err)
|
||||
raise NoPublicKey
|
||||
try:
|
||||
self.info = provider_info.json()
|
||||
except JSONDecodeError:
|
||||
logger.debug("Provider_info: cannot decode json response")
|
||||
raise NoPublicKey
|
||||
if "public_key" in self.info:
|
||||
# For Keycloak
|
||||
try:
|
||||
public_key = str(self.info["public_key"])
|
||||
except KeyError:
|
||||
logger.debug("Provider_info: cannot get public_key")
|
||||
raise NoPublicKey
|
||||
elif "keys" in self.info:
|
||||
# For Forgejo/Gitea
|
||||
try:
|
||||
public_key = str(self.info["keys"][0]["n"])
|
||||
except KeyError:
|
||||
logger.debug("Provider_info: cannot get key 0.n")
|
||||
raise NoPublicKey
|
||||
if self.public_key_url is not None:
|
||||
resp = await client.get(self.public_key_url)
|
||||
public_key = resp.text
|
||||
if public_key is None:
|
||||
logger.debug("Provider_info: cannot determine public key")
|
||||
raise NoPublicKey
|
||||
self.public_key = "\n".join(
|
||||
["-----BEGIN PUBLIC KEY-----", public_key, "-----END PUBLIC KEY-----"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue