|
257 | 257 | conn_max_age=600) |
258 | 258 | } |
259 | 259 |
|
| 260 | +# Static files (CSS, JavaScript, Images) |
| 261 | +# https://docs.djangoproject.com/en/2.2/howto/static-files/ |
| 262 | +STATIC_URL = '/assets/' |
| 263 | +STATIC_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..', 'web', 'dist', 'assets')) |
| 264 | +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' |
| 265 | + |
| 266 | +# see: https://django-oauth-toolkit.readthedocs.io/en/latest/oidc.html?highlight=oidc.key#creating-rsa-private-key # noqa |
| 267 | +with open('/var/run/secrets/drycc/passport/oidc-rsa-private-key') as f: |
| 268 | + OIDC_RSA_PRIVATE_KEY = f.read() |
| 269 | +OAUTH2_PROVIDER = { |
| 270 | + "OIDC_ENABLED": True, |
| 271 | + "OIDC_RSA_PRIVATE_KEY": OIDC_RSA_PRIVATE_KEY, |
| 272 | + "OAUTH2_VALIDATOR_CLASS": "api.serializers.CustomOAuth2Validator", |
| 273 | + "PKCE_REQUIRED": False, |
| 274 | + "ALLOWED_REDIRECT_URI_SCHEMES": ["http", "https"], |
| 275 | + "ACCESS_TOKEN_EXPIRE_SECONDS": int(os.environ.get('ACCESS_TOKEN_EXPIRE_SECONDS', 30 * 86400)), # noqa |
| 276 | + "ID_TOKEN_EXPIRE_SECONDS": int(os.environ.get('ID_TOKEN_EXPIRE_SECONDS', 30 * 86400)), # noqa |
| 277 | + "AUTHORIZATION_CODE_EXPIRE_SECONDS": int(os.environ.get('AUTHORIZATION_CODE_EXPIRE_SECONDS', 600)), # noqa |
| 278 | + "CLIENT_SECRET_GENERATOR_LENGTH": int(os.environ.get('CLIENT_SECRET_GENERATOR_LENGTH', 64)), # noqa |
| 279 | + "REFRESH_TOKEN_EXPIRE_SECONDS": int(os.environ.get('REFRESH_TOKEN_EXPIRE_SECONDS', 60 * 86400)), # noqa |
| 280 | + "ROTATE_REFRESH_TOKEN": True, |
| 281 | + "SCOPES": { |
| 282 | + "profile": "Profile", |
| 283 | + "openid": "OpenID Connect scope", |
| 284 | + }, |
| 285 | + "DEFAULT_SCOPES": ['openid', ], |
| 286 | + "DEFAULT_CODE_CHALLENGE_METHOD": 'S256', |
| 287 | +} |
| 288 | +REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = ( |
| 289 | + 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', |
| 290 | + 'rest_framework.authentication.SessionAuthentication', |
| 291 | + 'rest_framework.authentication.BasicAuthentication', |
| 292 | +) |
| 293 | + |
260 | 294 | # LDAP settings taken from environment variables. |
261 | 295 | LDAP_ENDPOINT = os.environ.get('LDAP_ENDPOINT', '') |
262 | 296 | LDAP_BIND_DN = os.environ.get('LDAP_BIND_DN', '') |
|
275 | 309 | # In order to debug LDAP configuration it is possible to enable |
276 | 310 | # verbose logging from auth-ldap plugin: |
277 | 311 | # https://pythonhosted.org/django-auth-ldap/logging.html |
278 | | - |
279 | 312 | if LDAP_ENDPOINT: |
280 | 313 | AUTHENTICATION_BACKENDS = ("django_auth_ldap.backend.LDAPBackend",) + AUTHENTICATION_BACKENDS # noqa |
281 | 314 | AUTH_LDAP_SERVER_URI = LDAP_ENDPOINT |
|
312 | 345 | AUTH_LDAP_FIND_GROUP_PERMS = True |
313 | 346 | AUTH_LDAP_CACHE_GROUPS = False |
314 | 347 |
|
315 | | -# Static files (CSS, JavaScript, Images) |
316 | | -# https://docs.djangoproject.com/en/2.2/howto/static-files/ |
317 | | -STATIC_URL = '/assets/' |
318 | | -STATIC_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..', 'web', 'dist', 'assets')) |
319 | | -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' |
320 | | - |
321 | | -# see: https://django-oauth-toolkit.readthedocs.io/en/latest/oidc.html?highlight=oidc.key#creating-rsa-private-key # noqa |
322 | | -with open('/var/run/secrets/drycc/passport/oidc-rsa-private-key') as f: |
323 | | - OIDC_RSA_PRIVATE_KEY = f.read() |
324 | | -OAUTH2_PROVIDER = { |
325 | | - "OIDC_ENABLED": True, |
326 | | - "OIDC_RSA_PRIVATE_KEY": OIDC_RSA_PRIVATE_KEY, |
327 | | - "OAUTH2_VALIDATOR_CLASS": "api.serializers.CustomOAuth2Validator", |
328 | | - "PKCE_REQUIRED": False, |
329 | | - "ALLOWED_REDIRECT_URI_SCHEMES": ["http", "https"], |
330 | | - "ACCESS_TOKEN_EXPIRE_SECONDS": int(os.environ.get('ACCESS_TOKEN_EXPIRE_SECONDS', 30 * 86400)), # noqa |
331 | | - "ID_TOKEN_EXPIRE_SECONDS": int(os.environ.get('ID_TOKEN_EXPIRE_SECONDS', 30 * 86400)), # noqa |
332 | | - "AUTHORIZATION_CODE_EXPIRE_SECONDS": int(os.environ.get('AUTHORIZATION_CODE_EXPIRE_SECONDS', 600)), # noqa |
333 | | - "CLIENT_SECRET_GENERATOR_LENGTH": int(os.environ.get('CLIENT_SECRET_GENERATOR_LENGTH', 64)), # noqa |
334 | | - "REFRESH_TOKEN_EXPIRE_SECONDS": int(os.environ.get('REFRESH_TOKEN_EXPIRE_SECONDS', 60 * 86400)), # noqa |
335 | | - "ROTATE_REFRESH_TOKEN": True, |
336 | | - "SCOPES": { |
337 | | - "profile": "Profile", |
338 | | - "openid": "OpenID Connect scope", |
339 | | - }, |
340 | | - "DEFAULT_SCOPES": ['openid', ], |
341 | | - "DEFAULT_CODE_CHALLENGE_METHOD": 'S256', |
342 | | -} |
343 | | -REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = ( |
344 | | - 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', |
345 | | - 'rest_framework.authentication.SessionAuthentication', |
346 | | - 'rest_framework.authentication.BasicAuthentication', |
347 | | -) |
348 | | - |
349 | 348 | EMAIL_HOST = os.environ.get('EMAIL_HOST', '') |
350 | 349 | EMAIL_PORT = os.environ.get('EMAIL_PORT', '') |
351 | 350 | DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', '') |
|
0 commit comments