misc: close opened key files in authentic settings loader (#73550)

This commit is contained in:
Frédéric Péters 2023-01-18 13:02:38 +01:00 committed by Gitea
parent 2e18ac3a78
commit 3a6640f8f2
1 changed files with 4 additions and 2 deletions

View File

@ -339,8 +339,10 @@ class Authentic(FileBaseSettingsLoader):
saml_key = os.path.join(tenant_dir, 'saml.key')
if os.path.exists(saml_crt) and os.path.exists(saml_key):
tenant_settings.A2_IDP_SAML2_ENABLE = True
tenant_settings.A2_IDP_SAML2_SIGNATURE_PUBLIC_KEY = open(saml_crt).read()
tenant_settings.A2_IDP_SAML2_SIGNATURE_PRIVATE_KEY = open(saml_key).read()
with open(saml_crt) as f:
tenant_settings.A2_IDP_SAML2_SIGNATURE_PUBLIC_KEY = f.read()
with open(saml_key) as f:
tenant_settings.A2_IDP_SAML2_SIGNATURE_PRIVATE_KEY = f.read()
if not getattr(tenant_settings, 'A2_IDP_OIDC_JWKSET', None):
from jwcrypto import jwk