Projet

Général

Profil

0001-add-attribute-source-models-AttributeSource-is-a-bas.patch

Benjamin Dauvergne, 14 août 2014 12:14

Télécharger (39,1 ko)

Voir les différences:

Subject: [PATCH 1/3] add attribute source models, AttributeSource is a base
 class for all attribute source models

 .../migrations/0016_auto__add_attributesource.py   |  132 +++++++++
 authentic2/models.py                               |   41 ++-
 authentic2/saml/admin.py                           |    2 +
 authentic2/saml/migrations/0040_auto.py            |  297 ++++++++++++++++++++
 authentic2/saml/models.py                          |    4 +-
 5 files changed, 467 insertions(+), 9 deletions(-)
 create mode 100644 authentic2/migrations/0016_auto__add_attributesource.py
 create mode 100644 authentic2/saml/migrations/0040_auto.py
authentic2/migrations/0016_auto__add_attributesource.py
1
# -*- coding: utf-8 -*-
2
from south.utils import datetime_utils as datetime
3
from south.db import db
4
from south.v2 import SchemaMigration
5
from django.db import models
6

  
7

  
8
class Migration(SchemaMigration):
9

  
10
    def forwards(self, orm):
11
        # Adding model 'AttributeSource'
12
        db.create_table(u'authentic2_attributesource', (
13
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
14
            ('description', self.gf('django.db.models.fields.CharField')(max_length=100)),
15
            ('name', self.gf('django.db.models.fields.CharField')(max_length=50)),
16
        ))
17
        db.send_create_signal(u'authentic2', ['AttributeSource'])
18

  
19

  
20
    def backwards(self, orm):
21
        # Deleting model 'AttributeSource'
22
        db.delete_table(u'authentic2_attributesource')
23

  
24

  
25
    models = {
26
        u'auth.group': {
27
            'Meta': {'object_name': 'Group'},
28
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
29
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
30
            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
31
        },
32
        u'auth.permission': {
33
            'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
34
            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
35
            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
36
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
37
            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
38
        },
39
        u'auth.user': {
40
            'Meta': {'object_name': 'User'},
41
            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
42
            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
43
            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
44
            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
45
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
46
            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
47
            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
48
            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
49
            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
50
            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
51
            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
52
            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
53
            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
54
        },
55
        u'authentic2.attribute': {
56
            'Meta': {'object_name': 'Attribute'},
57
            'asked_on_registration': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
58
            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
59
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
60
            'kind': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
61
            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '63'}),
62
            'multiple': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
63
            'name': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '256'}),
64
            'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
65
            'user_editable': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
66
            'user_visible': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
67
        },
68
        u'authentic2.attributesource': {
69
            'Meta': {'object_name': 'AttributeSource'},
70
            'description': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
71
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
72
            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
73
        },
74
        u'authentic2.attributevalue': {
75
            'Meta': {'object_name': 'AttributeValue'},
76
            'attribute': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['authentic2.Attribute']"}),
77
            'content': ('django.db.models.fields.TextField', [], {}),
78
            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
79
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
80
            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {})
81
        },
82
        u'authentic2.authenticationevent': {
83
            'Meta': {'object_name': 'AuthenticationEvent'},
84
            'how': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
85
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
86
            'nonce': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
87
            'when': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
88
            'who': ('django.db.models.fields.CharField', [], {'max_length': '80'})
89
        },
90
        u'authentic2.deleteduser': {
91
            'Meta': {'object_name': 'DeletedUser'},
92
            'creation': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
93
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
94
            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
95
        },
96
        u'authentic2.federatedid': {
97
            'Meta': {'object_name': 'FederatedId'},
98
            'about': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
99
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
100
            'id_format': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
101
            'id_value': ('django.db.models.fields.TextField', [], {}),
102
            'provider': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
103
            'service': ('django.db.models.fields.CharField', [], {'max_length': '255'})
104
        },
105
        u'authentic2.logouturl': {
106
            'Meta': {'object_name': 'LogoutUrl'},
107
            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
108
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
109
            'logout_url': ('django.db.models.fields.URLField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
110
            'logout_use_iframe': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
111
            'logout_use_iframe_timeout': ('django.db.models.fields.PositiveIntegerField', [], {'default': '300'}),
112
            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {})
113
        },
114
        u'authentic2.userexternalid': {
115
            'Meta': {'object_name': 'UserExternalId'},
116
            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
117
            'external_id': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
118
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
119
            'source': ('django.db.models.fields.URLField', [], {'max_length': '256'}),
120
            'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
121
            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
122
        },
