nftables-http-api/nftables_api/config.py
Georg Pfuetzenreuter 75c2411dd2
Implement authorization
Read a configuration file mapping bcrypt hashed tokens to authorized
paths and methods to decide whether a request should be pursued.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-09-28 16:42:46 +02:00

15 lines
323 B
Python

from yaml import safe_load
from os import getenv
configpath = getenv('NFT-API-CONFIG')
if not configpath:
raise RuntimeError('NFT-API-CONFIG is not set')
with open(configpath) as fh:
configdata = safe_load(fh)
config = configdata.get('nft-api', {})
if not config:
raise RuntimeError('Invalid configuration data')