Skip to content

Commit

Permalink
add branch to circle-ci build
Browse files Browse the repository at this point in the history
configure new branch

deploy current branch

deploy current branch

reconfigure build and deply scripts

remove commented out code

ft remove unused imports

finalize

fix failing tests

fix failing tests

squash commits

make variable global

make variable global

squash commits
  • Loading branch information
mutoromike committed Jun 12, 2019
1 parent e8fadd6 commit 37820b6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ workflows:
filters:
branches:
only:
- ft-add-logger-to-auth-service
- develop
- master
- develop-V2
- master-V2
Expand All @@ -110,7 +110,7 @@ workflows:
filters:
branches:
only:
- ft-add-logger-to-auth-service
- develop
- master
- develop-V2
- master-V2
12 changes: 8 additions & 4 deletions src/api/services/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import base64
from functools import wraps
import logging
import datetime

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

# logger = logging.getLogger(__name__)
access_time = str(datetime.datetime.utcnow().time())

def verify_token(authorization_token, public_key, audience=None, issuer=None):
"""Validate token."""
from manage import app
Expand All @@ -39,8 +40,7 @@ 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')
app.logger.info('Token SUCCESSFULLY validated: The ACCESS time is UTC {}'.format(access_time)) # Noqa E501
return payload


Expand All @@ -49,6 +49,7 @@ def token_required(f):
"""Authenticate that a valid Token is present."""
@wraps(f)
def decorated(*args, **kwargs):
from manage import app
# check that the Authorization header is set
authorization_token = request.headers.get('Authorization')
if not authorization_token:
Expand All @@ -69,8 +70,10 @@ def decorated(*args, **kwargs):
current_app.config['API_ISSUER'])
except ExpiredSignatureError:
expired_response = "The authorization token supplied is expired"
app.logger.warning('Token HAS EXPIRED!')
return response_builder(dict(message=expired_response), 401)
except JWTError:
app.logger.info('Token Authentication FAILED!: The ACCESS time is UTC {}'.format(access_time)) # Noqa E501
return response_builder(dict(message=unauthorized_message), 401)

# confirm that payload and UserInfo has required keys
Expand All @@ -90,6 +93,7 @@ def decorated(*args, **kwargs):
if not g.current_user.society and g.current_user.cohort:
user.society = g.current_user.cohort.society
user.save()
app.logger.info('Token Authentication SUCCESSFUL! The CURRENT USER is {}'.format(user))
return f(*args, **kwargs)
return decorated

Expand Down
3 changes: 0 additions & 3 deletions src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,3 @@ def tests():

if __name__ == "__main__":
cli()
# gunicorn_logger = logging.getLogger('gunicorn.error')
# app.logger.handlers = gunicorn_logger.handlers
# app.logger.setLevel(gunicorn_logger.level)
2 changes: 1 addition & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alembic==0.9.5
amqp==2.4.0
amqp==2.5.0
aniso8601==1.3.0
appnope==0.1.0
astroid==2.0.4
Expand Down

0 comments on commit 37820b6

Please sign in to comment.