VRE Backend API and Scheduler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

93 lines
4.0 KiB

from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from datetime import timedelta
class ApiConfig(AppConfig):
name = 'apps.api'
label = 'api'
verbose_name = _('API')
verbose_name_plural = _('APIs')
if not hasattr(settings, 'SWAGGER_SETTINGS'):
# We only load this setting, if it is not available in the overall settings.py file
settings.SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'JWT': {
'type': 'apiKey',
'description': 'Prefix token with \'JWT \'.<br /><strong>Ex header:</strong> \'Authorization\': \'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjE2MDU2NTg0LCJqdGkiOiIwNGNhZTk0MWEyNWQ0NjU5ODA4NDg2OTU2NGQzZmZlZSIsInVzZXJfaWQiOjN9.IShrsNu0qJWASQ3xSZR7PHTD0zzRgbYG52D5iQjdRLI\'<br />Use the ',
'name': 'Authorization',
'in': 'header'
},
'Hawk': {
'type': 'apiKey',
'description': 'HTTP Holder-Of-Key Authentication Scheme, https://github.com/hapijs/hawk, https://hawkrest.readthedocs.io/en/latest/<br /><strong>Ex header:</strong><br />\'Authorization\': \'Hawk mac="F4+S9cu7yZiZEgdtqzMpOOdudvqcV2V2Yzk2WcphECc=", hash="+7fKUX+djeQolvnLTxr0X47e//UHKbkRlajwMw3tx3w=", id="7FI5JET4", ts="1592905433", nonce="DlV-fL"\'',
'name': 'Authorization',
'in': 'header'
}
}
}
if not hasattr(settings, 'REST_FRAMEWORK'):
# We only load this setting, if it is not available in the overall settings.py file
# To protect all API views with Hawk by default, put this in your settings:
# https://hawkrest.readthedocs.io/en/latest/usage.html#protecting-api-views-with-hawk
settings.REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'mozilla_django_oidc.contrib.drf.OIDCAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework_simplejwt.authentication.JWTAuthentication',
'apps.api.authentication.APIHawk',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'EXCEPTION_HANDLER': 'apps.api.exceptions.json_schema_error_message',
# 'DEFAULT_AUTHENTICATION_CLASSES': (
# 'rest_framework.authentication.TokenAuthentication',
# ),
# 'DEFAULT_PERMISSION_CLASSES': (
# 'rest_framework.permissions.IsAuthenticated', ),
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
# 'DEFAULT_PERMISSION_CLASSES': [
# 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
# ],
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10
}
if not hasattr(settings, 'SIMPLE_JWT'):
settings.SIMPLE_JWT = {
'AUTH_HEADER_TYPES': ('JWT',),
}
if settings.DEBUG:
settings.SIMPLE_JWT['ACCESS_TOKEN_LIFETIME'] = timedelta(hours=12)
if not hasattr(settings, 'HAWK_MESSAGE_EXPIRATION'):
# We only load this setting, if it is not available in the overall settings.py file
settings.HAWK_MESSAGE_EXPIRATION = 60
if not hasattr(settings, 'DJOSER'):
settings.DJOSER = {
# 'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
# 'USERNAME_RESET_CONFIRM_URL': '#/username/reset/confirm/{uid}/{token}',
'ACTIVATION_URL': '#/activate/{uid}/{token}',
'SEND_ACTIVATION_EMAIL': False,
'SEND_CONFIRMATION_EMAIL': True,
'HIDE_USERS': True,
'SERIALIZERS': {},
}
def ready(self):
from . import signals