<reponame>ramboldio/steuerlotse
import base64
from os import environ


class Config(object):
    DEBUG = False
    TESTING = False
    DEBUG_DATA = False
    USE_MOCK_API = False
    WTF_CSRF_ENABLED = True
    ALLOW_RESEND_FOR_TEST_USER = False
    PROMETHEUS_EXPORTER_ENABLED = False

    LANGUAGES = ['de']
    SEND_FILE_MAX_AGE_DEFAULT = 60
    SESSION_COOKIE_HTTPONLY = True
    SESSION_COOKIE_SAMESITE = 'Lax'
    SESSION_COOKIE_SECURE = True
    PERMANENT_SESSION_LIFETIME = 10800
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    PLAUSIBLE_DOMAIN = None


class ProductionConfig(Config):
    PROMETHEUS_EXPORTER_ENABLED = True
    PLAUSIBLE_DOMAIN = 'steuerlotse-rente.de'

    ERICA_BASE_URL = environ.get('ERICA_BASE_URL')
    RATELIMIT_STORAGE_URL = environ.get('RATELIMIT_STORAGE_URL')
    SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI')

    ENCRYPTION_KEY = environ.get('ENCRYPTION_KEY')
    # avoid decoding errors (must match certain length + must not be None)
    RSA_ENCRYPT_PUBLIC_KEY = base64.b64decode(environ.get('RSA_ENCRYPT_PUBLIC_KEY') + "========") \
        if environ.get('RSA_ENCRYPT_PUBLIC_KEY') else None
    HASH_ALGORITHM = 'bcrypt'
    IDNR_SALT = environ.get('IDNR_SALT')
    SECRET_KEY = environ.get('SECRET_KEY')


class StagingConfig(Config):
    PROMETHEUS_EXPORTER_ENABLED = True
    PLAUSIBLE_DOMAIN = 'www-staging.stl.ds4g.dev'

    ALLOW_RESEND_FOR_TEST_USER = True

    ERICA_BASE_URL = environ.get('ERICA_BASE_URL')
    RATELIMIT_STORAGE_URL = environ.get('RATELIMIT_STORAGE_URL')
    SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI')

    ENCRYPTION_KEY = environ.get('ENCRYPTION_KEY')
    # avoid decoding errors (must match certain length + must not be None)
    RSA_ENCRYPT_PUBLIC_KEY = base64.b64decode(environ.get('RSA_ENCRYPT_PUBLIC_KEY') + "========") \
        if environ.get('RSA_ENCRYPT_PUBLIC_KEY') else None
    HASH_ALGORITHM = 'bcrypt'
    IDNR_SALT = environ.get('IDNR_SALT')
    SECRET_KEY = environ.get('SECRET_KEY')


class DevelopmentConfig(Config):
    DEBUG = True
    DEBUG_DATA = True
    ALLOW_RESEND_FOR_TEST_USER = True

    SESSION_COOKIE_SECURE = False  # Because Safari can not send Secure Cookies via HTTP to localhost

    ERICA_BASE_URL = environ.get('ERICA_BASE_URL') or 'http://127.0.0.1:8000/01'
    RATELIMIT_STORAGE_URL = environ.get('RATELIMIT_STORAGE_URL') or "memory://"
    SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI') or "sqlite:///dev.db"

    ENCRYPTION_KEY = b'<KEY>  # Generate a new random key for production
    # Find the according private key in tests/crypto/test_encryption
    RSA_ENCRYPT_PUBLIC_KEY = b'-----<KEY>'
    HASH_ALGORITHM = 'mock'
    IDNR_SALT = "ZCgldrRxOVUEdNQLwbGDYu"  # Because of padding bits with encoding,last character should always be in [.Oeu]
    SECRET_KEY = 'dev'


class TestingConfig(Config):
    DEBUG = True
    TESTING = True
    DEBUG_DATA = True
    USE_MOCK_API = True
    WTF_CSRF_ENABLED = False
    ALLOW_RESEND_FOR_TEST_USER = True

    ERICA_BASE_URL = 'ERICA'
    RATELIMIT_STORAGE_URL = "memory://"
    SQLALCHEMY_DATABASE_URI = "sqlite:///:memory:"

    ENCRYPTION_KEY = b'<KEY>  # Generate a new random key for production
    RSA_ENCRYPT_PUBLIC_KEY = b'rsa encrypt public key'
    HASH_ALGORITHM = 'mock'
    IDNR_SALT = "ZCgldrRxOVUEdNQLwbGDYu"  # Because of padding bits with encoding,last character should always be in [.Oeu]
    SECRET_KEY = 'dev'

import base64
from os import environ


