Merge pull request #753 from alphagov/logging-service-ids

Records the service ID if present in the request
This commit is contained in:
minglis
2016-12-01 11:38:49 +00:00
committed by GitHub
2 changed files with 3 additions and 4 deletions

View File

@@ -1,11 +1,10 @@
from flask import request, _request_ctx_stack, current_app
from flask import request, _request_ctx_stack, current_app, g
from sqlalchemy.exc import DataError
from sqlalchemy.orm.exc import NoResultFound
from notifications_python_client.authentication import decode_jwt_token, get_token_issuer
from notifications_python_client.errors import TokenDecodeError, TokenExpiredError, TokenIssuerError
from app.dao.api_key_dao import get_model_api_keys
from app.dao.services_dao import dao_fetch_service_by_id
@@ -50,6 +49,7 @@ def requires_auth():
raise AuthError("Invalid token: iss not provided", 403)
if client == current_app.config.get('ADMIN_CLIENT_USER_NAME'):
g.service_id = current_app.config.get('ADMIN_CLIENT_USER_NAME')
return handle_admin_key(auth_token, current_app.config.get('ADMIN_CLIENT_SECRET'))
try:
@@ -74,6 +74,7 @@ def requires_auth():
if api_key.expiry_date:
raise AuthError("Invalid token: API key revoked", 403)
g.service_id = api_key.service_id
_request_ctx_stack.top.api_user = api_key
return
else:

View File

@@ -36,8 +36,6 @@ from app.schemas import (
)
from app.service.utils import service_allowed_to_send_to
from app.utils import pagination_links
from app import redis_store
from app.clients import redis
notifications = Blueprint('notifications', __name__)