mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03: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
|
||||
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]
|
||||
|
@ -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"]}
|
||||
|
@ -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"}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user