123
        u'contenttypes.contenttype': {
124
            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
125
            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
126
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
127
            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
128
            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
129
        }
130
    }
131

  
132
    complete_apps = ['authentic2']
authentic2/models.py
13 13
from django.contrib.auth.models import (AbstractBaseUser, PermissionsMixin,
14 14
        BaseUserManager, SiteProfileNotAvailable)
15 15
from django.contrib.auth import load_backend
16

  
17
from model_utils.managers import QueryManager
18

  
19
from . import attribute_kinds
20

  
21

  
22 16
try:
23 17
    from django.contrib.contenttypes.fields import GenericForeignKey
24 18
except ImportError:
25 19
    from django.contrib.contenttypes.generic import GenericForeignKey
26 20
from django.contrib.contenttypes.models import ContentType
27 21

  
22
from model_utils.managers import QueryManager, InheritanceManager
23
from safe_expression import SafeExpression, InvalidExpression
24

  
28 25

  
29
from . import managers, plugins
26
from . import managers, plugins, attribute_kinds
30 27

  
31 28
plugins.init()
32 29

  
......
376 373
    class Meta:
377 374
        verbose_name = _('attribute value')
378 375
        verbose_name_plural = _('attribute values')
376

  
377
class AttributeSource(models.Model):
378
    '''Base class for any attribute generator'''
379
    description = models.CharField(max_length=100)
380
    name = models.CharField(max_length=50)
381

  
382
    objects = InheritanceManager()
383

  
384
    def get_definition(self, ctx):
385
        raise NotImplementedError
386

  
387
    def __unicode__(self):
388
        return self.description + u' (%s)' % self.name
389

  
390
    class Meta:
391
        verbose_name = _('attribute source')
392
        verbose_name_plural = _('attribute sources')
393

  
394

  
395
class ModelWithAttributeSources(models.Model):
396
    attribute_sources = models.ManyToManyField(AttributeSource, blank=True)
397

  
398
    def add_attribute_sources_to_context(self, ctx):
399
        '''Fill a context with local attribute sources'''
400
        attribute_sources = ctx.setdefault('__attribute_sources__', [])
401
        for source in self.attribute_sources.select_subclasses():
402
            attribute_sources.append(source.get_definition())
403

  
404
    class Meta:
405
        abstract = True
authentic2/saml/admin.py
253 253
            'needs_iframe_logout',
254 254
            'iframe_logout_timeout',
255 255
            'http_method_for_slo_request',
256
            'attribute_sources',
256 257
    )
257 258

  
259
    filter_horizontal = [ 'attribute_sources' ]
258 260

  
259 261
admin.site.register(SPOptionsIdPPolicy, SPOptionsIdPPolicyAdmin)
260 262
admin.site.register(LibertyProvider, LibertyProviderAdmin)
authentic2/saml/migrations/0040_auto.py
1
# -*- coding: utf-8 -*-
2
from south.utils import datetime_utils as datetime
3
from south.db import db
4
from south.v2 import SchemaMigration
5
from django.db import models
6

  
7

  
8
class Migration(SchemaMigration):
9

  
10
    def forwards(self, orm):
11
        # Adding M2M table for field attribute_sources on 'SPOptionsIdPPolicy'
12
        m2m_table_name = db.shorten_name(u'saml_spoptionsidppolicy_attribute_sources')
13
        db.create_table(m2m_table_name, (
14
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
15
            ('spoptionsidppolicy', models.ForeignKey(orm[u'saml.spoptionsidppolicy'], null=False)),
16
            ('attributesource', models.ForeignKey(orm[u'authentic2.attributesource'], null=False))
17
        ))
18
        db.create_unique(m2m_table_name, ['spoptionsidppolicy_id', 'attributesource_id'])
19

  
20

  
21
    def backwards(self, orm):
22
        # Removing M2M table for field attribute_sources on 'SPOptionsIdPPolicy'
23
        db.delete_table(db.shorten_name(u'saml_spoptionsidppolicy_attribute_sources'))
