Skip to content

Commit

Permalink
add auth logger services
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoromike committed May 22, 2019
1 parent 95c907e commit 2b17cce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api/services/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import base64
from functools import wraps
import logging

from flask import current_app, g, request
from jose import ExpiredSignatureError, JWTError, jwt
Expand All @@ -14,9 +15,10 @@
from api.models import Role, User
from api.utils.helpers import response_builder


# logger = logging.getLogger(__name__)
def verify_token(authorization_token, public_key, audience=None, issuer=None):
"""Validate token."""
from manage import app
try:
payload = jwt.decode(
authorization_token,
Expand All @@ -37,6 +39,8 @@ def verify_token(authorization_token, public_key, audience=None, issuer=None):
'verify_signature': True,
'verify_exp': True
})
app.logger.warning('Token NOT validated')
app.logger.info('Token SUCCESSFULLY validated')
return payload


Expand Down
9 changes: 9 additions & 0 deletions src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import csv
import os
import sys
import logging

from flask_migrate import Migrate
from flask.cli import FlaskGroup
Expand All @@ -20,6 +21,11 @@
app = create_app()
cli = FlaskGroup(app)

if __name__ != "__main__":
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)


@cli.command()
def drop_database():
Expand Down Expand Up @@ -140,3 +146,6 @@ def tests():

if __name__ == "__main__":
cli()
# gunicorn_logger = logging.getLogger('gunicorn.error')
# app.logger.handlers = gunicorn_logger.handlers
# app.logger.setLevel(gunicorn_logger.level)

0 comments on commit 2b17cce

Please sign in to comment.