class Config(object):
    DEBUG = False
    TESTING = False
    DEBUG_DATA = False
    USE_MOCK_API = False
    WTF_CSRF_ENABLED = True
    ALLOW_RESEND_FOR_TEST_USER = False
    PROMETHEUS_EXPORTER_ENABLED = False

    LANGUAGES = ['de']
    SEND_FILE_MAX_AGE_DEFAULT = 60
    SESSION_COOKIE_HTTPONLY = True
    SESSION_COOKIE_SAMESITE = 'Lax'
    SESSION_COOKIE_SECURE = True
    PERMANENT_SESSION_LIFETIME = 10800
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    PLAUSIBLE_DOMAIN = None


class ProductionConfig(Config):
    PROMETHEUS_EXPORTER_ENABLED = True
    PLAUSIBLE_DOMAIN = 'steuerlotse-rente.de'

    ERICA_BASE_URL = environ.get('ERICA_BASE_URL')
    RATELIMIT_STORAGE_URL = environ.get('RATELIMIT_STORAGE_URL')
    SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI')

    ENCRYPTION_KEY = environ.get('ENCRYPTION_KEY')
    # avoid decoding errors (must match certain length + must not be None)
    RSA_ENCRYPT_PUBLIC_KEY = base64.b64decode(environ.get('RSA_ENCRYPT_PUBLIC_KEY') + "========") \
        if environ.get('RSA_ENCRYPT_PUBLIC_KEY') else None
    HASH_ALGORITHM = 'bcrypt'
    IDNR_SALT = environ.get('IDNR_SALT')
    SECRET_KEY = environ.get('SECRET_KEY')


class StagingConfig(Config):
    PROMETHEUS_EXPORTER_ENABLED = True
    PLAUSIBLE_DOMAIN = 'www-staging.stl.ds4g.dev'

    ALLOW_RESEND_FOR_TEST_USER = True

    ERICA_BASE_URL = environ.get('ERICA_BASE_URL')
    RATELIMIT_STORAGE_URL = environ.get('RATELIMIT_STORAGE_URL')
    SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI')

    ENCRYPTION_KEY = environ.get('ENCRYPTION_KEY')
    # avoid decoding errors (must match certain length + must not be None)
    RSA_ENCRYPT_PUBLIC_KEY = base64.b64decode(environ.get('RSA_ENCRYPT_PUBLIC_KEY') + "========") \
        if environ.get('RSA_ENCRYPT_PUBLIC_KEY') else None
    HASH_ALGORITHM = 'bcrypt'
    IDNR_SALT = environ.get('IDNR_SALT')
    SECRET_KEY = environ.get('SECRET_KEY')


class DevelopmentConfig(Config):
    DEBUG = True
    DEBUG_DATA = True
    ALLOW_RESEND_FOR_TEST_USER = True

    SESSION_COOKIE_SECURE = False  # Because Safari can not send Secure Cookies via HTTP to localhost

    ERICA_BASE_URL = environ.get('ERICA_BASE_URL') or 'http://127.0.0.1:8000/01'
    RATELIMIT_STORAGE_URL = environ.get('RATELIMIT_STORAGE_URL') or "memory://"
    SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI') or "sqlite:///dev.db"

    ENCRYPTION_KEY = b'<KEY>  # Generate a new random key for production
    # Find the according private key in tests/crypto/test_encryption
    RSA_ENCRYPT_PUBLIC_KEY = b'-----<KEY>'
    HASH_ALGORITHM = 'mock'
    IDNR_SALT = "ZCgldrRxOVUEdNQLwbGDYu"  # Because of padding bits with encoding,last character should always be in [.Oeu]
    SECRET_KEY = 'dev'


class TestingConfig(Config):
    DEBUG = True
    TESTING = True
    DEBUG_DATA = True
    USE_MOCK_API = True
    WTF_CSRF_ENABLED = False
    ALLOW_RESEND_FOR_TEST_USER = True

    ERICA_BASE_URL = 'ERICA'
    RATELIMIT_STORAGE_URL = "memory://"
    SQLALCHEMY_DATABASE_URI = "sqlite:///:memory:"

    ENCRYPTION_KEY = b'<KEY>  # Generate a new random key for production
    RSA_ENCRYPT_PUBLIC_KEY = b'rsa encrypt public key'
    HASH_ALGORITHM = 'mock'
    IDNR_SALT = "ZCgldrRxOVUEdNQLwbGDYu"  # Because of padding bits with encoding,last character should always be in [.Oeu]
    SECRET_KEY = 'dev'
# avoid decoding errors (must match certain length + must not be None) # avoid decoding errors (must match certain length + must not be None) # Because Safari can not send Secure Cookies via HTTP to localhost # Generate a new random key for production # Find the according private key in tests/crypto/test_encryption # Because of padding bits with encoding,last character should always be in [.Oeu] # Generate a new random key for production # Because of padding bits with encoding,last character should always be in [.Oeu]