From e06a9fdf340b8e73cdea402877f4db605f3e0ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 15 Mar 2016 10:58:47 +0100 Subject: [PATCH] Strip trailing slash from BLENDER_ID_ENDPOINT and removed SystemUtility The xxxUtility classes are silly, they should be removed or replaced by Python modules. --- pillar/application/utils/authentication.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pillar/application/utils/authentication.py b/pillar/application/utils/authentication.py index b676e7c8..5d96d012 100644 --- a/pillar/application/utils/authentication.py +++ b/pillar/application/utils/authentication.py @@ -1,4 +1,3 @@ -import os import logging import requests @@ -14,16 +13,11 @@ from application import app log = logging.getLogger(__name__) -class SystemUtility(): - def __new__(cls, *args, **kwargs): - raise TypeError("Base class may not be instantiated") - - @staticmethod - def blender_id_endpoint(): - """Gets the endpoint for the authentication API. If the env variable - is defined, it's possible to override the (default) production address. - """ - return app.config['BLENDER_ID_ENDPOINT'] +def blender_id_endpoint(): + """Gets the endpoint for the authentication API. If the env variable + is defined, it's possible to override the (default) production address. + """ + return app.config['BLENDER_ID_ENDPOINT'].rstrip('/') def validate(token): @@ -39,7 +33,7 @@ def validate(token): payload = dict( token=token) try: - url = "{0}/u/validate_token".format(SystemUtility.blender_id_endpoint()) + url = "{0}/u/validate_token".format(blender_id_endpoint()) log.debug('POSTing to %r', url) r = requests.post(url, data=payload) except requests.exceptions.ConnectionError as e: