Skip to content

Commit 9e35ac0

Browse files
authored
Merge pull request #48 from zfi/master
Add logging details for authetication errors.
2 parents 317558d + f57768f commit 9e35ac0

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

Failures.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def unknown_user_id(id_user):
1212

1313

1414
def unknown_user_email(email):
15-
logging.debug('Failures: Unknown user: %s', email)
15+
logging.debug('Failures: Unknown user email: %s', email)
1616
return {
1717
'success': False,
1818
'message': 'Unknown user',
@@ -41,17 +41,17 @@ def email_already_in_use(email):
4141
}, 500
4242

4343

44-
def email_not_confirmed():
45-
logging.debug('Failures: Email not confirmed')
44+
def email_not_confirmed(email):
45+
logging.debug('Failures: Email %s not confirmed', email)
4646
return {
4747
'success': False,
4848
'message': 'Email not confirmed',
4949
'code': 430
5050
}, 401
5151

5252

53-
def user_blocked():
54-
logging.debug('Failures: User blocked')
53+
def user_blocked(email):
54+
logging.debug('Failures: User %s blocked', email)
5555
return {
5656
'success': False,
5757
'message': 'User is blocked',
@@ -113,8 +113,8 @@ def rate_exceeded(time):
113113
}, 500
114114

115115

116-
def wrong_password():
117-
logging.debug('Failures: Wrong password')
116+
def wrong_password(email):
117+
logging.debug('Failures: Wrong password for %s', email)
118118
return {
119119
'success': False,
120120
'message': 'Wrong password',

app/Authenticate/controllers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def post(self):
4141
if user is None:
4242
return Failures.unknown_user_email(email)
4343
if not user.confirmed:
44-
return Failures.email_not_confirmed()
44+
return Failures.email_not_confirmed(email)
4545
if user.blocked:
46-
return Failures.user_blocked()
46+
return Failures.user_blocked(email)
4747
if user.auth_source != 'local':
4848
return Failures.wrong_auth_source(user.auth_source)
4949

@@ -53,11 +53,11 @@ def post(self):
5353
if not user_services.check_password(user.id, password):
5454
rate_limiting_services.consume_tokens(user.id, 'failed-password', 1)
5555
db.session.commit()
56-
return Failures.wrong_password()
56+
return Failures.wrong_password(email)
5757

5858
db.session.commit()
5959

60-
logging.info('Authenticate-controller: Authenticate: success: %s', user.id)
60+
logging.info('Authenticate-controller: Authenticate: success: %s', email)
6161

6262
return {'success': True, 'user': {
6363
'id': user.id,

app/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
app = Flask(__name__)
2525

2626
# Application version (major,minor,patch-level)
27-
version = "1.1.5"
27+
version = "1.1.6"
2828

2929
"""
3030
Change Log
3131
32+
1.1.6 Add email address detail for various authentication failures
33+
3234
1.1.5 Refactor _convert_email_uri(email) to properly handle a null
3335
email address.
3436

0 commit comments

Comments
 (0)