Skip to content

Commit

Permalink
Remove introspection_endpoint from required secrets
Browse files Browse the repository at this point in the history
The field is not mandatory and some OIDC providers (such as Nextcloud)
don't provide it resulting in a key error.

Also, refactored client secrets to use json.dumps() for better code
readibility.

Signed-off-by: Marek Pikuła <[email protected]>
  • Loading branch information
MarekPikula committed Apr 2, 2023
1 parent 87d39e8 commit df6f337
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,19 @@
oidc_info = response.json()
app.logger.debug("JSON Dumps for OIDC_INFO: "+json.dumps(oidc_info))

client_secrets = """{
"web": {
"issuer": \""""+oidc_info["issuer"]+"""\",
"auth_uri": \""""+oidc_info["authorization_endpoint"]+"""\",
"client_id": \""""+OIDC_CLIENT_ID+"""\",
"client_secret": \""""+OIDC_SECRET+"""\",
"redirect_uris": [
\""""+DOMAIN_NAME+BASE_PATH+"""/oidc_callback"
],
"userinfo_uri": \""""+oidc_info["userinfo_endpoint"]+"""\",
"token_uri": \""""+oidc_info["token_endpoint"]+"""\",
"token_introspection_uri": \""""+oidc_info["introspection_endpoint"]+"""\"
client_secrets = json.dumps(
{
"web": {
"issuer": oidc_info["issuer"],
"auth_uri": oidc_info["authorization_endpoint"],
"client_id": OIDC_CLIENT_ID,
"client_secret": OIDC_SECRET,
"redirect_uris": [DOMAIN_NAME + BASE_PATH + "/oidc_callback"],
"userinfo_uri": oidc_info["userinfo_endpoint"],
"token_uri": oidc_info["token_endpoint"],
}
}
}
"""
)

with open("/app/instance/secrets.json", "w+") as secrets_json:
secrets_json.write(client_secrets)
Expand Down

0 comments on commit df6f337

Please sign in to comment.