settings_base.py 4.59 KB
Newer Older
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
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import uuid

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = int(os.environ.get("DEBUG", default=0))
DEBUG = True

ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")


# Application definition
INSTALLED_APPS = [
    # django
    'rest_framework',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'django.contrib.sites',

    # visualisation
    'leaflet',

    # authentication
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
Giannis Tsapelas's avatar
Giannis Tsapelas committed
37
    'django_keycloak.apps.KeycloakAppConfig',
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

    # apps
    'aggregator',
    'query_designer',
]


STORAGE_TARGET = 'CYBELE_LXS'
DATABASES = {
    'default': {
        'ENGINE': os.environ.get("SQL_ENGINE"),
        'NAME': os.environ.get("SQL_DATABASE"),
        'USER': os.environ.get("SQL_USER"),
        'PASSWORD': os.environ.get("SQL_PASSWORD"),
        'HOST': os.environ.get("SQL_HOST"),
        'PORT': os.environ.get("SQL_PORT"),
    },
    'CYBELE_LXS': {
        'HOST': os.environ.get("LXS_HOST"),
        'PORT': os.environ.get("LXS_PORT"),
        'USER': os.environ.get("LXS_USER"),
        'PASSWORD': os.environ.get("LXS_PASSWORD"),
        'NAME': os.environ.get("LXS_NAME"),
Giannis Tsapelas's avatar
Giannis Tsapelas committed
61
        'DRIVER': os.environ.get("LXS_DRIVER"),
62
63
64
65
66
67
68
69
70
71
    }
}



AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    "django.contrib.auth.backends.ModelBackend",
    # `allauth` specific authentication methods, such as login by e-mail
    "allauth.account.auth_backends.AuthenticationBackend",
Giannis Tsapelas's avatar
Giannis Tsapelas committed
72
    'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
73
74
75
)

SITE_ID = 1
Giannis Tsapelas's avatar
Giannis Tsapelas committed
76
# LOGIN_REDIRECT_URL = '/queries/'
77
78
79
80
81
82
83
84
85
86
87
88
89

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # removed to allow embedding in the CYBELE Dashboard iframes
    #'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
Giannis Tsapelas's avatar
Giannis Tsapelas committed
90
    'django_keycloak.middleware.BaseKeycloakMiddleware'
91
92
93
94

]

LOGIN_EXEMPT_URLS = (
Giannis Tsapelas's avatar
Giannis Tsapelas committed
95
    # r'^$',
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
	r'^terms/$',
    r'^about$',
    r'^register$',
    r'^accounts/',
)

ROOT_URLCONF = 'cybele_advanced_query_builder.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'templates', 'allauth')]
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django_settings_export.settings_export',
            ],
        },
    },
]

WSGI_APPLICATION = 'cybele_advanced_query_builder.wsgi.application'

PLATFORM_VERSION = '0.1.0'
SETTINGS_EXPORT = [
    'PLATFORM_VERSION',
]

Giannis Tsapelas's avatar
Giannis Tsapelas committed
129
130
KEYCLOAK_OIDC_PROFILE_MODEL = 'django_keycloak.OpenIdConnectProfile'
LOGIN_URL = 'keycloak_login'
Giannis Tsapelas's avatar
Giannis Tsapelas committed
131
KEYCLOAK_PERMISSIONS_METHOD = 'resource'
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

# AUTH_PASSWORD_VALIDATORS = [
#     # {
#     #     'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
#     # },
#     {
#         'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
#     },
#     # {
#     #     'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
#     # },
#     {
#         'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
#     },
# ]

# ACCOUNT_EMAIL_REQUIRED = True
# ACCOUNT_UNIQUE_EMAIL = True
# ACCOUNT_EMAIL_VERIFICATION = 'mandatory'


# Internationalization
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

DATETIME_FORMAT = 'Y-m-d H:i:s'
DATE_FORMAT = 'Y-m%d'

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]