|
10 | 10 | https://docs.djangoproject.com/en/3.0/ref/settings/ |
11 | 11 | """ |
12 | 12 | import os |
13 | | -from importlib import import_module |
14 | 13 | import environ as environ # type: ignore |
15 | 14 |
|
| 15 | +from importlib import import_module |
| 16 | + |
| 17 | + |
16 | 18 | # Initialise environment variables |
17 | 19 | env = environ.Env() |
18 | 20 | environ.Env.read_env() |
|
27 | 29 | REST_FRAMEWORK = { |
28 | 30 | 'DEFAULT_PARSER_CLASSES': [ |
29 | 31 | 'rest_framework.parsers.JSONParser', |
30 | | - ] |
| 32 | + ], |
| 33 | + 'DEFAULT_AUTHENTICATION_CLASSES': ( |
| 34 | + #'rest_framework_simplejwt.authentication.JWTAuthentication', |
| 35 | + 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', |
| 36 | + ), |
| 37 | + 'DEFAULT_PERMISSION_CLASSES': ( |
| 38 | + 'rest_framework.permissions.IsAuthenticatedOrReadOnly', |
| 39 | + ) |
31 | 40 | } |
32 | 41 |
|
| 42 | +AUTHENTICATION_BACKENDS = [ |
| 43 | + 'oauth2_provider.backends.OAuth2Backend', |
| 44 | + # Uncomment following if you want to access the admin |
| 45 | + 'django.contrib.auth.backends.ModelBackend', |
| 46 | +] |
| 47 | + |
| 48 | +OAUTH2_PROVIDER = { |
| 49 | + # this is the list of available scopes |
| 50 | + 'SCOPES': {'read': 'Read scope', 'write': 'Write scope', 'groups': 'Access to your groups'} |
| 51 | +} |
| 52 | + |
| 53 | +# Cors stuff (must go before installed apps) |
| 54 | +CORS_ALLOWED_ORIGINS = [ |
| 55 | + 'http://localhost', |
| 56 | + 'http://localhost:3000', |
| 57 | + ] |
| 58 | + |
33 | 59 | # Application definition |
34 | 60 | INSTALLED_BASE_APPS = [ |
35 | 61 | 'django.contrib.admin', |
|
38 | 64 | 'django.contrib.sessions', |
39 | 65 | 'django.contrib.messages', |
40 | 66 | 'django.contrib.staticfiles', |
| 67 | + 'corsheaders', |
41 | 68 | 'rest_framework', |
| 69 | + 'rest_framework_simplejwt', |
| 70 | + 'django_filters', |
42 | 71 | 'dispatcher.apps.DispatcherConfig', |
43 | 72 | 'django_extensions', |
| 73 | + 'users', |
| 74 | + 'oauth2_provider', |
| 75 | + #'gennifer', # Need to make into CHP app |
44 | 76 | ] |
45 | 77 |
|
46 | 78 | INSTALLED_CHP_APPS = [ |
47 | 79 | 'gene_specificity', |
| 80 | + 'gennifer', |
48 | 81 | ] |
49 | 82 |
|
50 | 83 | # CHP Versions |
|
54 | 87 | INSTALLED_APPS = INSTALLED_BASE_APPS + INSTALLED_CHP_APPS |
55 | 88 |
|
56 | 89 | MIDDLEWARE = [ |
| 90 | + 'corsheaders.middleware.CorsMiddleware', |
57 | 91 | 'django.middleware.security.SecurityMiddleware', |
58 | 92 | 'django.contrib.sessions.middleware.SessionMiddleware', |
59 | 93 | 'django.middleware.common.CommonMiddleware', |
60 | 94 | 'django.middleware.csrf.CsrfViewMiddleware', |
61 | 95 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
62 | 96 | 'django.contrib.messages.middleware.MessageMiddleware', |
63 | 97 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 98 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 99 | + 'oauth2_provider.middleware.OAuth2TokenMiddleware', |
64 | 100 | ] |
65 | 101 |
|
66 | 102 | ROOT_URLCONF = 'chp_api.urls' |
|
116 | 152 | }, |
117 | 153 | ] |
118 | 154 |
|
| 155 | +# Authorization |
| 156 | +AUTH_USER_MODEL='users.User' |
| 157 | +LOGIN_URL='/admin/login/' |
| 158 | + |
119 | 159 | # Internationalization |
120 | 160 | # https://docs.djangoproject.com/en/3.0/topics/i18n/ |
121 | 161 | LANGUAGE_CODE = 'en-us' |
|
193 | 233 | if not DJANGO_SUPERUSER_PASSWORD: |
194 | 234 | with open(env("DJANGO_SUPERUSER_PASSWORD_FILE"), 'r') as dsp_file: |
195 | 235 | os.environ["DJANGO_SUPERUSER_PASSWORD"] = dsp_file.readline().strip() |
| 236 | + |
| 237 | +# Simple JWT Settings |
| 238 | +SIMPLE_JWT = { |
| 239 | + "TOKEN_OBTAIN_SERIALIZER": "chp_api.serializers.ChpTokenObtainPairSerializer", |
| 240 | + } |
| 241 | + |
| 242 | +# Celery Settings |
| 243 | +CELERY_BROKER_URL = os.environ.get("CELERY_BROKER_URL", "redis://localhost:6379") |
| 244 | +CELERY_RESULT_BACKEND = os.environ.get("CELERY_RESULT_BACKEND", "redis://localhost:6379") |
| 245 | + |
| 246 | +# Gennifer settings |
| 247 | +GENNIFER_ALGORITHM_URLS = [ |
| 248 | + "http://pidc:5000", |
| 249 | + "http://grisli:5000", |
| 250 | + "http://genie3:5000", |
| 251 | + "http://grnboost2:5000", |
| 252 | + "http://bkb-grn:5000", |
| 253 | + ] |
0 commit comments