aboutsummaryrefslogtreecommitdiffstats
path: root/src/account/views.py
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2020-06-23 20:58:14 +0000
committerGerrit Code Review <gerrit@opnfv.org>2020-06-23 20:58:14 +0000
commit6a41bf4f6f0b84e84293b7f2649ba60a9c78818f (patch)
treea8169386aca6e64ceb4e0f13895618be55b146e8 /src/account/views.py
parent3bd27e99960c16c0a9bcab1533b1e6f15b0c9d9e (diff)
parent596664b37c17b31f2b5faa0d5144e4317179e0ba (diff)
Merge "Enable OpenID"
Diffstat (limited to 'src/account/views.py')
-rw-r--r--src/account/views.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/account/views.py b/src/account/views.py
index 1cb2275..912a432 100644
--- a/src/account/views.py
+++ b/src/account/views.py
@@ -28,6 +28,7 @@ from django.views.generic import RedirectView, TemplateView, UpdateView
from django.shortcuts import render
from jira import JIRA
from rest_framework.authtoken.models import Token
+from mozilla_django_oidc.auth import OIDCAuthenticationBackend
from account.forms import AccountSettingsForm
@@ -58,6 +59,20 @@ class AccountSettingsView(UpdateView):
return context
+class MyOIDCAB(OIDCAuthenticationBackend):
+ def filter_users_by_claims(self, claims):
+ email = claims.get(email=email)
+ if not email:
+ return self.UserModel.objects.none()
+
+ try:
+ profile = Profile.objects.get(email=email)
+ return profile.user
+
+ except Profile.DoesNotExist:
+ return self.UserModel.objects.none()
+
+
class JiraLoginView(RedirectView):
def get_redirect_url(self, *args, **kwargs):
consumer = oauth.Consumer(settings.OAUTH_CONSUMER_KEY, settings.OAUTH_CONSUMER_SECRET)