Esempio n. 1
0
class AppConfig(object):
    SQLITE_PATH = path.join(state_basedir, 'users.sqlite3')
    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + SQLITE_PATH
    SQLALCHEMY_MIGRATE_REPO = path.join(state_basedir, 'app.migrate')
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    ADMIN_SECRET = getenv('OPWEN_ADMIN_SECRET')
    SECRET_KEY = getenv('OPWEN_SESSION_KEY')
    SECURITY_USER_IDENTITY_ATTRIBUTES = 'email'
    SECURITY_PASSWORD_HASH = 'bcrypt'
    SECURITY_PASSWORD_SALT = getenv('OPWEN_PASSWORD_SALT')
    SECURITY_REGISTERABLE = True
    SECURITY_CHANGEABLE = True
    SECURITY_TRACKABLE = True
    SECURITY_SEND_PASSWORD_CHANGE_EMAIL = False
    SECURITY_POST_REGISTER_VIEW = 'register_complete'
    SECURITY_POST_LOGIN_VIEW = 'login_complete'
    SECURITY_POST_LOGOUT_VIEW = 'logout_complete'
    SECURITY_SEND_REGISTER_EMAIL = False
    SECURITY_MSG_LOGIN = i8n.LOGIN_REQUIRED, 'error'
    SECURITY_MSG_UNAUTHORIZED = i8n.UNAUTHORIZED, 'error'
    SECURITY_MSG_INVALID_PASSWORD = i8n.INVALID_PASSWORD, 'error'
    SECURITY_MSG_DISABLED_ACCOUNT = i8n.ACCOUNT_SUSPENDED, 'error'
    SECURITY_MSG_PASSWORD_INVALID_LENGTH = i8n.SHORT_PASSWORD, 'error'
    SECURITY_MSG_PASSWORD_IS_THE_SAME = i8n.SAME_PASSWORD, 'error'
    SECURITY_LOGIN_URL = '/user/login'
    SECURITY_LOGOUT_URL = '/user/logout'
    SECURITY_REGISTER_URL = '/user/register'
    SECURITY_CHANGE_URL = '/user/password/change'

    TESTING = getenv('OPWEN_ENABLE_DEBUG', False)

    LOCAL_EMAIL_STORE = path.join(state_basedir, 'emails.sqlite3')

    EMAIL_ADDRESS_DELIMITER = ','
    EMAILS_PER_PAGE = 30

    LOG_FORMAT = '%(asctime)s\t%(levelname)s\t%(message)s'
    LOG_LEVEL = ERROR

    LOCALES_DIRECTORY = path.join(app_basedir, 'translations')
    DEFAULT_LOCALE = Locale.parse('en_ca')
    LOCALES = (
        [DEFAULT_LOCALE] +
        [Locale.parse(code) for code in subdirectories(LOCALES_DIRECTORY)])

    EMAIL_SERVER_READ_API_HOSTNAME = getenv('OPWEN_EMAIL_SERVER_READ_API')
    EMAIL_SERVER_WRITE_API_HOSTNAME = getenv('OPWEN_EMAIL_SERVER_WRITE_API')
    EMAIL_HOST_FORMAT = '{}.lokole.ca'
    STORAGE_CONTAINER = 'compressedpackages'
    STORAGE_ACCOUNT_NAME = getenv('OPWEN_REMOTE_ACCOUNT_NAME')
    STORAGE_ACCOUNT_KEY = getenv('OPWEN_REMOTE_ACCOUNT_KEY')
    CLIENT_NAME = getenv('OPWEN_CLIENT_NAME')
    CLIENT_ID = getenv('OPWEN_CLIENT_ID')
    CLIENT_EMAIL_HOST = EMAIL_HOST_FORMAT.format(CLIENT_NAME)
