Class "Sop\JWX\JWT\JWT" not found

Created on 9 December 2023, about 1 year ago
Updated 11 December 2023, about 1 year ago

Problem/Motivation

Upon hitting the oidc SSO for log in, the user receives the following error in the browser
The website encountered an unexpected error. Please try again later.
Error: Class "Sop\JWX\JWT\JWT" not found in Drupal\oidc\OpenidConnectRealm\OpenidConnectRealmBase->getJsonWebTokens() (line 367 of /bitnami/drupal/modules/contrib/oidc/src/OpenidConnectRealm/OpenidConnectRealmBase.php).

In the drupal logs, I see the following Warning and 2 errors (in order)
Path: /. Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException: The 'access content' permission is required. in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 118 of /opt/bitnami/drupal/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).
then

Error: Class "Sop\JWX\JWT\JWT" not found in Drupal\oidc\OpenidConnectRealm\OpenidConnectRealmBase->getJsonWebTokens() (line 367 of /bitnami/drupal/modules/contrib/oidc/src/OpenidConnectRealm/OpenidConnectRealmBase.php)
#0 /bitnami/drupal/modules/contrib/oidc/src/Plugin/OpenidConnectRealm/GenericOpenidConnectRealm.php(401): Drupal\oidc\OpenidConnectRealm\OpenidConnectRealmBase->getJsonWebTokens()
#1 /bitnami/drupal/modules/contrib/oidc/src/OpenidConnectRealm/OpenidConnectRealmBase.php(135): Drupal\oidc\Plugin\OpenidConnectRealm\GenericOpenidConnectRealm->getJsonWebTokens()
#2 /bitnami/drupal/modules/contrib/oidc/src/Controller/OpenidConnectController.php(197): Drupal\oidc\OpenidConnectRealm\OpenidConnectRealmBase->getJsonWebTokensForLogin()
#3 [internal function]: Drupal\oidc\Controller\OpenidConnectController->loginRedirect()
#4 /opt/bitnami/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#5 /opt/bitnami/drupal/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#6 /opt/bitnami/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#7 /opt/bitnami/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#8 /opt/bitnami/drupal/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /opt/bitnami/drupal/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#10 /opt/bitnami/drupal/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#11 /opt/bitnami/drupal/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#12 /opt/bitnami/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#13 /opt/bitnami/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#14 /opt/bitnami/drupal/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#15 /opt/bitnami/drupal/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#16 /opt/bitnami/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#17 /opt/bitnami/drupal/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#18 /opt/bitnami/drupal/index.php(19): Drupal\Core\DrupalKernel->handle()
#19 {main}

then

Error: Class "Sop\JWX\JWT\JWT" not found in Drupal\oidc\OpenidConnectRealm\OpenidConnectRealmBase->getJsonWebTokens() (line 367 of /bitnami/drupal/modules/contrib/oidc/src/OpenidConnectRealm/OpenidConnectRealmBase.php)
#0 /bitnami/drupal/modules/contrib/oidc/src/Plugin/OpenidConnectRealm/GenericOpenidConnectRealm.php(401): Drupal\oidc\OpenidConnectRealm\OpenidConnectRealmBase->getJsonWebTokens()
#1 /bitnami/drupal/modules/contrib/oidc/src/OpenidConnectRealm/OpenidConnectRealmBase.php(135): Drupal\oidc\Plugin\OpenidConnectRealm\GenericOpenidConnectRealm->getJsonWebTokens()
#2 /bitnami/drupal/modules/contrib/oidc/src/Controller/OpenidConnectController.php(197): Drupal\oidc\OpenidConnectRealm\OpenidConnectRealmBase->getJsonWebTokensForLogin()
#3 [internal function]: Drupal\oidc\Controller\OpenidConnectController->loginRedirect()
#4 /opt/bitnami/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#5 /opt/bitnami/drupal/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#6 /opt/bitnami/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#7 /opt/bitnami/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#8 /opt/bitnami/drupal/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /opt/bitnami/drupal/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#10 /opt/bitnami/drupal/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#11 /opt/bitnami/drupal/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#12 /opt/bitnami/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#13 /opt/bitnami/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#14 /opt/bitnami/drupal/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#15 /opt/bitnami/drupal/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#16 /opt/bitnami/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#17 /opt/bitnami/drupal/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#18 /opt/bitnami/drupal/index.php(19): Drupal\Core\DrupalKernel->handle()
#19 {main}

Steps to reproduce

Install oidc module via composer require 'drupal/oidc:^2.2'

Create/configure new generic realm + configure provider

drush cget oidc.settings returns

generic_realms:
  - <the_realm_id>
login_path: /oidc/login/generic%3A<the_realm_id>
redirect_403: true
disable_user_routes: true
show_session_expired_message: true

drush cget oidc.realm.generic.<the_realm_id> returns

config_url: '<provider's discovery endpoint>'
client_id: <the-client-id>
client_secret: <TheClientSecret>
scopes:
  - profile
  - email
request_userinfo: false
id_claim: sub
username_claim: preferred_username
email_claim: email
given_name_claim: given_name
family_name_claim: family_name
display_name_format: '[user:account-name]'
default_rid: generic_logged_in
name: <the realm's name>

I could have sworn I had oidc working previously several months ago. But this is what I see now, and I've love to figure out what's going wrong.

💬 Support request
Status

Closed: works as designed

Version

2.2

Component

Miscellaneous

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @amw5g
  • 🇧🇪Belgium matthijs

    Can you check if the sop/jwx package is properly installed andere can be autoloaded?
    It's in the composer dependencies, but it seems missing in your installation.
    It's this class that can't be autoloaded: https://github.com/sop/jwx/blob/master/lib/JWX/JWT/JWT.php

  • Very weird. That was a great idea. I had done that Friday before I left, and it showed installed. So I ran the composer require again today, and again, it showed as already installed.

    So I killed/restarted the drupal pod. When it came back up, still the same error. I then executed composer dump-autoload -o to generate an autoload file. I don't exactly understand what this does, but I saw it recommended somewhere else.

    Then I tried to reinstall sop/jwx via composer, but it told me that it's not currently installed. What?

    Executed the composer require command, it installed, and now OIDC is working as expected on that site.

    Clearly I did something wrong; or thought I'd done something and actually hadn't. Regardless, I appreciate the guidance because I'm unstuck. Now I hope it's just as easy to do the same in my other environments.

    Much obliged!

  • Status changed to Closed: works as designed about 1 year ago
  • 🇧🇪Belgium matthijs

    Glad you git it fixed!

Production build 0.71.5 2024