Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flask-simpleldap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
nimrod
flask-simpleldap
Commits
2f6cb20a
Commit
2f6cb20a
authored
10 years ago
by
admiralobvious
Browse files
Options
Downloads
Patches
Plain Diff
Up version to 0.3.0
Merged PRs: #11 and #13. Fixed some PEP 8 issues and typos.
parent
8ad9348e
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
docs/conf.py
+2
-2
2 additions, 2 deletions
docs/conf.py
docs/index.rst
+4
-1
4 additions, 1 deletion
docs/index.rst
examples/groups/app.py
+1
-1
1 addition, 1 deletion
examples/groups/app.py
flask_simpleldap/__init__.py
+11
-7
11 additions, 7 deletions
flask_simpleldap/__init__.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
19 additions
and
12 deletions
docs/conf.py
+
2
−
2
View file @
2f6cb20a
...
@@ -63,9 +63,9 @@ copyright = u'2014, Alexandre Ferland'
...
@@ -63,9 +63,9 @@ copyright = u'2014, Alexandre Ferland'
# built documents.
# built documents.
#
#
# The short X.Y version.
# The short X.Y version.
version
=
'
0.
2.1
'
version
=
'
0.
3.0
'
# The full version, including alpha/beta/rc tags.
# The full version, including alpha/beta/rc tags.
release
=
'
0.
2.1
'
release
=
'
0.
3.0
'
# The language for content autogenerated by Sphinx. Refer to documentation
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# for a list of supported languages.
...
...
This diff is collapsed.
Click to expand it.
docs/index.rst
+
4
−
1
View file @
2f6cb20a
...
@@ -108,11 +108,14 @@ History
...
@@ -108,11 +108,14 @@ History
Changes:
Changes:
- 0.
2.1
: January
6
, 2015
- 0.
3.0
: January
21
, 2015
- Fix Github issue `#10 <https://github.com/admiralobvious/flask-simpleldap/issues/10>`_,
- Fix Github issue `#10 <https://github.com/admiralobvious/flask-simpleldap/issues/10>`_,
Redirect users back to the page they originally requested after authenticating
Redirect users back to the page they originally requested after authenticating
- Fix GitHub issue `#12 <https://github.com/admiralobvious/flask-simpleldap/issues/12>`_,
Only trust .bind_user() with a non-empty password
- 0.2.0: December 7, 2014
- 0.2.0: December 7, 2014
- Added HTTP Basic Authentication. Thanks to OptiverTimAll on GitHub.
- Added HTTP Basic Authentication. Thanks to OptiverTimAll on GitHub.
...
...
This diff is collapsed.
Click to expand it.
examples/groups/app.py
+
1
−
1
View file @
2f6cb20a
...
@@ -36,7 +36,7 @@ def login():
...
@@ -36,7 +36,7 @@ def login():
user
=
request
.
form
[
'
user
'
]
user
=
request
.
form
[
'
user
'
]
passwd
=
request
.
form
[
'
passwd
'
]
passwd
=
request
.
form
[
'
passwd
'
]
test
=
ldap
.
bind_user
(
user
,
passwd
)
test
=
ldap
.
bind_user
(
user
,
passwd
)
if
test
is
None
or
passwd
=
''
:
if
test
is
None
or
passwd
=
=
''
:
return
'
Invalid credentials
'
return
'
Invalid credentials
'
else
:
else
:
session
[
'
user_id
'
]
=
request
.
form
[
'
user
'
]
session
[
'
user_id
'
]
=
request
.
form
[
'
user
'
]
...
...
This diff is collapsed.
Click to expand it.
flask_simpleldap/__init__.py
+
11
−
7
View file @
2f6cb20a
...
@@ -2,10 +2,12 @@
...
@@ -2,10 +2,12 @@
__all__
=
[
'
LDAP
'
]
__all__
=
[
'
LDAP
'
]
import
re
import
re
from
functools
import
wraps
import
ldap
import
ldap
import
ldap.filter
import
ldap.filter
from
f
unctools
import
wraps
from
f
lask
import
abort
,
current_app
,
g
,
make_response
,
redirect
,
url_for
,
\
from
flask
import
abort
,
current_app
,
g
,
make_response
,
redirect
,
url_for
,
request
request
try
:
try
:
from
flask
import
_app_ctx_stack
as
stack
from
flask
import
_app_ctx_stack
as
stack
...
@@ -202,8 +204,8 @@ class LDAP(object):
...
@@ -202,8 +204,8 @@ class LDAP(object):
[
current_app
.
config
[
'
LDAP_USER_GROUPS_FIELD
'
]])
[
current_app
.
config
[
'
LDAP_USER_GROUPS_FIELD
'
]])
conn
.
unbind_s
()
conn
.
unbind_s
()
if
records
:
if
records
:
if
current_app
.
config
[
'
LDAP_USER_GROUPS_FIELD
'
]
in
records
[
0
][
if
current_app
.
config
[
'
LDAP_USER_GROUPS_FIELD
'
]
in
\
1
]:
records
[
0
][
1
]:
groups
=
records
[
0
][
1
][
groups
=
records
[
0
][
1
][
current_app
.
config
[
'
LDAP_USER_GROUPS_FIELD
'
]]
current_app
.
config
[
'
LDAP_USER_GROUPS_FIELD
'
]]
result
=
[
re
.
findall
(
'
(?:cn=|CN=)(.*?),
'
,
group
)[
0
]
for
result
=
[
re
.
findall
(
'
(?:cn=|CN=)(.*?),
'
,
group
)[
0
]
for
...
@@ -259,7 +261,8 @@ class LDAP(object):
...
@@ -259,7 +261,8 @@ class LDAP(object):
@wraps
(
func
)
@wraps
(
func
)
def
wrapped
(
*
args
,
**
kwargs
):
def
wrapped
(
*
args
,
**
kwargs
):
if
g
.
user
is
None
:
if
g
.
user
is
None
:
return
redirect
(
url_for
(
current_app
.
config
[
'
LDAP_LOGIN_VIEW
'
],
next
=
request
.
path
))
return
redirect
(
url_for
(
current_app
.
config
[
'
LDAP_LOGIN_VIEW
'
],
next
=
request
.
path
))
return
func
(
*
args
,
**
kwargs
)
return
func
(
*
args
,
**
kwargs
)
return
wrapped
return
wrapped
...
@@ -272,7 +275,7 @@ class LDAP(object):
...
@@ -272,7 +275,7 @@ class LDAP(object):
The login view is responsible for asking for credentials, checking
The login view is responsible for asking for credentials, checking
them, and setting ``flask.g.user`` to the name of the authenticated
them, and setting ``flask.g.user`` to the name of the authenticated
user and ``flask.g.ldap_groups`` to the authenticated
'
s
user
'
s groups
user and ``flask.g.ldap_groups`` to the authenticated user
'
s groups
if the credentials are acceptable.
if the credentials are acceptable.
:param list groups: List of groups that should be able to access the
:param list groups: List of groups that should be able to access the
...
@@ -284,7 +287,8 @@ class LDAP(object):
...
@@ -284,7 +287,8 @@ class LDAP(object):
def
wrapped
(
*
args
,
**
kwargs
):
def
wrapped
(
*
args
,
**
kwargs
):
if
g
.
user
is
None
:
if
g
.
user
is
None
:
return
redirect
(
return
redirect
(
url_for
(
current_app
.
config
[
'
LDAP_LOGIN_VIEW
'
],
next
=
request
.
path
))
url_for
(
current_app
.
config
[
'
LDAP_LOGIN_VIEW
'
],
next
=
request
.
path
))
match
=
[
group
for
group
in
groups
if
group
in
g
.
ldap_groups
]
match
=
[
group
for
group
in
groups
if
group
in
g
.
ldap_groups
]
if
not
match
:
if
not
match
:
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
2f6cb20a
...
@@ -9,7 +9,7 @@ from setuptools import setup
...
@@ -9,7 +9,7 @@ from setuptools import setup
setup
(
setup
(
name
=
'
Flask-SimpleLDAP
'
,
name
=
'
Flask-SimpleLDAP
'
,
version
=
'
0.
2.1
'
,
version
=
'
0.
3.0
'
,
url
=
'
https://github.com/admiralobvious/flask-simpleldap
'
,
url
=
'
https://github.com/admiralobvious/flask-simpleldap
'
,
license
=
'
MIT
'
,
license
=
'
MIT
'
,
author
=
'
Alexandre Ferland
'
,
author
=
'
Alexandre Ferland
'
,
...
...
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