Implemented web interface for API key management, close GH-24

This commit is contained in:
krateng 2021-12-25 03:30:39 +01:00
parent 115be57651
commit 6aee8c7a48
3 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from ..database import *
from ..globalconf import malojaconfig
from ..globalconf import malojaconfig, apikeystore
from ..__pkginfo__ import version
from ..malojauri import uri_to_internal
from .. import utilities
@ -331,5 +331,9 @@ def newrule(**keys):
@api.post("settings")
@authenticated_api
def set_settings(**keys):
from .. import globalconf
globalconf.malojaconfig.update(keys)
malojaconfig.update(keys)
@api.post("apikeys")
@authenticated_api
def set_settings(**keys):
apikeystore.update(keys)

View File

@ -313,7 +313,7 @@ config(
### symmetric keys are fine for now since we hopefully use HTTPS
apikeystore = KeyStore(file=data_dir['clients']("apikeys.yml"),save_endpoint="/apis/mlj_1/api_keys")
apikeystore = KeyStore(file=data_dir['clients']("apikeys.yml"),save_endpoint="/apis/mlj_1/apikeys")
oldfile = pthj(dir_settings['config'],"clients","authenticated_machines.tsv")
if os.path.exists(oldfile):

View File

@ -4,5 +4,7 @@
{% block maincontent %}
Here you can add and remove API keys used by your scrobblers. It is recommended to use
a different key for each scrobbler.<br/><br/>
{{ apikeys.html() }}
{% endblock %}