From a5be84e5a08b222d6879b7368479610183b31748 Mon Sep 17 00:00:00 2001
From: Grigi <nagrigoriadis@gmail.com>
Date: Wed, 19 Nov 2014 13:51:52 +0200
Subject: [PATCH 1/3] added default=False to all BooleanFields that didn't have
 an explicit default

---
 authentic2/idp/models.py  |  2 +-
 authentic2/models.py      |  7 ++++++-
 authentic2/saml/models.py | 46 +++++++++++++++++++++++-----------------------
 3 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/authentic2/idp/models.py b/authentic2/idp/models.py
index e60e37a..1ad51c6 100644
--- a/authentic2/idp/models.py
+++ b/authentic2/idp/models.py
@@ -15,7 +15,7 @@ ATTRIBUTE_VALUE_FORMATS = (
 
 class AttributePolicy(models.Model):
     name = models.CharField(max_length = 100, unique = True)
-    enabled = models.BooleanField(verbose_name = _('Enabled'))
+    enabled = models.BooleanField(verbose_name = _('Enabled'), default=False)
     ask_consent_attributes = models.BooleanField(\
             verbose_name = _("Ask the user consent before forwarding attributes"),
             default=True)
diff --git a/authentic2/models.py b/authentic2/models.py
index 5c2c722..b9edb0c 100644
--- a/authentic2/models.py
+++ b/authentic2/models.py
@@ -244,7 +244,7 @@ class LogoutUrlAbstract(models.Model):
     logout_url = models.URLField(verbose_name=_('url'), help_text=_('you can use a {} '
         'to pass the URL of the success icon, ex.: '
         'http://example.com/logout?next={}'), max_length=255, blank=True, null=True)
-    logout_use_iframe = models.BooleanField(
+    logout_use_iframe = models.BooleanField(default=False,
             verbose_name=_('use an iframe instead of an img tag for logout'))
     logout_use_iframe_timeout = models.PositiveIntegerField(
             verbose_name=_('iframe logout timeout (ms)'),
@@ -299,18 +299,23 @@ class Attribute(models.Model):
             unique=True)
     required = models.BooleanField(
             verbose_name=_('required'),
+            default=False,
             blank=True)
     asked_on_registration = models.BooleanField(
             verbose_name=_('asked on registration'),
+            default=False,
             blank=True)
     user_editable = models.BooleanField(
             verbose_name=_('user editable'),
+            default=False,
             blank=True)
     user_visible = models.BooleanField(
             verbose_name=_('user visible'),
+            default=False,
             blank=True)
     multiple = models.BooleanField(
             verbose_name=_('multiple'),
+            default=False,
             blank=True)
     kind = models.CharField(max_length=16,
             verbose_name=_('kind'),
diff --git a/authentic2/saml/models.py b/authentic2/saml/models.py
index 27e54d4..e45d4a4 100644
--- a/authentic2/saml/models.py
+++ b/authentic2/saml/models.py
@@ -183,36 +183,36 @@ class IdPOptionsSPPolicy(models.Model):
         providers
     '''
     name = models.CharField(_('name'), max_length=200, unique=True)
-    enabled = models.BooleanField(verbose_name = _('Enabled'))
-    no_nameid_policy = models.BooleanField(
+    enabled = models.BooleanField(verbose_name = _('Enabled'), default=False)
+    no_nameid_policy = models.BooleanField(default=False,
             verbose_name = _("Do not send a nameId Policy"))
     requested_name_id_format = models.CharField(
             verbose_name = _("Requested NameID format"),
             max_length = 200,
             default = DEFAULT_NAME_ID_FORMAT,
             choices = NAME_ID_FORMATS_CHOICES)
-    transient_is_persistent = models.BooleanField(
+    transient_is_persistent = models.BooleanField(default=False,
             verbose_name = \
 _("This IdP sends a transient NameID but you want a persistent behaviour for your SP"))
     persistent_identifier_attribute = models.CharField(_('Persistent '
             'identifier attribute'), max_length=200, null=True, blank=True)
-    allow_create = models.BooleanField(
+    allow_create = models.BooleanField(default=False,
             verbose_name = _("Allow IdP to create an identity"))
-    enable_binding_for_sso_response = models.BooleanField(
+    enable_binding_for_sso_response = models.BooleanField(default=False,
             verbose_name = _('Binding for Authnresponse \
             (taken from metadata by the IdP if not enabled)'))
     binding_for_sso_response = models.CharField(
             verbose_name = _("Binding for the SSO responses"),
             max_length = 200, choices = BINDING_SSO_IDP,
             default = lasso.SAML2_METADATA_BINDING_ARTIFACT)
-    enable_http_method_for_slo_request = models.BooleanField(
+    enable_http_method_for_slo_request = models.BooleanField(default=False,
             verbose_name = _('HTTP method for single logout request \
             (taken from metadata if not enabled)'))
     http_method_for_slo_request = models.IntegerField(
             verbose_name = _("HTTP binding for the SLO requests"),
             max_length = 200, choices = HTTP_METHOD,
             default = lasso.HTTP_METHOD_REDIRECT)
-    enable_http_method_for_defederation_request = models.BooleanField(
+    enable_http_method_for_defederation_request = models.BooleanField(default=False,
             verbose_name = \
             _('HTTP method for federation termination request \
             (taken from metadata if not enabled)'))
@@ -220,15 +220,15 @@ _("This IdP sends a transient NameID but you want a persistent behaviour for you
             verbose_name = _("HTTP method for the defederation requests"),
             max_length = 200, choices = HTTP_METHOD,
             default = lasso.HTTP_METHOD_SOAP)
-    force_user_consent = models.BooleanField(\
+    force_user_consent = models.BooleanField(
             verbose_name = \
                 _("Require the user consent be given at account linking"),
             default=False)
-    want_force_authn_request = models.BooleanField(
+    want_force_authn_request = models.BooleanField(default=False,
             verbose_name = _("Force authentication"))
-    want_is_passive_authn_request = models.BooleanField(
+    want_is_passive_authn_request = models.BooleanField(default=False,
             verbose_name = _("Passive authentication"))
-    want_authn_request_signed = models.BooleanField(
+    want_authn_request_signed = models.BooleanField(default=False,
             verbose_name = _("Want AuthnRequest signed"))
     handle_persistent = models.CharField(
             max_length=200,
@@ -271,17 +271,17 @@ class SPOptionsIdPPolicy(models.Model):
         Used to define SAML2 parameters employed with service providers.
     '''
     name = models.CharField(_('name'), max_length=80, unique=True)
-    enabled = models.BooleanField(verbose_name = _('Enabled'))
+    enabled = models.BooleanField(verbose_name = _('Enabled'), default=False)
     prefered_assertion_consumer_binding = models.CharField(
             verbose_name = _("Prefered assertion consumer binding"),
             default = 'meta',
             max_length = 4, choices = ASSERTION_CONSUMER_PROFILES)
-    encrypt_nameid = models.BooleanField(verbose_name = _("Encrypt NameID"))
-    encrypt_assertion = models.BooleanField(
+    encrypt_nameid = models.BooleanField(verbose_name = _("Encrypt NameID"), default=False)
+    encrypt_assertion = models.BooleanField(default=False,
             verbose_name = _("Encrypt Assertion"))
-    authn_request_signed = models.BooleanField(
+    authn_request_signed = models.BooleanField(default=False,
             verbose_name = _("Authentication request signed"))
-    idp_initiated_sso = models.BooleanField(
+    idp_initiated_sso = models.BooleanField(default=False,
             verbose_name = _("Allow IdP initiated SSO"))
     # XXX: format in the metadata file, should be suffixed with a star to mark
     # them as special
@@ -446,7 +446,7 @@ class AuthorizationAttributeMapping(models.Model):
 
 class AuthorizationSPPolicy(models.Model):
     name = models.CharField(_('name'), max_length=80, unique=True)
-    enabled = models.BooleanField(verbose_name = _('Enabled'))
+    enabled = models.BooleanField(verbose_name = _('Enabled'), default=False)
     attribute_map = models.ForeignKey(AuthorizationAttributeMap,
             related_name = "authorization_attributes",
             blank = True, null = True)
@@ -532,13 +532,13 @@ def get_all_custom_or_default(instance, name):
 class LibertyServiceProvider(models.Model):
     liberty_provider = models.OneToOneField(LibertyProvider,
             primary_key = True, related_name = 'service_provider')
-    enabled = models.BooleanField(verbose_name = _('Enabled'))
-    enable_following_sp_options_policy = models.BooleanField(verbose_name = \
+    enabled = models.BooleanField(verbose_name = _('Enabled'), default=False)
+    enable_following_sp_options_policy = models.BooleanField(default=False, verbose_name = \
         _('The following options policy will apply except if a policy for all service provider is defined.'))
     sp_options_policy = models.ForeignKey(SPOptionsIdPPolicy, related_name = "sp_options_policy", verbose_name = _('service provider options policy'), blank=True, null=True)
     policy = models.ForeignKey(LibertyProviderPolicy,
             verbose_name=_("Protocol policy"), null=True, default=1)
-    enable_following_attribute_policy = models.BooleanField(verbose_name = \
+    enable_following_attribute_policy = models.BooleanField(default=False, verbose_name = \
         _('The following attribute policy will apply except if a policy for all service provider is defined.'))
     attribute_policy = models.ForeignKey('idp.AttributePolicy',
              related_name = "attribute_policy",
@@ -571,15 +571,15 @@ class LibertyServiceProvider(models.Model):
 class LibertyIdentityProvider(models.Model):
     liberty_provider = models.OneToOneField(LibertyProvider,
             primary_key = True, related_name = 'identity_provider')
-    enabled = models.BooleanField(verbose_name = _('Enabled'))
-    enable_following_idp_options_policy = models.BooleanField(verbose_name = \
+    enabled = models.BooleanField(verbose_name = _('Enabled'), default=False)
+    enable_following_idp_options_policy = models.BooleanField(default=False, verbose_name = \
         _('The following options policy will apply except if a policy for all '
           'identity provider is defined.'))
     idp_options_policy = models.ForeignKey(IdPOptionsSPPolicy,
             related_name="idp_options_policy",
             verbose_name=_('identity provider options policy'), blank=True,
             null=True)
-    enable_following_authorization_policy = models.BooleanField(verbose_name = \
+    enable_following_authorization_policy = models.BooleanField(default=False, verbose_name = \
         _('The following authorization policy will apply except if a policy for'
           ' all identity provider is defined.'))
     authorization_policy = models.ForeignKey(AuthorizationSPPolicy,
-- 
2.0.4

