Tweak the config

This commit is contained in:
Thomas Sileo 2018-05-30 23:47:01 +02:00
parent 0932b98a44
commit fc1bd190ef
2 changed files with 14 additions and 9 deletions

10
app.py
View file

@ -51,6 +51,8 @@ from config import PASS
from config import HEADERS from config import HEADERS
from config import VERSION from config import VERSION
from config import DEBUG_MODE from config import DEBUG_MODE
from config import JWT
from config import ADMIN_API_KEY
from config import _drop_db from config import _drop_db
from config import custom_cache_purge_hook from config import custom_cache_purge_hook
from utils.httpsig import HTTPSigAuth, verify_request from utils.httpsig import HTTPSigAuth, verify_request
@ -79,14 +81,6 @@ root_logger = logging.getLogger()
root_logger.handlers = gunicorn_logger.handlers root_logger.handlers = gunicorn_logger.handlers
root_logger.setLevel(gunicorn_logger.level) root_logger.setLevel(gunicorn_logger.level)
JWT_SECRET = get_secret_key('jwt')
JWT = JSONWebSignatureSerializer(JWT_SECRET)
def _admin_jwt_token() -> str:
return JWT.dumps({'me': 'ADMIN', 'ts': datetime.now().timestamp()}).decode('utf-8') # type: ignore
ADMIN_API_KEY = get_secret_key('admin_api_key', _admin_jwt_token)
SIG_AUTH = HTTPSigAuth(ID+'#main-key', KEY.privkey) SIG_AUTH = HTTPSigAuth(ID+'#main-key', KEY.privkey)

View file

@ -3,9 +3,10 @@ import os
import yaml import yaml
from pymongo import MongoClient from pymongo import MongoClient
import requests import requests
from itsdangerous import JSONWebSignatureSerializer
from utils import strtobool from utils import strtobool
from utils.key import Key, KEY_DIR from utils.key import Key, KEY_DIR, get_secret_key
from utils.actor_service import ActorService from utils.actor_service import ActorService
from utils.object_service import ObjectService from utils.object_service import ObjectService
@ -73,6 +74,16 @@ def _drop_db():
KEY = Key(USERNAME, DOMAIN, create=True) KEY = Key(USERNAME, DOMAIN, create=True)
JWT_SECRET = get_secret_key('jwt')
JWT = JSONWebSignatureSerializer(JWT_SECRET)
def _admin_jwt_token() -> str:
return JWT.dumps({'me': 'ADMIN', 'ts': datetime.now().timestamp()}).decode('utf-8') # type: ignore
ADMIN_API_KEY = get_secret_key('admin_api_key', _admin_jwt_token)
ME = { ME = {
"@context": [ "@context": [
CTX_AS, CTX_AS,