Registered claims error after upgrading from 5.0.5 to 5.2.0.

Created on 6 January 2022, almost 4 years ago
Updated 12 September 2024, about 1 year ago

Problem/Motivation

Error: Lcobucci\JWT\Token\RegisteredClaimGiven: Builder#withClaim() is meant to be used for non-registered claims, check the documentation on how to set claim "sub" in Lcobucci\JWT\Token\RegisteredClaimGiven::forClaim() (line 18 of /app/vendor/lcobucci/jwt/src/Token/RegisteredClaimGiven.php).

Steps to reproduce

Setup a Drupal provider.
Setup an external consumer which expects a "sub" field mapping.

Proposed resolution

I don't know if this is a problem with my implementation, simple_oauth or the underlying package. 'sub' is one of the claims fields used by simple_oath default normalizer, but it seems like others would be experiencing this issue.
* Should I override the normalizer and set the claims (getClaimsFromAccount) without 'sub'?
* Is 5.2 compatible with lesser versions (3.4) of lcobucci/jwt? Are others explicitly using lower version?

I downgraded to 5.0.6 and our implementation started working again, but would like to figure out the source of this issue.

FULL TRACE

Lcobucci\JWT\Token\RegisteredClaimGiven: Builder#withClaim() is meant to be used for non-registered claims, check the documentation on how to set claim "sub" in Lcobucci\JWT\Token\RegisteredClaimGiven::forClaim() (line 18 of /app/vendor/lcobucci/jwt/src/Token/RegisteredClaimGiven.php).
Lcobucci\JWT\Token\Builder->withClaim('sub', '5') (Line: 89)
OpenIDConnectServer\IdTokenResponse->getExtraParams(Object) (Line: 51)
League\OAuth2\Server\ResponseTypes\BearerTokenResponse->generateHttpResponse(Object) (Line: 208)
League\OAuth2\Server\AuthorizationServer->respondToAccessTokenRequest(Object, Object) (Line: 87)
Drupal\simple_oauth\Controller\Oauth2Token->handleToken(Object, Object) (Line: 63)
Drupal\simple_oauth\Controller\Oauth2Token->token(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Thanks.

πŸ› Bug report
Status

Needs work

Version

5.2

Component

OpenID Connect

Created by

πŸ‡ΊπŸ‡ΈUnited States bfuzze9898

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024