From a827f27bebc5a795ae4fd1abc382427666a7b527 Mon Sep 17 00:00:00 2001
From: Julian Rother <julianr@fsmpi.rwth-aachen.de>
Date: Sat, 31 Oct 2020 02:17:25 +0100
Subject: [PATCH] added ldap uuid to user object and oauth userinfo endpoint

---
 uffd/oauth2/views.py | 1 +
 uffd/user/models.py  | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/uffd/oauth2/views.py b/uffd/oauth2/views.py
index 9ebacb26..586b11d9 100644
--- a/uffd/oauth2/views.py
+++ b/uffd/oauth2/views.py
@@ -103,6 +103,7 @@ def userinfo():
 		nickname=user.loginname,
 		email=user.mail,
 		ldap_dn=user.dn,
+		ldap_uuid=user.uuid,
 		groups=[group.name for group in user.get_groups()]
 	)
 
diff --git a/uffd/user/models.py b/uffd/user/models.py
index 5158b323..56cc018d 100644
--- a/uffd/user/models.py
+++ b/uffd/user/models.py
@@ -7,13 +7,14 @@ from flask import current_app
 from uffd import ldap
 
 class User():
-	def __init__(self, uid=None, loginname='', displayname='', mail='', groups=None, dn=None):
+	def __init__(self, uid=None, loginname='', displayname='', mail='', groups=None, dn=None, uuid=None):
 		self.uid = uid
 		self.loginname = loginname
 		self.displayname = displayname
 		self.mail = mail
 		self.newpassword = None
 		self.dn = dn
+		self.uuid = uuid
 
 		self.groups_ldap = groups or []
 		self.initial_groups_ldap = groups or []
@@ -29,6 +30,7 @@ class User():
 				mail=ldapobject['mail'].value,
 				groups=ldap.get_ldap_array_attribute_safe(ldapobject, 'memberOf'),
 				dn=ldapobject.entry_dn,
+				uuid=ldapobject['entryUUID'].value
 			)
 
 	@classmethod
-- 
GitLab