24

  
25

  
26
    models = {
27
        u'attribute_aggregator.attributeitem': {
28
            'Meta': {'object_name': 'AttributeItem'},
29
            'attribute_name': ('django.db.models.fields.CharField', [], {'default': "('OpenLDAProotDSE', 'OpenLDAProotDSE')", 'max_length': '100'}),
30
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
31
            'output_name_format': ('django.db.models.fields.CharField', [], {'default': "('urn:oasis:names:tc:SAML:2.0:attrname-format:uri', 'SAMLv2 URI')", 'max_length': '100'}),
32
            'output_namespace': ('django.db.models.fields.CharField', [], {'default': "('Default', 'Default')", 'max_length': '100'}),
33
            'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
34
            'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['attribute_aggregator.AttributeSource']", 'null': 'True', 'blank': 'True'})
35
        },
36
        u'attribute_aggregator.attributelist': {
37
            'Meta': {'object_name': 'AttributeList'},
38
            'attributes': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'attributes of the list'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['attribute_aggregator.AttributeItem']"}),
39
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
40
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'})
41
        },
42
        u'attribute_aggregator.attributesource': {
43
            'Meta': {'object_name': 'AttributeSource'},
44
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
45
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}),
46
            'namespace': ('django.db.models.fields.CharField', [], {'default': "('Default', 'Default')", 'max_length': '100'})
47
        },
48
        u'auth.group': {
49
            'Meta': {'object_name': 'Group'},
50
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
51
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
52
            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
53
        },
54
        u'auth.permission': {
55
            'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
56
            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
57
            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
58
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
59
            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
60
        },
61
        u'auth.user': {
62
            'Meta': {'object_name': 'User'},
63
            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
64
            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
65
            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
66
            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
67
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
68
            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
69
            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
70
            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
71
            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
72
            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
73
            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
74
            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
75
            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
76
        },
77
        u'authentic2.attributesource': {
78
            'Meta': {'object_name': 'AttributeSource'},
79
            'description': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
80
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
81
            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
82
        },
83
        u'contenttypes.contenttype': {
84
            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
85
            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
86
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
87
            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
88
            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
89
        },
90
        u'idp.attributepolicy': {
91
            'Meta': {'object_name': 'AttributePolicy'},
92
            'allow_attributes_selection': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
93
            'ask_consent_attributes': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
94
            'attribute_filter_for_sso_from_push_sources': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'filter attributes of push sources with list'", 'null': 'True', 'to': u"orm['attribute_aggregator.AttributeList']"}),
95
            'attribute_list_for_sso_from_pull_sources': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'attributes from pull sources'", 'null': 'True', 'to': u"orm['attribute_aggregator.AttributeList']"}),
96
            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
97
            'filter_source_of_filtered_attributes': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
98
            'forward_attributes_from_push_sources': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
99
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
100
            'map_attributes_from_push_sources': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
101
            'map_attributes_of_filtered_attributes': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
102
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
103
            'output_name_format': ('django.db.models.fields.CharField', [], {'default': "('urn:oasis:names:tc:SAML:2.0:attrname-format:uri', 'SAMLv2 URI')", 'max_length': '100'}),
104
            'output_namespace': ('django.db.models.fields.CharField', [], {'default': "('Default', 'Default')", 'max_length': '100'}),
105
            'send_error_and_no_attrs_if_missing_required_attrs': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
106
            'source_filter_for_sso_from_push_sources': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'filter attributes of push sources with sources'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['attribute_aggregator.AttributeSource']"})
107
        },
108
        u'saml.authorizationattributemap': {
109
            'Meta': {'object_name': 'AuthorizationAttributeMap'},
110
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
111
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40'})
112
        },
113
        u'saml.authorizationattributemapping': {
114
            'Meta': {'object_name': 'AuthorizationAttributeMapping'},
115
            'attribute_name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
116
            'attribute_value': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
117
            'attribute_value_format': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'}),
118
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
119
            'map': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['saml.AuthorizationAttributeMap']"}),
120
            'source_attribute_name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'})
121
        },
122
        u'saml.authorizationsppolicy': {
123
            'Meta': {'object_name': 'AuthorizationSPPolicy'},
124
            'attribute_map': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'authorization_attributes'", 'null': 'True', 'to': u"orm['saml.AuthorizationAttributeMap']"}),
125
            'default_denial_message': ('django.db.models.fields.CharField', [], {'default': "u'You are not authorized to access the service.'", 'max_length': '80'}),
126
            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
127
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
128
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'})
129
        },
