This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.py
51 lines (33 loc) · 1.37 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from django.db import models
from django.contrib.auth.models import User, Group
class SamlUserManager(models.Manager):
use_in_migrations = True
def get_by_natural_key(self, user_name):
return self.get(user=User.objects.db_manager(self.db).get_by_natural_key(user_name))
class SamlUser(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
is_persistent = models.BooleanField(default=False)
objects = SamlUserManager()
def natural_key(self):
return (self.user.username,)
def __str__(self):
return str(self.user)
class Meta:
permissions = (
("is_ecs_user", "The user is within ECS"),
)
class EcsswebUserGroupManager(models.Manager):
use_in_migrations = True
def get_by_natural_key(self, group_name):
return self.get(group=Group.objects.db_manager(self.db).get_by_natural_key(group_name))
class EcsswebUserGroup(models.Model):
group = models.OneToOneField(Group, on_delete=models.CASCADE)
is_saml = models.BooleanField(default=False)
objects = EcsswebUserGroupManager()
def natural_key(self):
return (self.group.name,)
def __str__(self):
return str(self.group)
class ConsumedAssertionRecord(models.Model):
assertion_id = models.CharField(max_length=100, primary_key=True)
not_on_or_after = models.DateTimeField(db_index=True)