hsman/config.py

69 lines
1.7 KiB
Python

import os
import importlib.metadata
base_dir = os.path.dirname(os.path.abspath(__file__))
class BaseConfig(object):
"""Base configuration."""
APP_NAME = "HSMAN"
APP_VERSION = os.getenv('APP_VERSION', "0.0alpha1")
APP_SHA = os.getenv('APP_SHA', "000000")
APP_PREFIX = os.getenv('APP_PREFIX', '')
DEBUG_TB_ENABLED = False
WTF_CSRF_ENABLED = False
# Session
# We store sessions in filesystem, max 100 files, expire in 2 hours
SESSION_TYPE = 'filesystem'
SESSION_FILE_THRESHOLD = 100
PERMANENT_SESSION_LIFETIME = 7200
# All the following vars can be overriden
# in the environment, using `HSMAN_` prefix
SECRET_KEY = "secreto"
ADMIN_GROUPS = "adminGroup"
OIDC_CLIENT_ID = 'client-id'
OIDC_CLIENT_SECRET = 'client-secreto'
OIDC_URL = "https://myidp.example.com/auth"
OIDC_REDIRECT_URI = 'http://localhost:5000/auth'
OIDC_CLOCK_SKEW = 30
# These are required by hsapi, should not be defined here
# HSAPI_SERVER = "https://headscale.example.com"
# HSAPI_API_TOKEN = 'hs-apikey'
@staticmethod
def configure(app):
# Implement this method to do further configuration on your app.
pass
class DevelopmentConfig(BaseConfig):
"""Development configuration."""
DEBUG = True
ENVIRONMENT = "develop"
TEMPLATES_AUTO_RELOAD = True
class TestingConfig(BaseConfig):
"""Testing configuration."""
TESTING = True
PRESERVE_CONTEXT_ON_EXCEPTION = False
ENVIRONMENT = "test"
class ProductionConfig(BaseConfig):
"""Production configuration."""
ENVIRONMENT = "production"
WTF_CSRF_ENABLED = True
config = dict(
development=DevelopmentConfig,
testing=TestingConfig,
production=ProductionConfig)