Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uffd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca (strifel)
uffd
Commits
6d13eecd
Commit
6d13eecd
authored
4 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Fixed and refactored default and update mechanism
parent
5d63c4fe
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
uffd/ldap.py
+18
-9
18 additions, 9 deletions
uffd/ldap.py
uffd/user/models.py
+1
-1
1 addition, 1 deletion
uffd/user/models.py
with
19 additions
and
10 deletions
uffd/ldap.py
+
18
−
9
View file @
6d13eecd
...
...
@@ -163,21 +163,28 @@ class LDAPAttribute:
if
callable
(
values
):
values
=
values
()
self
.
__set__
(
obj
,
values
)
def
additem
(
self
,
obj
,
value
):
obj
.
ldap_attradd
(
self
.
name
,
value
)
for
name
in
self
.
aliases
:
obj
.
ldap_attradd
(
name
,
value
)
def
delitem
(
self
,
obj
,
value
):
obj
.
ldap_attradd
(
self
.
name
,
value
)
for
name
in
self
.
aliases
:
obj
.
ldap_
set
attr
(
name
,
obj
.
ldap_getattr
(
self
.
nam
e
)
)
obj
.
ldap_attr
add
(
name
,
valu
e
)
def
__set_name__
(
self
,
cls
,
name
):
if
self
.
default
is
None
:
return
cls
.
ldap_defaults
=
cls
.
ldap_defaults
+
[
self
.
default
]
if
self
.
default_values
is
not
None
:
cls
.
ldap_pre_create_hooks
=
cls
.
ldap_pre_create_hooks
+
[
self
.
default
]
def
__get__
(
self
,
obj
,
objtype
=
None
):
if
obj
is
None
:
return
self
if
self
.
multi
:
return
LDAPSet
(
getitems
=
lambda
:
obj
.
ldap_getattr
(
self
.
name
),
additem
=
lambda
value
:
obj
.
ldap_attradd
(
self
.
name
,
value
),
delitem
=
lambda
value
:
obj
.
ldap_attrdel
(
self
.
name
,
value
),
additem
=
lambda
value
:
self
.
additem
(
obj
,
value
),
delitem
=
lambda
value
:
self
.
delitem
(
obj
,
value
),
encode
=
self
.
encode
,
decode
=
self
.
decode
)
return
self
.
decode
((
obj
.
ldap_getattr
(
self
.
name
)
or
[
None
])[
0
])
...
...
@@ -185,6 +192,8 @@ class LDAPAttribute:
if
not
self
.
multi
:
values
=
[
values
]
obj
.
ldap_setattr
(
self
.
name
,
[
self
.
encode
(
value
)
for
value
in
values
])
for
name
in
self
.
aliases
:
obj
.
ldap_setattr
(
name
,
[
self
.
encode
(
value
)
for
value
in
values
])
class
LDAPBackref
:
def
__init__
(
self
,
srccls
,
srcattr
):
...
...
@@ -229,8 +238,8 @@ class LDAPModel:
ldap_base
=
None
ldap_object_classes
=
None
ldap_filter
=
None
# Caution: Never mutate ldap_
default
s and ldap_relations, always reassign!
ldap_
default
s
=
[]
# Caution: Never mutate ldap_
pre_create_hook
s and ldap_relations, always reassign!
ldap_
pre_create_hook
s
=
[]
ldap_relations
=
[]
def
__init__
(
self
,
_ldap_dn
=
None
,
_ldap_attributes
=
None
,
**
kwargs
):
...
...
@@ -376,7 +385,7 @@ class LDAPModel:
if
self
.
ldap_created
:
raise
Exception
()
conn
=
get_conn
()
for
func
in
self
.
ldap_
default
s
:
for
func
in
self
.
ldap_
pre_create_hook
s
:
func
(
self
)
success
=
conn
.
add
(
self
.
dn
,
self
.
ldap_object_classes
,
self
.
__attributes
)
if
not
success
:
...
...
This diff is collapsed.
Click to expand it.
uffd/user/models.py
+
1
−
1
View file @
6d13eecd
...
...
@@ -39,7 +39,7 @@ class User(LDAPModel):
if
self
.
ldap_getattr
(
'
gidNumber
'
)
==
[]:
self
.
ldap_setattr
(
'
gidNumber
'
,
[
current_app
.
config
[
'
LDAP_USER_GID
'
]])
ldap_
default
s
=
LDAPModel
.
ldap_
default
s
+
[
dummy_attribute_defaults
]
ldap_
pre_create_hook
s
=
LDAPModel
.
ldap_
pre_create_hook
s
+
[
dummy_attribute_defaults
]
# Write-only property
def
password
(
self
,
value
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment