aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Chatzimichos <tampakrap@gentoo.org>2013-07-10 16:03:45 +0200
committerTheo Chatzimichos <tampakrap@gentoo.org>2013-07-10 16:03:45 +0200
commit3c235ac654bd5504faab15d696f1bcbe4a623da2 (patch)
treeebd44352294a293d141d233bcdbc5f180d352989 /okupy/accounts/models.py
parentMove tests.tests.example_directory to tests.settings.DIRECTORY (diff)
downloadidentity.gentoo.org-3c235ac654bd5504faab15d696f1bcbe4a623da2.tar.gz
identity.gentoo.org-3c235ac654bd5504faab15d696f1bcbe4a623da2.tar.bz2
identity.gentoo.org-3c235ac654bd5504faab15d696f1bcbe4a623da2.zip
Add LDAPUser model, from django-ldapdb
It is in very early stage, plus it has many hardcoded things, but it provides the API we want to get LDAP accounts as python objects. TODO list regarding LDAPUser and django-ldapdb can be found at: https://github.com/gentoo/identity.gentoo.org/wiki/TODO_tampakrap#django-ldapdb Example: >>> alice = LDAPUser.objects.get(username='alice') >>> developers = LDAPUser.objects.filter(ACL__contains='dev.group') PS Since it is in early stage, and the final form of it is not fully defined yet, I'm skipping the tests for now till we have a final design
Diffstat (limited to 'okupy/accounts/models.py')
-rw-r--r--okupy/accounts/models.py54
1 files changed, 53 insertions, 1 deletions
diff --git a/okupy/accounts/models.py b/okupy/accounts/models.py
index 190137a..976c26f 100644
--- a/okupy/accounts/models.py
+++ b/okupy/accounts/models.py
@@ -1,6 +1,9 @@
# vim:fileencoding=utf8:et:ts=4:sts=4:sw=4:ft=python
+from django.conf import settings
from django.db import models
+from ldapdb.models.fields import CharField, IntegerField, ListField
+import ldapdb.models
class Queue(models.Model):
@@ -11,8 +14,57 @@ class Queue(models.Model):
email = models.EmailField(max_length=254, unique=True)
token = models.CharField(max_length=40)
-# Models for OpenID data store
+class LDAPUser(ldapdb.models.Model):
+ """ Class representing an LDAP user entry """
+ # LDAP metadata
+ base_dn = settings.AUTH_LDAP_USER_BASE_DN
+ object_classes = settings.AUTH_LDAP_USER_OBJECTCLASS + \
+ settings.AUTH_LDAP_DEV_OBJECTCLASS
+ # person
+ last_name = CharField(db_column='sn')
+ full_name = CharField(db_column='cn')
+ description = CharField(db_column='description')
+ phone = CharField(db_column='telephoneNumber', blank=True)
+ password = ListField(db_column='userPassword')
+ # inetOrgPerson
+ first_name = CharField(db_column='givenName')
+ email = ListField(db_column='mail')
+ username = CharField(db_column='uid', primary_key=True)
+ # posixAccount
+ uid = IntegerField(db_column='uidNumber', unique=True)
+ gid = IntegerField(db_column='gidNumber')
+ gecos = CharField(db_column='gecos')
+ home_directory = CharField(db_column='homeDirectory')
+ login_shell = CharField(db_column='loginShell', default='/bin/bash')
+ # ldapPublicKey
+ ssh_key = ListField(db_column='sshPublicKey')
+ # gentooGroup
+ ACL = ListField(db_column='gentooACL')
+ birthday = CharField(db_column='birthday')
+ gentoo_join_date = ListField(db_column='gentooJoin')
+ gentoo_retire_date = ListField(db_column='gentooRetire')
+ developer_bug = ListField(db_column='gentooDevBug')
+ gpg_fingerprint = ListField(db_column='gentooGPGFingerprint')
+ gpg_key = ListField(db_column='gentooGPGKey')
+ latitude = IntegerField(db_column='gentooLatitude')
+ longitude = IntegerField(db_column='gentooLongitude')
+ location = CharField(db_column='gentooLocation')
+ mentor = ListField(db_column='gentooMentor')
+ im = ListField(db_column='gentooIM')
+ # gentooDevGroup
+ roles = CharField(db_column='gentooRoles')
+ alias = ListField(db_column='gentooAlias')
+ spf = ListField(db_column='gentooSPF')
+
+ def __str__(self):
+ return self.username
+
+ def __unicode__(self):
+ return self.username
+
+
+# Models for OpenID data store
class OpenID_Nonce(models.Model):
server_uri = models.URLField(max_length=2048)