def __init__(self): """General object initializer.""" CONFIG = get_config() self.OIDC_DOMAIN = CONFIG("oidc_domain", namespace="sso-dashboard") self.OIDC_CLIENT_ID = CONFIG("oidc_client_id", namespace="sso-dashboard") self.OIDC_CLIENT_SECRET = CONFIG("oidc_client_secret", namespace="sso-dashboard") self.LOGIN_URL = "https://{DOMAIN}/login?client={CLIENT_ID}".format( DOMAIN=self.OIDC_DOMAIN, CLIENT_ID=self.OIDC_CLIENT_ID)
from dashboard.models.alert import Alert from dashboard.models.alert import FakeAlert from dashboard.models.alert import Rules from dashboard.models.tile import S3Transfer logging.basicConfig(level=logging.DEBUG) with open("dashboard/logging.yml", "r") as log_config: config_yml = log_config.read() config_dict = yaml.safe_load(config_yml) logging.config.dictConfig(config_dict) logger = logging.getLogger("sso-dashboard") app = Flask(__name__) everett_config = get_config() # Enable monitoring endpoint if (everett_config("enable_prometheus_monitoring", namespace="sso-dashboard", default="False") == "True"): os.environ["prometheus_multiproc_dir"] = "/tmp" registry = CollectorRegistry() multiprocess.MultiProcessCollector(registry, path="/tmp") metrics = PrometheusMetrics(app) metrics.start_http_server( int( everett_config("prometheus_monitoring_port", namespace="sso-dashboard", default="9000"))) talisman = Talisman(app,
"""Configuration loader for different environments.""" import base64 from dashboard import get_config CONFIG = get_config() class Config(object): def __init__(self, app): self.app = app self.environment = CONFIG("environment", default="development") self.settings = self._init_env() def _init_env(self): return DefaultConfig() class DefaultConfig(object): """Defaults for the configuration objects.""" DEBUG = bool(CONFIG("debug", namespace="sso-dashboard", default="True")) TESTING = bool(CONFIG("testing", namespace="sso-dashboard", default="False")) CSRF_ENABLED = bool(CONFIG("csrf_enabled", default="True")) PERMANENT_SESSION = bool( CONFIG("permanent_session", namespace="sso-dashboard", default="True") ) PERMANENT_SESSION_LIFETIME = int( CONFIG("permanent_session_lifetime", namespace="sso-dashboard", default="86400") )