Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
authserv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
authserv
Commits
17d1900f
Commit
17d1900f
authored
11 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
log errors; fix app-specific pass decoding
parent
af8a777c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
authserv/ldap_model.py
+8
-4
8 additions, 4 deletions
authserv/ldap_model.py
with
8 additions
and
4 deletions
authserv/ldap_model.py
+
8
−
4
View file @
17d1900f
import
contextlib
import
ldap
import
logging
from
ldap.dn
import
escape_dn_chars
from
ldap.filter
import
escape_filter_chars
from
ldap.ldapobject
import
LDAPObject
...
...
@@ -40,6 +41,7 @@ class UserDb(model.UserDb):
while
isinstance
(
ldap_params
,
basestring
):
ldap_params
=
self
.
service_map
.
get
(
ldap_params
)
if
not
ldap_params
:
logging
.
error
(
'
unknown service
"
%s
"'
,
service
)
return
None
with
self
.
_conn
()
as
c
:
...
...
@@ -61,6 +63,7 @@ class UserDb(model.UserDb):
base
=
ldap_params
[
'
base
'
].
replace
(
'
%s
'
,
escape_dn_chars
(
username
))
filt
=
ldap_params
[
'
filter
'
].
replace
(
'
%s
'
,
escape_filter_chars
(
username
))
scope
=
ldap
.
SCOPE_SUBTREE
logging
.
debug
(
'
ldap search: base=%s, scope=%s, filt=%s
'
,
base
,
scope
,
filt
)
result
=
c
.
search_s
(
base
,
scope
,
filt
,
self
.
ldap_attrs
)
if
not
result
:
...
...
@@ -72,8 +75,9 @@ class UserDb(model.UserDb):
def
get_user
(
self
,
username
,
service
):
try
:
return
User
(
username
)
except
(
Error
,
ldap
.
LDAPError
):
return
self
.
_query_user
(
username
,
service
)
except
(
Error
,
ldap
.
LDAPError
),
e
:
logging
.
error
(
'
userdb error: %s
'
,
e
)
return
None
...
...
@@ -93,7 +97,7 @@ class User(model.User):
self
.
_otp_enabled
=
True
self
.
_totp_secret
=
values
[
0
]
elif
key
==
'
appSpecificPassword
'
:
self
.
_asps
=
[
v
.
split
(
'
:
'
,
2
)
for
v
in
values
]
self
.
_asps
=
[
v
.
split
(
'
:
'
,
1
)
for
v
in
values
]
def
otp_enabled
(
self
):
return
self
.
_otp_enabled
...
...
@@ -108,7 +112,7 @@ class User(model.User):
return
self
.
_totp_secret
def
get_app_specific_passwords
(
self
,
service
):
return
[
x
[
2
]
for
x
in
self
.
_asps
if
x
[
0
]
==
service
]
return
[
x
[
1
]
for
x
in
self
.
_asps
if
x
[
0
]
==
service
]
def
get_password
(
self
):
return
self
.
_password
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