aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2021-01-04 21:15:58 +0000
committerGerrit Code Review <gerrit@opnfv.org>2021-01-04 21:15:58 +0000
commitd41310f9c3b62e8ab462fa94f2bf1b6b7d2b5e23 (patch)
treeb14138db73a98a9f618be86d7ce9c5483b1ea798 /src
parent107d8bb663083cd2e5fc09417ccd41560bc272c9 (diff)
parentbf822708949ad2e57b3966ad2bf485588fe4b29d (diff)
Merge "Fix issue where users are redirected to Jira login in LFID mode in certain cases"
Diffstat (limited to 'src')
-rw-r--r--src/account/urls.py13
-rw-r--r--src/account/views.py5
-rw-r--r--src/dashboard/views.py4
-rw-r--r--src/laas_dashboard/settings.py4
4 files changed, 22 insertions, 4 deletions
diff --git a/src/account/urls.py b/src/account/urls.py
index 0c01ee0..97d8c77 100644
--- a/src/account/urls.py
+++ b/src/account/urls.py
@@ -32,6 +32,7 @@ from account.views import (
AccountSettingsView,
JiraAuthenticatedView,
JiraLoginView,
+ OIDCLoginView,
JiraLogoutView,
UserListView,
account_resource_view,
@@ -45,11 +46,21 @@ from account.views import (
configuration_delete_view
)
+from laas_dashboard import settings
+
+
+def get_login_view():
+ if (settings.AUTH_SETTING == 'LFID'):
+ return OIDCLoginView.as_view()
+ else:
+ return JiraLoginView.as_view()
+
+
app_name = "account"
urlpatterns = [
url(r'^settings/', AccountSettingsView.as_view(), name='settings'),
url(r'^authenticated/$', JiraAuthenticatedView.as_view(), name='authenticated'),
- url(r'^login/$', JiraLoginView.as_view(), name='login'),
+ url(r'^login/$', get_login_view(), name='login'),
url(r'^logout/$', JiraLogoutView.as_view(), name='logout'),
url(r'^users/$', UserListView.as_view(), name='users'),
url(r'^my/resources/$', account_resource_view, name="my-resources"),
diff --git a/src/account/views.py b/src/account/views.py
index 08da918..2e1ab94 100644
--- a/src/account/views.py
+++ b/src/account/views.py
@@ -128,6 +128,11 @@ class JiraLoginView(RedirectView):
return url
+class OIDCLoginView(RedirectView):
+ def get_redirect_url(self, *args, **kwargs):
+ return reverse('oidc_authentication_init')
+
+
class JiraLogoutView(LoginRequiredMixin, RedirectView):
def get_redirect_url(self, *args, **kwargs):
logout(self.request)
diff --git a/src/dashboard/views.py b/src/dashboard/views.py
index 7c85250..ff26c64 100644
--- a/src/dashboard/views.py
+++ b/src/dashboard/views.py
@@ -22,7 +22,7 @@ from booking.models import Booking
from resource_inventory.models import Image, ResourceProfile, ResourceQuery
from workflow.workflow_manager import ManagerTracker
-import os
+from laas_dashboard import settings
def lab_list_view(request):
@@ -80,7 +80,7 @@ def landing_view(request):
else:
bookings = None
- LFID = True if os.environ['AUTH_SETTING'] == 'LFID' else False
+ LFID = True if settings.AUTH_SETTING == 'LFID' else False
return render(
request,
'dashboard/landing.html',
diff --git a/src/laas_dashboard/settings.py b/src/laas_dashboard/settings.py
index a32b1c5..8f43a3d 100644
--- a/src/laas_dashboard/settings.py
+++ b/src/laas_dashboard/settings.py
@@ -53,7 +53,9 @@ MIDDLEWARE = [
'account.middleware.TimezoneMiddleware',
]
-if os.environ['AUTH_SETTING'] == 'LFID':
+AUTH_SETTING = os.environ.get('AUTH_SETTING', 'JIRA')
+
+if AUTH_SETTING == 'LFID':
AUTHENTICATION_BACKENDS = ['account.views.MyOIDCAB']
# OpenID Authentications