Skip to content

Commit

Permalink
Merge bf5e3a0 into 174198d
Browse files Browse the repository at this point in the history
  • Loading branch information
carsongee committed Apr 20, 2017
2 parents 174198d + bf5e3a0 commit 0737b62
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -56,3 +56,5 @@ docs/_build/

# PyBuilder
target/
# pyenv
.python-version
9 changes: 6 additions & 3 deletions .travis.yml
@@ -1,10 +1,13 @@
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
install:
- pip install coveralls
- pip install coveralls tox-travis
script:
- python setup.py install
- python setup.py test
- tox
after_success:
coveralls
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -41,7 +41,7 @@ something like:
.. code-block:: python
import flask
from flask.ext.htpasswd import HtPasswdAuth
from flask_htpasswd import HtPasswdAuth
app = flask.Flask(__name__)
app.config['FLASK_HTPASSWD_PATH'] = '/path/to/.htpasswd'
Expand Down Expand Up @@ -81,7 +81,7 @@ can serve it out to the user with something like
.. code-block:: python
import flask
from flask.ext.htpasswd import HtPasswdAuth
from flask_htpasswd import HtPasswdAuth
app = flask.Flask(__name__)
app.config['FLASK_HTPASSWD_PATH'] = '/path/to/.htpasswd'
Expand Down
10 changes: 5 additions & 5 deletions flask_htpasswd.py
Expand Up @@ -82,7 +82,7 @@ def check_basic_auth(self, username, password):
username, password
)
if not valid:
log.warn('Invalid login from %s', username)
log.warning('Invalid login from %s', username)
valid = False
return (
valid,
Expand All @@ -101,7 +101,7 @@ def get_hashhash(self, username):
Generate a digest of the htpasswd hash
"""
return hashlib.sha256(
self.users.find(username)
self.users.get_hash(username)
).hexdigest()

def generate_token(self, username):
Expand Down Expand Up @@ -129,16 +129,16 @@ def check_token_auth(self, token):
try:
data = serializer.loads(token)
except BadSignature:
log.warn('Received bad token signature')
log.warning('Received bad token signature')
return False, None
if data['username'] not in self.users.users():
log.warn(
log.warning(
'Token auth signed message, but invalid user %s',
data['username']
)
return False, None
if data['hashhash'] != self.get_hashhash(data['username']):
log.warn(
log.warning(
'Token and password do not match, %s '
'needs to regenerate token',
data['username']
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -69,7 +69,7 @@ def run_tests(self):
platforms='any',
install_requires=[
'Flask',
'passlib',
'passlib>=1.6',
'itsdangerous',
'tox',
],
Expand Down
6 changes: 3 additions & 3 deletions tests/test_htpasswd.py
Expand Up @@ -146,7 +146,7 @@ def test_token_auth(self, log):
)
self.assertEqual(False, valid)
self.assertEqual(None, username)
log.warn.assert_called_with('Received bad token signature')
log.warning.assert_called_with('Received bad token signature')

# Test bad username, but valid signature for users that have
# been deleted
Expand All @@ -157,7 +157,7 @@ def test_token_auth(self, log):
valid, username = self.htpasswd.check_token_auth(token)
self.assertEqual(False, valid)
self.assertEqual(None, username)
log.warn.assert_called_with(
log.warning.assert_called_with(
'Token auth signed message, but invalid user %s',
self.NOT_USER
)
Expand All @@ -170,7 +170,7 @@ def test_token_auth(self, log):
valid, username = self.htpasswd.check_token_auth(token)
self.assertEqual(False, valid)
self.assertEqual(None, username)
log.warn.assert_called_with(
log.warning.assert_called_with(
'Token and password do not match, '
'%s needs to regenerate token',
self.TEST_USER
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py{27,33,34}
envlist = py{27,33,34,35,36}
skip_missing_interpreters = True

[testenv]
Expand Down

0 comments on commit 0737b62

Please sign in to comment.