Esempio n. 2
0
class AppConfig(OpwenConfig):
    SQLITE_PATH = path.join(state_basedir, 'app.sqlite3')
    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + SQLITE_PATH
    SQLALCHEMY_MIGRATE_REPO = path.join(state_basedir, 'app.migrate')
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    PRESHARED_SECRET = getenv('OPWEN_PRESHARED_SECRET')
    SECRET_KEY = getenv('OPWEN_SECRET_KEY')
    SECURITY_USER_IDENTITY_ATTRIBUTES = 'email'
    SECURITY_PASSWORD_HASH = 'bcrypt'
    SECURITY_PASSWORD_SALT = getenv('OPWEN_PASSWORD_SALT')
    SECURITY_REGISTERABLE = True
    SECURITY_POST_REGISTER_VIEW = 'register_complete'
    SECURITY_POST_LOGIN_VIEW = 'login_complete'
    SECURITY_POST_LOGOUT_VIEW = 'logout_complete'
    SECURITY_SEND_REGISTER_EMAIL = False
    SECURITY_LOGIN_USER_TEMPLATE = 'login.html'
    SECURITY_REGISTER_USER_TEMPLATE = 'register.html'
    SECURITY_MSG_LOGIN = i8n.LOGIN_REQUIRED, 'error'
    SECURITY_MSG_UNAUTHORIZED = i8n.UNAUTHORIZED, 'error'
    SECURITY_MSG_INVALID_PASSWORD = i8n.INVALID_PASSWORD, 'error'
    SECURITY_MSG_DISABLED_ACCOUNT = i8n.ACCOUNT_SUSPENDED, 'error'
    SECURITY_MSG_PASSWORD_INVALID_LENGTH = i8n.SHORT_PASSWORD, 'error'

    TESTING = getenv('OPWEN_ENABLE_DEBUG', False)

    LOCAL_EMAIL_STORE = path.join(state_basedir, 'email.store')

    EMAIL_ADDRESS_DELIMITER = ','
    EMAILS_PER_PAGE = 30

    LOG_FORMAT = '%(asctime)s\t%(levelname)s\t%(message)s'
    LOG_LEVEL = ERROR

    LOCALES_DIRECTORY = path.join(app_basedir, 'translations')
    DEFAULT_LOCALE = Locale.parse('en_ca')
    LOCALES = [DEFAULT_LOCALE] + [
        Locale.parse(code) for code in subdirectories(LOCALES_DIRECTORY)
    ]

    CLIENT_NAME = getenv('OPWEN_CLIENT_NAME')
    CLIENT_EMAIL_HOST = OpwenConfig.EMAIL_HOST_FORMAT.format(CLIENT_NAME)
    STORAGE_UPLOAD_PATH = OpwenConfig.STORAGE_UPLOAD_FORMAT.format(CLIENT_NAME)
    STORAGE_DOWNLOAD_PATH = OpwenConfig.STORAGE_DOWNLOAD_FORMAT.format(
        CLIENT_NAME)
Esempio n. 3
0
 def test_handles_missing_directory(self):
     self.assertEqual(len(list(subdirectories('/does-not-exist'))), 0)