130
        u'saml.idpoptionssppolicy': {
131
            'Meta': {'object_name': 'IdPOptionsSPPolicy'},
132
            'accept_slo': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
133
            'allow_create': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
134
            'back_url': ('django.db.models.fields.CharField', [], {'default': "'/'", 'max_length': '200'}),
135
            'binding_for_sso_response': ('django.db.models.fields.CharField', [], {'default': "'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact'", 'max_length': '200'}),
136
            'enable_binding_for_sso_response': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
137
            'enable_http_method_for_defederation_request': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
138
            'enable_http_method_for_slo_request': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
139
            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
140
            'force_user_consent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
141
            'forward_slo': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
142
            'handle_persistent': ('django.db.models.fields.CharField', [], {'default': "'AUTHSAML2_UNAUTH_PERSISTENT_ACCOUNT_LINKING_BY_AUTH'", 'max_length': '200'}),
143
            'handle_transient': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200'}),
144
            'http_method_for_defederation_request': ('django.db.models.fields.IntegerField', [], {'default': '5', 'max_length': '200'}),
145
            'http_method_for_slo_request': ('django.db.models.fields.IntegerField', [], {'default': '4', 'max_length': '200'}),
146
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
147
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}),
148
            'no_nameid_policy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
149
            'persistent_identifier_attribute': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
150
            'requested_name_id_format': ('django.db.models.fields.CharField', [], {'default': "'none'", 'max_length': '200'}),
151
            'transient_is_persistent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
152
            'want_authn_request_signed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
153
            'want_force_authn_request': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
154
            'want_is_passive_authn_request': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
155
        },
156
        u'saml.keyvalue': {
157
            'Meta': {'object_name': 'KeyValue'},
158
            'key': ('django.db.models.fields.CharField', [], {'max_length': '128', 'primary_key': 'True'}),
159
            'value': ('authentic2.saml.fields.PickledObjectField', [], {})
160
        },
161
        u'saml.libertyartifact': {
162
            'Meta': {'object_name': 'LibertyArtifact'},
163
            'artifact': ('django.db.models.fields.CharField', [], {'max_length': '128', 'primary_key': 'True'}),
164
            'content': ('django.db.models.fields.TextField', [], {}),
165
            'creation': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
166
            'provider_id': ('django.db.models.fields.CharField', [], {'max_length': '256'})
167
        },
168
        u'saml.libertyassertion': {
169
            'Meta': {'object_name': 'LibertyAssertion'},
170
            'assertion': ('django.db.models.fields.TextField', [], {}),
171
            'assertion_id': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
172
            'creation': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
173
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
174
            'provider_id': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
175
            'session_index': ('django.db.models.fields.CharField', [], {'max_length': '128'})
176
        },
177
        u'saml.libertyfederation': {
178
            'Meta': {'object_name': 'LibertyFederation'},
179
            'creation': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
180
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
181
            'idp': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['saml.LibertyIdentityProvider']", 'null': 'True', 'blank': 'True'}),
182
            'last_modification': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
183
            'name_id_content': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
184
            'name_id_format': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
185
            'name_id_qualifier': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}),
186
            'name_id_sp_name_qualifier': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}),
187
            'sp': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['saml.LibertyServiceProvider']", 'null': 'True', 'blank': 'True'}),
188
            'termination_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
189
            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'})
190
        },
191
        u'saml.libertyidentityprovider': {
192
            'Meta': {'object_name': 'LibertyIdentityProvider'},
193
            'authorization_policy': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'authorization_policy'", 'null': 'True', 'to': u"orm['saml.AuthorizationSPPolicy']"}),
194
            'enable_following_authorization_policy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
195
            'enable_following_idp_options_policy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
196
            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
197
            'idp_options_policy': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'idp_options_policy'", 'null': 'True', 'to': u"orm['saml.IdPOptionsSPPolicy']"}),
198
            'liberty_provider': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'identity_provider'", 'unique': 'True', 'primary_key': 'True', 'to': u"orm['saml.LibertyProvider']"})
199
        },
200
        u'saml.libertymanagedump': {
201
            'Meta': {'object_name': 'LibertyManageDump'},
202
            'django_session_key': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
203
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
204
            'manage_dump': ('django.db.models.fields.TextField', [], {'blank': 'True'})
205
        },
206
        u'saml.libertyprovider': {
207
            'Meta': {'ordering': "('name',)", 'object_name': 'LibertyProvider'},
208
            'ca_cert_chain': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
209
            'entity_id': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '200'}),
210
            'entity_id_sha1': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'}),
211
            'federation_source': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
212
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
213
            'metadata': ('django.db.models.fields.TextField', [], {}),
214
            'name': ('django.db.models.fields.CharField', [], {'max_length': '140', 'blank': 'True'}),
215
            'protocol_conformance': ('django.db.models.fields.IntegerField', [], {'max_length': '10'}),
216
            'public_key': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
217
            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '140'}),
218
            'ssl_certificate': ('django.db.models.fields.TextField', [], {'blank': 'True'})
219
        },
220
        u'saml.libertyproviderpolicy': {
221
            'Meta': {'object_name': 'LibertyProviderPolicy'},
222
            'authn_request_signature_check_hint': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
223
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
224
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'})
225
        },
