Add optional "debug mode" w/ detailed logging for SAML IdPs
This commit is contained in:
@@ -40,6 +40,14 @@ _PSA_OAUTH2_BACKENDS = [backend_class.name for backend_class in _load_backend_cl
|
||||
_PSA_SAML_BACKENDS = [backend_class.name for backend_class in _load_backend_classes(SAMLAuth)]
|
||||
_LTI_BACKENDS = [backend_class.name for backend_class in _load_backend_classes(LTIAuthBackend)]
|
||||
|
||||
DEFAULT_SAML_CONTACT = {
|
||||
# Default contact information to put into the SAML metadata that gets generated by python-saml.
|
||||
"givenName": "{} Support".format(
|
||||
configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
|
||||
),
|
||||
"emailAddress": configuration_helpers.get_value('TECH_SUPPORT_EMAIL', settings.TECH_SUPPORT_EMAIL),
|
||||
}
|
||||
|
||||
|
||||
def clean_json(value, of_type):
|
||||
""" Simple helper method to parse and clean JSON """
|
||||
@@ -300,6 +308,13 @@ class SAMLProviderConfig(ProviderConfig):
|
||||
attr_email = models.CharField(
|
||||
max_length=128, blank=True, verbose_name="Email Attribute",
|
||||
help_text="URN of SAML attribute containing the user's email address[es]. Leave blank for default.")
|
||||
debug_mode = models.BooleanField(
|
||||
default=False, verbose_name="Debug Mode",
|
||||
help_text=(
|
||||
"In debug mode, all SAML XML requests and responses will be logged. "
|
||||
"This is helpful for testing/setup but should always be disabled before users start using this provider."
|
||||
),
|
||||
)
|
||||
other_settings = models.TextField(
|
||||
verbose_name="Advanced settings", blank=True,
|
||||
help_text=(
|
||||
@@ -451,16 +466,13 @@ class SAMLConfiguration(ConfigurationModel):
|
||||
return self.private_key
|
||||
# To allow instances to avoid storing keys in the DB, the private key can also be set via Django:
|
||||
return getattr(settings, 'SOCIAL_AUTH_SAML_SP_PRIVATE_KEY', '')
|
||||
other_config = json.loads(self.other_config_str)
|
||||
if name in ("TECHNICAL_CONTACT", "SUPPORT_CONTACT"):
|
||||
contact = {
|
||||
"givenName": "{} Support".format(
|
||||
configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
|
||||
),
|
||||
"emailAddress": settings.TECH_SUPPORT_EMAIL
|
||||
}
|
||||
contact.update(other_config.get(name, {}))
|
||||
return contact
|
||||
other_config = {
|
||||
# These defaults can be overriden by self.other_config_str
|
||||
"EXTRA_DATA": ["attributes"], # Save all attribute values the IdP sends into the UserSocialAuth table
|
||||
"TECHNICAL_CONTACT": DEFAULT_SAML_CONTACT,
|
||||
"SUPPORT_CONTACT": DEFAULT_SAML_CONTACT,
|
||||
}
|
||||
other_config.update(json.loads(self.other_config_str))
|
||||
return other_config[name] # SECURITY_CONFIG, SP_EXTRA, or similar extra settings
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user