Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError at /oidc/callback/ #383

Closed
strus38 opened this issue Oct 31, 2020 · 1 comment
Closed

JSONDecodeError at /oidc/callback/ #383

strus38 opened this issue Oct 31, 2020 · 1 comment

Comments

@strus38
Copy link

strus38 commented Oct 31, 2020

Using OIDC keycloak with RS256 and OIDC_OP_JWKS_ENDPOINT: https://keycloak.home.lab/auth/realms/master/protocol/openid-connect/certs

It seems to pass the token verification step, but fails after:
image

Environment:

Request Method: GET
Request URL: http://netbox.home.lab/oidc/callback/?state=N3ih2JMAfaM46vvyVIBZ59k9MsXHdy5B&session_state=7088a530-0120-46e6-83f7-2988c62af8b8&code=216e6a06-51fe-41e9-90ce-a5eccb8b4c32.7088a530-0120-46e6-83f7-2988c62af8b8.0484b399-6e9d-48a0-8e5c-d305ea20485a

Django Version: 3.1
Python Version: 3.7.9
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'mozilla_django_oidc',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'cacheops',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'django_prometheus',
 'mptt',
 'rest_framework',
 'taggit',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'django_rq',
 'drf_yasg']
Installed Middleware:
['debug_toolbar.middleware.DebugToolbarMiddleware',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'utilities.middleware.ExceptionHandlingMiddleware',
 'utilities.middleware.RemoteUserMiddleware',
 'utilities.middleware.LoginRequiredMiddleware',
 'utilities.middleware.APIVersionMiddleware',
 'extras.middleware.ObjectChangeMiddleware',
 'django_prometheus.middleware.PrometheusAfterMiddleware']



Traceback (most recent call last):
  File "/usr/local/lib/python3.7/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)

During handling of the above exception (0), another exception occurred:
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 73, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 101, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/mozilla_django_oidc/views.py", line 99, in get
    self.user = auth.authenticate(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/auth/__init__.py", line 73, in authenticate
    user = backend.authenticate(request, **credentials)
  File "/usr/local/lib/python3.7/site-packages/mozilla_django_oidc/auth.py", line 286, in authenticate
    return self.get_or_create_user(access_token, id_token, payload)
  File "/usr/local/lib/python3.7/site-packages/mozilla_django_oidc/auth.py", line 307, in get_or_create_user
    user_info = self.get_userinfo(access_token, id_token, payload)
  File "/usr/local/lib/python3.7/site-packages/mozilla_django_oidc/auth.py", line 245, in get_userinfo
    return user_response.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 890, in json
    self.content.decode(encoding), **kwargs
  File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

Exception Type: JSONDecodeError at /oidc/callback/
Exception Value: Expecting value: line 1 column 1 (char 0)
@akatsoulas
Copy link
Collaborator

Thanks @strus38 for filing this. Closing as duplicate of #376. Let's track the issue there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants