mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Removed old API key functions
This commit is contained in:
parent
34db81ccef
commit
2720dc1be5
@ -10,7 +10,6 @@ apikeystore = KeyStore(file=data_dir['clients']("apikeys.yml"),save_endpoint="/a
|
|||||||
from .. import upgrade
|
from .. import upgrade
|
||||||
upgrade.upgrade_apikeys()
|
upgrade.upgrade_apikeys()
|
||||||
|
|
||||||
log("Authenticated Machines: " + ", ".join([k for k in apikeystore]),module='apis')
|
|
||||||
|
|
||||||
# skip regular authentication if api key is present in request
|
# skip regular authentication if api key is present in request
|
||||||
# an api key now ONLY permits scrobbling tracks, no other admin tasks
|
# 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}
|
return {'client':client}
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def checkAPIkey(key):
|
|
||||||
return apikeystore.check_key(key)
|
|
||||||
def allAPIkeys():
|
|
||||||
return [apikeystore[k] for k in apikeystore]
|
|
||||||
|
@ -76,7 +76,7 @@ class Listenbrainz(APIHandler):
|
|||||||
token = self.get_token_from_request_keys(keys)
|
token = self.get_token_from_request_keys(keys)
|
||||||
except:
|
except:
|
||||||
raise BadAuthException()
|
raise BadAuthException()
|
||||||
if not checkAPIkey(token):
|
if not apikeystore.check_key(token):
|
||||||
raise InvalidAuthException()
|
raise InvalidAuthException()
|
||||||
else:
|
else:
|
||||||
return 200,{"code":200,"message":"Token valid.","valid":True,"user_name":malojaconfig["NAME"]}
|
return 200,{"code":200,"message":"Token valid.","valid":True,"user_name":malojaconfig["NAME"]}
|
||||||
|
@ -18,8 +18,7 @@ from ..globalconf import malojaconfig, data_dir
|
|||||||
from ..__pkginfo__ import VERSION
|
from ..__pkginfo__ import VERSION
|
||||||
from ..malojauri import uri_to_internal, compose_querystring, internal_to_uri
|
from ..malojauri import uri_to_internal, compose_querystring, internal_to_uri
|
||||||
from .. import images
|
from .. import images
|
||||||
from ._apikeys import api_key_correct, checkAPIkey
|
from ._apikeys import apikeystore, api_key_correct
|
||||||
from . import apikeystore
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ def test_server(key=None):
|
|||||||
:param string key: An API key to be tested. Optional.
|
:param string key: An API key to be tested. Optional.
|
||||||
"""
|
"""
|
||||||
response.set_header("Access-Control-Allow-Origin","*")
|
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
|
response.status = 403
|
||||||
return {"error":"Wrong API key"}
|
return {"error":"Wrong API key"}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user