226
        u'saml.libertyserviceprovider': {
227
            'Meta': {'object_name': 'LibertyServiceProvider'},
228
            'attribute_policy': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'attribute_policy'", 'null': 'True', 'to': u"orm['idp.AttributePolicy']"}),
229
            'enable_following_attribute_policy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
230
            'enable_following_sp_options_policy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
231
            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
232
            'liberty_provider': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'service_provider'", 'unique': 'True', 'primary_key': 'True', 'to': u"orm['saml.LibertyProvider']"}),
233
            'policy': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': u"orm['saml.LibertyProviderPolicy']", 'null': 'True'}),
234
            'sp_options_policy': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'sp_options_policy'", 'null': 'True', 'to': u"orm['saml.SPOptionsIdPPolicy']"})
235
        },
236
        u'saml.libertysession': {
237
            'Meta': {'object_name': 'LibertySession'},
238
            'assertion': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['saml.LibertyAssertion']", 'null': 'True', 'blank': 'True'}),
239
            'creation': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
240
            'django_session_key': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
241
            'federation': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['saml.LibertyFederation']", 'null': 'True', 'blank': 'True'}),
242
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
243
            'name_id_content': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
244
            'name_id_format': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),
245
            'name_id_qualifier': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
246
            'name_id_sp_name_qualifier': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
247
            'provider_id': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
248
            'session_index': ('django.db.models.fields.CharField', [], {'max_length': '80'})
249
        },
250
        u'saml.libertysessiondump': {
251
            'Meta': {'object_name': 'LibertySessionDump'},
252
            'django_session_key': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
253
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
254
            'kind': ('django.db.models.fields.IntegerField', [], {}),
255
            'session_dump': ('django.db.models.fields.TextField', [], {'blank': 'True'})
256
        },
257
        u'saml.libertysessionsp': {
258
            'Meta': {'object_name': 'LibertySessionSP'},
259
            'django_session_key': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
260
            'federation': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['saml.LibertyFederation']"}),
261
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
262
            'session_index': ('django.db.models.fields.CharField', [], {'max_length': '80'})
263
        },
264
        u'saml.samlattribute': {
265
            'Meta': {'object_name': 'SAMLAttribute'},
266
            'attribute_name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
267
            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
268
            'friendly_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
269
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
270
            'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
271
            'name_format': ('django.db.models.fields.CharField', [], {'default': "'basic'", 'max_length': '64'}),
272
            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {})
273
        },
274
        u'saml.spoptionsidppolicy': {
275
            'Meta': {'object_name': 'SPOptionsIdPPolicy'},
276
            'accept_slo': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
277
            'accepted_name_id_format': ('authentic2.saml.fields.MultiSelectField', [], {'max_length': '1024', 'blank': 'True'}),
278
            'ask_user_consent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
279
            'attribute_sources': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['authentic2.AttributeSource']", 'symmetrical': 'False'}),
280
            'authn_request_signed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
281
            'default_name_id_format': ('django.db.models.fields.CharField', [], {'default': "'none'", 'max_length': '256'}),
282
            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
283
            'encrypt_assertion': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
284
            'encrypt_nameid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
285
            'federation_mode': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
286
            'forward_slo': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
287
            'http_method_for_slo_request': ('django.db.models.fields.IntegerField', [], {'default': '4'}),
288
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
289
            'idp_initiated_sso': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
290
            'iframe_logout_timeout': ('django.db.models.fields.PositiveIntegerField', [], {'default': '300'}),
291
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
292
            'needs_iframe_logout': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
293
            'prefered_assertion_consumer_binding': ('django.db.models.fields.CharField', [], {'default': "'meta'", 'max_length': '4'})
294
        }
295
    }
296

  
297
    complete_apps = ['saml']
authentic2/saml/models.py
24 24
from fields import PickledObjectField, MultiSelectField
25 25

  
26 26
from . import app_settings, managers
27
from .. import managers as a2_managers
27
from .. import managers as a2_managers, models as a2_models
28 28

  
29 29
def metadata_validator(meta):
30 30
    provider=lasso.Provider.newFromBuffer(lasso.PROVIDER_ROLE_ANY, meta.encode('utf8'))
......
254 254
        return self.name
255 255

  
256 256

  
257
class SPOptionsIdPPolicy(models.Model):
257
class SPOptionsIdPPolicy(a2_models.ModelWithAttributeSources):
258 258
    '''
259 259
        Policies configured as a SAML2 identity provider.
260 260

  
261
-