Skip to content

Commit

Permalink
Add feature flag for login/password auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Rusakov committed Jan 6, 2025
1 parent 673face commit fdcb802
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY poetry.lock pyproject.toml /app/geoshop_back/

RUN apt update && apt install -y libgdal-dev libffi-dev gettext && \
pip install poetry && \
poetry install --only=main
poetry install --only=main --no-root

COPY . /app/geoshop_back/

Expand Down
1 change: 1 addition & 0 deletions default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
FEATURE_FLAGS = {
"oidc": os.environ.get("OIDC_ENABLED", "False") == "True",
"registration": os.environ.get("REGISTRATION_ENABLED", "True") == "True",
"local_auth": os.environ.get("LOCAL_AUTH_ENABLED", "True") == "True"
}

AUTHENTICATION_BACKENDS = ("django.contrib.auth.backends.ModelBackend",)
Expand Down
8 changes: 7 additions & 1 deletion urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
path(f'{ROOTURL}extract/orderitem/', views.ExtractOrderItemView.as_view(), name='extract_orderitem'),
re_path(rf'^{ROOTURL}extract/orderitem/(?P<pk>[0-9]+)$',
views.ExtractOrderItemView.as_view(), name='extract_orderitem'),
path(f'{ROOTURL}token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path(f'{ROOTURL}token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path(f'{ROOTURL}token/verify/', TokenVerifyView.as_view(), name='token_verify'),
path(f'{ROOTURL}session-auth/', include('rest_framework.urls', namespace='rest_framework')),
Expand All @@ -92,6 +91,12 @@
path(f'{ROOTURL}health/', include('health_check.urls')),
] + static(settings.STATIC_URL,document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)

# Hiding Name/Password Token obtain link behind feature flags
if settings.FEATURE_FLAGS["local_auth"]:
urlpatterns += [
path(f'{ROOTURL}token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
]

# OIDC links if OIDC is enabled
if settings.FEATURE_FLAGS["oidc"]:
urlpatterns += [
Expand All @@ -107,3 +112,4 @@
urlpatterns += [
path(f'{ROOTURL}auth/register/', views.RegisterView.as_view(), name='auth_register'),
]

0 comments on commit fdcb802

Please sign in to comment.