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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca (strifel)
uffd
Commits
54c98455
Commit
54c98455
authored
4 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
handle unsafe login name in forgot_password, closes #31
parent
eb7e2911
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/test_selfservice.py
+9
-0
9 additions, 0 deletions
tests/test_selfservice.py
uffd/ldap/ldap.py
+1
-1
1 addition, 1 deletion
uffd/ldap/ldap.py
uffd/selfservice/views.py
+4
-1
4 additions, 1 deletion
uffd/selfservice/views.py
with
14 additions
and
2 deletions
tests/test_selfservice.py
+
9
−
0
View file @
54c98455
...
@@ -176,6 +176,15 @@ class TestSelfservice(UffdTestCase):
...
@@ -176,6 +176,15 @@ class TestSelfservice(UffdTestCase):
self
.
assertFalse
(
hasattr
(
self
.
app
,
'
last_mail
'
))
self
.
assertFalse
(
hasattr
(
self
.
app
,
'
last_mail
'
))
self
.
assertEqual
(
len
(
PasswordToken
.
query
.
all
()),
0
)
self
.
assertEqual
(
len
(
PasswordToken
.
query
.
all
()),
0
)
# Regression test for #31
def
test_forgot_password_invalid_user
(
self
):
r
=
self
.
client
.
post
(
path
=
url_for
(
'
selfservice.forgot_password
'
),
data
=
{
'
loginname
'
:
'
=
'
,
'
mail
'
:
'
test@example.com
'
},
follow_redirects
=
True
)
dump
(
'
forgot_password_submit_invalid_user
'
,
r
)
self
.
assertEqual
(
r
.
status_code
,
200
)
self
.
assertFalse
(
hasattr
(
self
.
app
,
'
last_mail
'
))
self
.
assertEqual
(
len
(
PasswordToken
.
query
.
all
()),
0
)
def
test_token_password
(
self
):
def
test_token_password
(
self
):
user
=
User
.
from_ldap_dn
(
'
uid=testuser,ou=users,dc=example,dc=com
'
)
user
=
User
.
from_ldap_dn
(
'
uid=testuser,ou=users,dc=example,dc=com
'
)
oldpw
=
get_ldap_password
()
oldpw
=
get_ldap_password
()
...
...
This diff is collapsed.
Click to expand it.
uffd/ldap/ldap.py
+
1
−
1
View file @
54c98455
...
@@ -67,7 +67,7 @@ def uid_to_dn(uid):
...
@@ -67,7 +67,7 @@ def uid_to_dn(uid):
def
loginname_to_dn
(
loginname
):
def
loginname_to_dn
(
loginname
):
if
loginname_is_safe
(
loginname
):
if
loginname_is_safe
(
loginname
):
return
'
uid={},{}
'
.
format
(
loginname
,
current_app
.
config
[
"
LDAP_BASE_USER
"
])
return
'
uid={},{}
'
.
format
(
loginname
,
current_app
.
config
[
"
LDAP_BASE_USER
"
])
raise
Exception
(
'
unsafe login name
'
)
raise
ValueError
(
'
unsafe login name
'
)
def
mail_to_dn
(
uid
):
def
mail_to_dn
(
uid
):
if
mailname_is_safe
(
uid
):
if
mailname_is_safe
(
uid
):
...
...
This diff is collapsed.
Click to expand it.
uffd/selfservice/views.py
+
4
−
1
View file @
54c98455
...
@@ -67,7 +67,10 @@ def forgot_password():
...
@@ -67,7 +67,10 @@ def forgot_password():
reset_ratelimit
.
log
(
loginname
+
'
/
'
+
mail
)
reset_ratelimit
.
log
(
loginname
+
'
/
'
+
mail
)
host_ratelimit
.
log
()
host_ratelimit
.
log
()
flash
(
"
We sent a mail to this users mail address if you entered the correct mail and login name combination
"
)
flash
(
"
We sent a mail to this users mail address if you entered the correct mail and login name combination
"
)
try
:
user
=
User
.
from_ldap_dn
(
loginname_to_dn
(
loginname
))
user
=
User
.
from_ldap_dn
(
loginname_to_dn
(
loginname
))
except
ValueError
:
user
=
None
if
user
and
user
.
mail
==
mail
:
if
user
and
user
.
mail
==
mail
:
send_passwordreset
(
loginname
)
send_passwordreset
(
loginname
)
return
redirect
(
url_for
(
'
session.login
'
))
return
redirect
(
url_for
(
'
session.login
'
))
...
...
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