Register a before_request event for all blueprints, that defines the authentication requirement.

There are three authentication methods:
 - requires_no_auth - public endpoint that does not require an Authorisation header
 - requires_auth - public endpoints that need an API key in the Authorisation header
 - requires_admin_auth - private endpoint that requires an Authorisation header which contains the API key for the defined as the client admin user
This commit is contained in:
Rebecca Law
2017-03-16 18:15:49 +00:00
parent f880604c85
commit 78242812ef
19 changed files with 634 additions and 544 deletions

View File

@@ -41,8 +41,7 @@ from app.dao import notifications_dao
from app.dao.provider_statistics_dao import get_fragment_count
from app.dao.users_dao import get_user_by_id
from app.errors import (
InvalidRequest,
register_errors)
InvalidRequest, register_errors)
from app.service import statistics
from app.service.utils import get_whitelist_objects
from app.schemas import (
@@ -57,11 +56,8 @@ from app.schemas import (
from app.utils import pagination_links, get_london_midnight_in_utc
from flask import Blueprint
from app.authentication.auth import requires_admin_auth
service_blueprint = Blueprint('service', __name__)
service_blueprint.before_request(requires_admin_auth)
register_errors(service_blueprint)