From 81e32cbb1b9ae40283bcbaef606ef9e09cb71ae6 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Tue, 8 May 2018 11:30:50 +0100 Subject: Move bot API key to a constant --- pysite/decorators.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pysite/decorators.py') diff --git a/pysite/decorators.py b/pysite/decorators.py index 0c31fe6e..befc0869 100644 --- a/pysite/decorators.py +++ b/pysite/decorators.py @@ -1,4 +1,3 @@ -import os from functools import wraps from json import JSONDecodeError @@ -7,7 +6,7 @@ from schema import Schema, SchemaError from werkzeug.exceptions import Forbidden from pysite.base_route import APIView, BaseView -from pysite.constants import CSRF, DEBUG_MODE, ErrorCodes, ValidationTypes +from pysite.constants import CSRF, DEBUG_MODE, ErrorCodes, ValidationTypes, BOT_API_KEY def csrf(f): @@ -58,7 +57,7 @@ def api_key(f): @wraps(f) def inner_decorator(self: APIView, *args, **kwargs): - if not request.headers.get("X-API-Key") == os.environ.get("BOT_API_KEY"): + if not request.headers.get("X-API-Key") == BOT_API_KEY: return self.error(ErrorCodes.invalid_api_key) return f(self, *args, **kwargs) -- cgit v1.2.3