From 2720dc1be579a06052c896957ee6f434366d2a13 Mon Sep 17 00:00:00 2001 From: krateng Date: Wed, 6 Apr 2022 22:46:43 +0200 Subject: [PATCH] Removed old API key functions --- maloja/apis/_apikeys.py | 7 ------- maloja/apis/listenbrainz.py | 2 +- maloja/apis/native_v1.py | 5 ++--- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/maloja/apis/_apikeys.py b/maloja/apis/_apikeys.py index 02c9e09..3cd42ca 100644 --- a/maloja/apis/_apikeys.py +++ b/maloja/apis/_apikeys.py @@ -10,7 +10,6 @@ apikeystore = KeyStore(file=data_dir['clients']("apikeys.yml"),save_endpoint="/a from .. import upgrade upgrade.upgrade_apikeys() -log("Authenticated Machines: " + ", ".join([k for k in apikeystore]),module='apis') # skip regular authentication if api key is present in request # an api key now ONLY permits scrobbling tracks, no other admin tasks @@ -26,9 +25,3 @@ def api_key_correct(request,args,kwargs): return {'client':client} else: return False - - -def checkAPIkey(key): - return apikeystore.check_key(key) -def allAPIkeys(): - return [apikeystore[k] for k in apikeystore] diff --git a/maloja/apis/listenbrainz.py b/maloja/apis/listenbrainz.py index 6896b6a..457573f 100644 --- a/maloja/apis/listenbrainz.py +++ b/maloja/apis/listenbrainz.py @@ -76,7 +76,7 @@ class Listenbrainz(APIHandler): token = self.get_token_from_request_keys(keys) except: raise BadAuthException() - if not checkAPIkey(token): + if not apikeystore.check_key(token): raise InvalidAuthException() else: return 200,{"code":200,"message":"Token valid.","valid":True,"user_name":malojaconfig["NAME"]} diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index 4e930c4..3d7a924 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -18,8 +18,7 @@ from ..globalconf import malojaconfig, data_dir from ..__pkginfo__ import VERSION from ..malojauri import uri_to_internal, compose_querystring, internal_to_uri from .. import images -from ._apikeys import api_key_correct, checkAPIkey -from . import apikeystore +from ._apikeys import apikeystore, api_key_correct @@ -48,7 +47,7 @@ def test_server(key=None): :param string key: An API key to be tested. Optional. """ response.set_header("Access-Control-Allow-Origin","*") - if key is not None and not (checkAPIkey(key)): + if key is not None and not apikeystore.check_key(key): response.status = 403 return {"error":"Wrong API key"}