Skip to content

Commit

Permalink
Saml2 (#299)
Browse files Browse the repository at this point in the history
* Fixed saml2 auth

* Fixed saml2 auth

* Fixed saml2 auth

* Fixed saml2 auth
  • Loading branch information
crisingulani committed Sep 4, 2024
1 parent adcbb49 commit 078cec6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend/core/saml2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def _update_user(self, user, attributes: dict, attribute_mapping: dict, force_sa

log = logging.getLogger("saml")

log.debug("USER: ", user)
log.debug("ATTRIBUTES: ", attributes)
log.debug("USER: %s", user)
log.debug("ATTRIBUTES: %s", attributes)

display_name = attributes.get('cn', [""])[0]

Expand Down
16 changes: 12 additions & 4 deletions backend/pzserver/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import os

import saml2
import saml2.saml

# import saml2.saml

# Build paths inside the project like this: BASE_DIR / 'subdir'.
# BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -29,7 +30,7 @@
SECRET_KEY = os.getenv("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = int(os.getenv("DEBUG", 1))
DEBUG = int(os.getenv("DEBUG", "1"))

# Application definition

Expand Down Expand Up @@ -364,6 +365,12 @@
"email": ("email",),
}

METADATAS = str(os.getenv("IDP_METADATA")).split(",")
METADATA_URLS = []

for metadata in METADATAS:
METADATA_URLS.append({"url": metadata, "cert": None})

SAML_CONFIG = {
# Biblioteca usada para assinatura e criptografia
"xmlsec_binary": "/usr/bin/xmlsec1",
Expand Down Expand Up @@ -411,9 +418,10 @@
},
# Indica onde os metadados podem ser encontrados
"metadata": {
"local": [os.getenv("IDP_METADATA")],
"remote": METADATA_URLS,
# "local": [os.getenv("IDP_METADATA")],
},
"debug": os.getenv("DEBUG", 1),
"debug": os.getenv("DEBUG", "1"),
# Signature
"key_file": SIG_KEY_PEM, # private part
"cert_file": SIG_CERT_PEM, # public part
Expand Down

0 comments on commit 078cec6

Please sign in to comment.