Skip to content

Commit e4520ec

Browse files
committed
Removed authorization requirement
1 parent d148069 commit e4520ec

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

config/urls.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from config.views import robots_txt
1717
from seed.api.base.urls import urlpatterns as api
1818
from seed.landing.views import CustomLoginView, password_reset_complete, password_reset_confirm, password_reset_done
19-
from seed.views.main import angular_js_tests, health_check, noauth_settings, version
19+
from seed.views.main import angular_js_tests, config, health_check, version
2020

2121
schema_view = get_schema_view(
2222
openapi.Info(
@@ -52,9 +52,10 @@ def trigger_error(request):
5252
# root configuration items
5353
re_path(r"^i18n/", include("django.conf.urls.i18n")),
5454
re_path(r"^robots\.txt", robots_txt, name="robots_txt"),
55-
# API
55+
# API (explicit no-auth)
56+
re_path(r"^api/config/$", config, name="config"),
5657
re_path(r"^api/health_check/$", health_check, name="health_check"),
57-
re_path(r"^api/noauth_settings/$", noauth_settings, name="noauth_settings"),
58+
# API
5859
re_path(r"^api/swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
5960
re_path(r"^api/token/$", TokenObtainPairView.as_view(), name="token_obtain_pair"),
6061
re_path(r"^api/token/refresh/$", TokenRefreshView.as_view(), name="token_refresh"),

seed/landing/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from django.utils import timezone
1616
from django.utils.translation import gettext_lazy as _
1717
from rest_framework import exceptions
18+
from rest_framework_simplejwt.exceptions import TokenError
1819
from rest_framework_simplejwt.tokens import AccessToken
1920

2021
from seed.lib.superperms.orgs.models import Organization
@@ -102,6 +103,8 @@ def process_header_request(cls, request):
102103
raise exceptions.AuthenticationFailed("Only Basic HTTP_AUTHORIZATION or BEARER Tokens are supported")
103104
except ValueError:
104105
raise exceptions.AuthenticationFailed("Invalid HTTP_AUTHORIZATION Header")
106+
except TokenError:
107+
raise exceptions.AuthenticationFailed("Invalid Bearer Token")
105108
except SEEDUser.DoesNotExist:
106109
raise exceptions.AuthenticationFailed("Invalid API key or Bearer Token")
107110

seed/views/main.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from django.db import connection
1515
from django.http import JsonResponse
1616
from django.shortcuts import redirect, render
17+
from django.views.decorators.http import require_GET
1718
from rest_framework import status
1819
from rest_framework.decorators import api_view
1920

@@ -157,17 +158,16 @@ def health_check(request):
157158
)
158159

159160

160-
@api_endpoint
161161
@ajax_request
162-
@api_view(["GET"])
163-
def noauth_settings(request):
162+
@require_GET
163+
def config(request):
164164
"""
165-
Returns django settings needed to render no-auth pages
165+
Returns readonly django settings
166166
"""
167-
# include sign-up page?
168-
enable_sign_up = settings.INCLUDE_ACCT_REG
169167

170-
return JsonResponse({"include_signup": enable_sign_up})
168+
return {
169+
"allow_signup": settings.INCLUDE_ACCT_REG,
170+
}
171171

172172

173173
@api_endpoint

0 commit comments

Comments
 (0)