Skip to content

Commit

Permalink
fix: middleware setup / removing old auth code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Oct 16, 2023
1 parent 8ed9d26 commit a7fa8cd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 34 deletions.
3 changes: 3 additions & 0 deletions chord_metadata_service/chord/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
]


# TODO: new base permissions for authz


class ReadOnly(BasePermission):
def has_permission(self, request, view):
return request.method in SAFE_METHODS
Expand Down
14 changes: 4 additions & 10 deletions chord_metadata_service/metadata/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@
'rest_framework',
'adrf',
'drf_spectacular',

# Keep authz middleware last!
'chord_metadata_service.metadata.authz.AuthzMiddleware'
]

MIDDLEWARE = [
Expand All @@ -159,7 +156,7 @@
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'bento_lib.auth.django_remote_user.BentoRemoteUserMiddleware',
'chord_metadata_service.metadata.authz.AuthzMiddleware'
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
Expand Down Expand Up @@ -270,16 +267,14 @@ def get_secret(path):
ELASTICSEARCH = False

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'bento_lib.auth.django_remote_user.BentoRemoteUserAuthentication'
],
'DEFAULT_AUTHENTICATION_CLASSES': [],
'DEFAULT_PARSER_CLASSES': (
# allows serializers to use snake_case field names, but parse incoming data as camelCase
'djangorestframework_camel_case.parser.CamelCaseJSONParser',
'djangorestframework_camel_case.parser.CamelCaseFormParser',
'djangorestframework_camel_case.parser.CamelCaseMultiPartParser',
),
'DEFAULT_PERMISSION_CLASSES': ['chord_metadata_service.chord.permissions.OverrideOrSuperUserOnly'],
'DEFAULT_PERMISSION_CLASSES': [],
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
'JSON_UNDERSCOREIZE': {
Expand All @@ -306,8 +301,7 @@ def get_secret(path):
]


AUTHENTICATION_BACKENDS = ['bento_lib.auth.django_remote_user.BentoRemoteUserBackend'] + (
['django.contrib.auth.backends.ModelBackend'] if DEBUG else [])
AUTHENTICATION_BACKENDS = (['django.contrib.auth.backends.ModelBackend'] if DEBUG else [])

# Models
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
Expand Down
3 changes: 0 additions & 3 deletions chord_metadata_service/restapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from . import auth_schema

__all__ = ['auth_schema']
21 changes: 0 additions & 21 deletions chord_metadata_service/restapi/auth_schema.py

This file was deleted.

0 comments on commit a7fa8cd

Please sign in to comment.