Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1338 | settings for login redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Aug 5, 2022
1 parent 2c1d27a commit 1cd221a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'core.middlewares.middlewares.TokenAuthMiddleWare',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
Expand Down Expand Up @@ -400,7 +401,7 @@

# keyCloak/OIDC Provider settings
OIDC_RP_CLIENT_ID = os.environ.get('OIDC_RP_CLIENT_ID', 'ocllocal')
OIDC_RP_CLIENT_SECRET = os.environ.get('OIDC_RP_CLIENT_SECRET', 'ZhuQY8Ps6osM3wJagmwItSuQmY2bgX3Q')
OIDC_RP_CLIENT_SECRET = os.environ.get('OIDC_RP_CLIENT_SECRET', 'XnsOiEwp5khw6ZLo9v1bLuXuheOofnz5')
OIDC_SERVER_URL = os.environ.get('OIDC_SERVER_URL', 'http://localhost:8080')
OIDC_SERVER_INTERNAL_URL = os.environ.get('OIDC_SERVER_URL', 'http://host.docker.internal:8080')
OIDC_REALM = os.environ.get('OIDC_REALM', 'ocl')
Expand All @@ -411,8 +412,10 @@
OIDC_OP_JWKS_ENDPOINT = f'{OIDC_SERVER_INTERNAL_URL}/realms/{OIDC_REALM}/protocol/openid-connect/certs'
OIDC_VERIFY_SSL = False
OIDC_VERIFY_JWT = True
OIDC_RP_SCOPES = 'openid profile email roles role_list'
OIDC_RP_SCOPES = 'openid profile email'
OIDC_STORE_ACCESS_TOKEN = True
LOGIN_REDIRECT_URL = '/'
OIDC_CREATE_USER = True
LOGIN_REDIRECT_URL = os.environ.get('LOGIN_REDIRECT_URL', 'http://localhost:4000')
KEYCLOAK_ADMIN = os.environ.get('KEYCLOAK_ADMIN', 'root')
KEYCLOAK_ADMIN_PASSWORD = os.environ.get('KEYCLOAK_ADMIN_PASSWORD', 'Root123')
OIDC_CALLBACK_CLASS = 'core.users.views.OCLOIDCAuthenticationCallbackView'
14 changes: 14 additions & 0 deletions core/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.core.exceptions import ValidationError
from django.http import Http404
from drf_yasg.utils import swagger_auto_schema
from mozilla_django_oidc.views import OIDCAuthenticationCallbackView
from pydash import get
from rest_framework import mixins, status
from rest_framework.authtoken.serializers import AuthTokenSerializer
Expand Down Expand Up @@ -32,6 +33,19 @@
from ..common.services import AuthService


class OCLOIDCAuthenticationCallbackView(OIDCAuthenticationCallbackView):
pass
# def login_success(self):
# print("**QP***", dict(self.request.GET.items()))
# print("**Session***", self.request.session.items())
# auth.login(self.request, self.user)
# expiration_interval = self.get_settings('OIDC_RENEW_ID_TOKEN_EXPIRY_SECONDS', 60 * 15)
# self.request.session['oidc_id_token_expiration'] = time.time() + expiration_interval
#
# return Response(dict(token=self.request.session['oidc_access_token']))
# return super().login_success()


class TokenAuthenticationView(ObtainAuthToken):
"""Implementation of ObtainAuthToken with last_login update"""

Expand Down

0 comments on commit 1cd221a

Please sign in to comment.