Skip to content

Commit 2f6cb20

Browse files
committed
Up version to 0.3.0
Merged PRs: #11 and #13. Fixed some PEP 8 issues and typos.
1 parent 8ad9348 commit 2f6cb20

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def __getattr__(cls, name):
6363
# built documents.
6464
#
6565
# The short X.Y version.
66-
version = '0.2.1'
66+
version = '0.3.0'
6767
# The full version, including alpha/beta/rc tags.
68-
release = '0.2.1'
68+
release = '0.3.0'
6969

7070
# The language for content autogenerated by Sphinx. Refer to documentation
7171
# for a list of supported languages.

docs/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,14 @@ History
108108

109109
Changes:
110110

111-
- 0.2.1: January 6, 2015
111+
- 0.3.0: January 21, 2015
112112

113113
- Fix Github issue `#10 <https://github.com/admiralobvious/flask-simpleldap/issues/10>`_,
114114
Redirect users back to the page they originally requested after authenticating
115115

116+
- Fix GitHub issue `#12 <https://github.com/admiralobvious/flask-simpleldap/issues/12>`_,
117+
Only trust .bind_user() with a non-empty password
118+
116119
- 0.2.0: December 7, 2014
117120

118121
- Added HTTP Basic Authentication. Thanks to OptiverTimAll on GitHub.

examples/groups/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def login():
3636
user = request.form['user']
3737
passwd = request.form['passwd']
3838
test = ldap.bind_user(user, passwd)
39-
if test is None or passwd = '':
39+
if test is None or passwd == '':
4040
return 'Invalid credentials'
4141
else:
4242
session['user_id'] = request.form['user']

flask_simpleldap/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
__all__ = ['LDAP']
33

44
import re
5+
from functools import wraps
6+
57
import ldap
68
import ldap.filter
7-
from functools import wraps
8-
from flask import abort, current_app, g, make_response, redirect, url_for, request
9+
from flask import abort, current_app, g, make_response, redirect, url_for, \
10+
request
911

1012
try:
1113
from flask import _app_ctx_stack as stack
@@ -202,8 +204,8 @@ def get_user_groups(self, user):
202204
[current_app.config['LDAP_USER_GROUPS_FIELD']])
203205
conn.unbind_s()
204206
if records:
205-
if current_app.config['LDAP_USER_GROUPS_FIELD'] in records[0][
206-
1]:
207+
if current_app.config['LDAP_USER_GROUPS_FIELD'] in \
208+
records[0][1]:
207209
groups = records[0][1][
208210
current_app.config['LDAP_USER_GROUPS_FIELD']]
209211
result = [re.findall('(?:cn=|CN=)(.*?),', group)[0] for
@@ -259,7 +261,8 @@ def login_required(func):
259261
@wraps(func)
260262
def wrapped(*args, **kwargs):
261263
if g.user is None:
262-
return redirect(url_for(current_app.config['LDAP_LOGIN_VIEW'], next=request.path))
264+
return redirect(url_for(current_app.config['LDAP_LOGIN_VIEW'],
265+
next=request.path))
263266
return func(*args, **kwargs)
264267

265268
return wrapped
@@ -272,7 +275,7 @@ def group_required(groups=None):
272275
273276
The login view is responsible for asking for credentials, checking
274277
them, and setting ``flask.g.user`` to the name of the authenticated
275-
user and ``flask.g.ldap_groups`` to the authenticated's user's groups
278+
user and ``flask.g.ldap_groups`` to the authenticated user's groups
276279
if the credentials are acceptable.
277280
278281
:param list groups: List of groups that should be able to access the
@@ -284,7 +287,8 @@ def wrapper(func):
284287
def wrapped(*args, **kwargs):
285288
if g.user is None:
286289
return redirect(
287-
url_for(current_app.config['LDAP_LOGIN_VIEW'], next=request.path))
290+
url_for(current_app.config['LDAP_LOGIN_VIEW'],
291+
next=request.path))
288292

289293
match = [group for group in groups if group in g.ldap_groups]
290294
if not match:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name='Flask-SimpleLDAP',
12-
version='0.2.1',
12+
version='0.3.0',
1313
url='https://github.com/admiralobvious/flask-simpleldap',
1414
license='MIT',
1515
author='Alexandre Ferland',

0 commit comments

Comments
 (0)