Esempio n. 4
0
class AppConfig(object):
    CACHE_TYPE = 'simple'
    STATE_BASEDIR = path.abspath(env('OPWEN_STATE_DIRECTORY', gettempdir()))
    SQLITE_PATH = path.join(STATE_BASEDIR, 'users.sqlite3')
    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + SQLITE_PATH
    SQLALCHEMY_MIGRATE_REPO = path.join(STATE_BASEDIR, 'app.migrate')
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    SECRET_KEY = env('OPWEN_SESSION_KEY', None)

    CELERY_SQLITE_PATH = path.join(STATE_BASEDIR, 'celery.sqlite3')
    CELERY_BROKER_URL = env('CELERY_BROKER_URL', 'sqlalchemy+sqlite:///' + CELERY_SQLITE_PATH)
    CELERY_BEAT_SCHEDULE_FILENAME = path.join(STATE_BASEDIR, 'celery.cron')

    SECURITY_USER_IDENTITY_ATTRIBUTES = 'email'
    SECURITY_PASSWORD_HASH = 'bcrypt'  # nosec
    SECURITY_PASSWORD_SINGLE_HASH = True
    SECURITY_REGISTERABLE = env.bool('OPWEN_CAN_REGISTER_USER', True)
    SECURITY_CHANGEABLE = env.bool('OPWEN_CAN_CHANGE_PASSWORD', True)
    SECURITY_TRACKABLE = True
    SECURITY_SEND_PASSWORD_CHANGE_EMAIL = False
    SECURITY_POST_REGISTER_VIEW = 'register_complete'
    SECURITY_POST_LOGIN_VIEW = 'login_complete'
    SECURITY_POST_LOGOUT_VIEW = 'logout_complete'
    SECURITY_SEND_REGISTER_EMAIL = False
    SECURITY_MSG_LOGIN = i8n.LOGIN_REQUIRED, 'error'
    SECURITY_MSG_UNAUTHORIZED = i8n.UNAUTHORIZED, 'error'
    SECURITY_MSG_INVALID_PASSWORD = i8n.INVALID_PASSWORD, 'error'
    SECURITY_MSG_DISABLED_ACCOUNT = i8n.ACCOUNT_SUSPENDED, 'error'
    SECURITY_MSG_PASSWORD_INVALID_LENGTH = i8n.SHORT_PASSWORD, 'error'
    SECURITY_MSG_PASSWORD_IS_THE_SAME = i8n.SAME_PASSWORD, 'error'
    SECURITY_LOGIN_URL = '/user/login'
    SECURITY_LOGOUT_URL = '/user/logout'
    SECURITY_REGISTER_URL = '/user/register'
    SECURITY_CHANGE_URL = '/user/password/change'

    TESTING = env.bool('OPWEN_ENABLE_DEBUG', False)

    MODEM_CONFIG_DIR = path.join(STATE_BASEDIR, 'usb_modeswitch')
    SIM_CONFIG_DIR = path.join(STATE_BASEDIR, 'wvdial')
    LOCAL_EMAIL_STORE = path.join(STATE_BASEDIR, 'emails.sqlite3')
    SIM_TYPE = env('OPWEN_SIM_TYPE', None)
    RESTART_PATHS = env.dict('OPWEN_RESTART_PATH', {})
    MAX_UPLOAD_SIZE_MB = env.int('OPWEN_MAX_UPLOAD_SIZE_MB', 0)

    SYNC_SCHEDULE = env('OPWEN_SYNC_SCHEDULE', '').strip()

    EMAIL_ADDRESS_DELIMITER = ','
    EMAILS_PER_PAGE = env.int('OPWEN_EMAILS_PER_PAGE', 10)

    LOCALES_DIRECTORY = path.join(app_basedir, 'translations')
    DEFAULT_LOCALE = Locale.parse('en_ca')
    LOCALES = [DEFAULT_LOCALE] + [Locale.parse(code) for code in subdirectories(LOCALES_DIRECTORY)]

    EMAIL_SEARCHABLE = env.bool('OPWEN_CAN_SEARCH_EMAIL', True)
    COMPRESSION = env('OPWEN_COMPRESSION', 'zstd')
    EMAIL_SERVER_ENDPOINT = env('OPWEN_EMAIL_SERVER_ENDPOINT', None)
    EMAIL_SERVER_HOSTNAME = env('OPWEN_EMAIL_SERVER_HOSTNAME', None)
    EMAIL_HOST_FORMAT = '{}.' + root_domain
    STORAGE_PROVIDER = env('LOKOLE_STORAGE_PROVIDER', 'AZURE_BLOBS')
    STORAGE_CONTAINER = env('OPWEN_REMOTE_RESOURCE_CONTAINER', None)
    STORAGE_ACCOUNT_NAME = env('OPWEN_REMOTE_ACCOUNT_NAME', None)
    STORAGE_ACCOUNT_KEY = env('OPWEN_REMOTE_ACCOUNT_KEY', None)
    STORAGE_ACCOUNT_HOST = env('OPWEN_REMOTE_ACCOUNT_HOST', None)
    STORAGE_ACCOUNT_SECURE = env.bool('OPWEN_REMOTE_ACCOUNT_SECURE', True)
    CLIENT_NAME = env('OPWEN_CLIENT_NAME', None)
    CLIENT_ID = env('OPWEN_CLIENT_ID', None)
    CLIENT_EMAIL_HOST = EMAIL_HOST_FORMAT.format(CLIENT_NAME)
    NEWS_INBOX = 'news@{}'.format(CLIENT_EMAIL_HOST)
    ADMIN_INBOX = 'admin@{}'.format(CLIENT_EMAIL_HOST)
    NEWS_SENDERS = set(env.list('OPWEN_NEWS_SENDERS', []))
    FORBIDDEN_ACCOUNTS = [NEWS_INBOX, ADMIN_INBOX]

    IOC = env('LOKOLE_IOC', 'opwen_email_client.webapp.ioc.Ioc')

    APP_ROOT = env('OPWEN_APP_ROOT', '').rstrip('/')
    SECURITY_URL_PREFIX = APP_ROOT or None
Esempio n. 5
0
 def test_handles_missing_directory(self):
     self.assertEqual(len(list(subdirectories('/does-not-exist'))), 0)