2018-11-26 16:18:56 +00:00
|
|
|
"""passbook LDAP Models"""
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2018-11-26 16:18:56 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.utils.translation import gettext as _
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2018-11-26 16:18:56 +00:00
|
|
|
from passbook.core.models import Source
|
|
|
|
|
|
|
|
|
|
|
|
class LDAPSource(Source):
|
|
|
|
"""LDAP Authentication source"""
|
|
|
|
|
|
|
|
TYPE_ACTIVE_DIRECTORY = 'ad'
|
|
|
|
TYPE_GENERIC = 'generic'
|
|
|
|
TYPES = (
|
2018-11-26 21:09:04 +00:00
|
|
|
(TYPE_ACTIVE_DIRECTORY, _('Active Directory')),
|
|
|
|
(TYPE_GENERIC, _('Generic')),
|
2018-11-26 16:18:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
server_uri = models.TextField()
|
|
|
|
bind_cn = models.TextField()
|
|
|
|
bind_password = models.TextField()
|
|
|
|
type = models.CharField(max_length=20, choices=TYPES)
|
|
|
|
|
|
|
|
domain = models.TextField()
|
|
|
|
base_dn = models.TextField()
|
|
|
|
create_user = models.BooleanField(default=False)
|
|
|
|
reset_password = models.BooleanField(default=True)
|
|
|
|
|
2018-11-26 17:22:38 +00:00
|
|
|
form = 'passbook.ldap.forms.LDAPSourceForm'
|
|
|
|
|
2018-12-18 12:24:58 +00:00
|
|
|
@property
|
2019-02-25 14:41:36 +00:00
|
|
|
def get_login_button(self):
|
2018-12-18 12:24:58 +00:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
2018-11-26 16:18:56 +00:00
|
|
|
class Meta:
|
|
|
|
|
|
|
|
verbose_name = _('LDAP Source')
|
|
|
|
verbose_name_plural = _('LDAP Sources')
|
2018-11-11 12:41:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
# class LDAPModification(UUIDModel, CreatedUpdatedModel):
|
|
|
|
# """Store LDAP Data in DB if LDAP Server is unavailable"""
|
|
|
|
# ACTION_ADD = 'ADD'
|
|
|
|
# ACTION_MODIFY = 'MODIFY'
|
|
|
|
|
|
|
|
# ACTIONS = (
|
|
|
|
# (ACTION_ADD, 'ADD'),
|
|
|
|
# (ACTION_MODIFY, 'MODIFY'),
|
|
|
|
# )
|
|
|
|
|
|
|
|
# dn = models.CharField(max_length=255)
|
|
|
|
# action = models.CharField(max_length=17, choices=ACTIONS, default=ACTION_MODIFY)
|
|
|
|
# data = JSONField()
|
|
|
|
|
|
|
|
# def __str__(self):
|
|
|
|
# return "LDAPModification %d from %s" % (self.pk, self.created)
|
|
|
|
|
|
|
|
|
|
|
|
# class LDAPGroupMapping(UUIDModel, CreatedUpdatedModel):
|
2019-02-26 13:07:47 +00:00
|
|
|
# """Model to map an LDAP Group to a passbook group"""
|
2018-11-11 12:41:48 +00:00
|
|
|
|
|
|
|
# ldap_dn = models.TextField()
|
|
|
|
# group = models.ForeignKey(Group, on_delete=models.CASCADE)
|
|
|
|
|
|
|
|
# def __str__(self):
|
|
|
|
# return "LDAPGroupMapping %s -> %s" % (self.ldap_dn, self.group.name)
|