File size: 1,941 Bytes
6739f59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
from functools import lru_cache

from pydantic import BaseSettings


class Settings(BaseSettings):
    """

    BaseSettings, from Pydantic, validates the data so that when we create an instance of Settings,
    environment and testing will have types of str and bool, respectively.

    Parameters:


    Returns:
    instance of Settings

    """

    VERSION: str = "2.5.0"
    DESCRIPTION: str = "Humanitics Webapp"
    PROJECT_NAME: str = "Humanitics"

    DEBUG: bool = os.getenv("DEBUG", False)

    # auth0
    AUTH0_DOMAIN: str = os.getenv("AUTH0_DOMAIN", "humanitics.eu.auth0.com")
    AUTH0_AUDIENCE: str = os.getenv(
        "AUTH0_AUDIENCE", "https://humanitics.eu.auth0.com"
    )
    AUTH0_CLIENT_ID: str = os.getenv("AUTH0_CLIENT_ID", "")
    AUTH0_CLIENT_SECRET: str = os.getenv("AUTH0_CLIENT_SECRET", "")
    AUTH0_CALLBACK_URL: str = os.getenv(
        "AUTH0_CALLBACK_URL", "http://localhost:8000/callback"
    )
    APP_SECRET_KEY: str = os.getenv("APP_SECRET_KEY", "")

    # flask
    SECRET_KEY: str = os.getenv("SECRET_KEY", "secret")
    SESSION_COOKIE_NAME: str = os.getenv("SESSION_COOKIE_NAME", "humanitics")
    SESSION_COOKIE_SECURE: bool = os.getenv("SESSION_COOKIE_SECURE", False)
    SESSION_COOKIE_HTTPONLY: bool = os.getenv("SESSION_COOKIE_HTTPONLY", True)

    # pages
    LOGIN_URL: str = os.getenv("LOGIN_URL", "/login")
    LOGOUT_URL: str = os.getenv("LOGOUT_URL", "/logout")
    CALLBACK_URL: str = os.getenv("CALLBACK_URL", "/callback")
    REDIRECT_URI: str = os.getenv(
        "REDIRECT_URI", "http://localhost:8000/callback"
    )

    # keys session
    JWT_PAYLOAD: str = os.getenv("JWT_PAYLOAD", "jwt_payload")
    PROFILE_KEY: str = os.getenv("PROFILE_KEY", "profile")

    # Data Folder
    DATA_FOLDER: str = os.getenv("DATA_FOLDER", "data")

    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"


@lru_cache
def get_settings():
    return Settings()