Uploaded image for project: 'OpenId Connect'
  1. OpenId Connect
  2. OIDC-332

Each login logs a NullPointerException from TokenRenewalOnAuthenticationEventListener after one of the user's OAuth2 tokens was deleted

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 2.21.1
    • OAuth2
    • None
    • Unknown

    Description

      Steps to reproduce

      1. Let a user get two OAuth2 tokens (XWiki.OAuth2.TokenClass objects) for two client configurations.
      2. Delete the first one with OAuth2TokenStore#deleteToken (e.g. an extension disconnecting the user from a service).
      3. Log in as that user, with the login form or with basic authentication (e.g. a REST call).

      Expected

      No error, and the remaining tokens of the user are renewed.

      Actual

      Each login logs the following error, and the remaining tokens of the user are not renewed on login:

      ERROR .o.i.DefaultObservationManager - Failed to send event [org.xwiki.security.authentication.UserAuthenticatedEvent@318a1358] to listener [org.xwiki.contrib.oidc.internal.TokenRenewalOnAuthenticationEventListener@f2485d6]
      java.lang.NullPointerException: Cannot invoke "com.xpn.xwiki.objects.BaseObject.getStringValue(String)" because "object" is null
      	at org.xwiki.contrib.oidc.internal.AbstractNimbusOAuth2TokenStore.getTokens(AbstractNimbusOAuth2TokenStore.java:240)
      	at org.xwiki.contrib.oidc.internal.TokenRenewalOnAuthenticationEventListener.onEvent(TokenRenewalOnAuthenticationEventListener.java:86)
      	at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:343)
      	...
      	at com.xpn.xwiki.user.impl.xwiki.MyBasicAuthenticator.checkLogin(MyBasicAuthenticator.java:139)
      

      Cause

      deleteToken removes the token object with XWikiDocument#removeXObject, which leaves a null entry in the list returned by getXObjects. AbstractNimbusOAuth2TokenStore#getTokens iterates over that list without skipping the null entries. The code is unchanged in 2.30.0.

      Found with the OpenProject integration of XWiki SAS, which deletes the token of a user who disconnects from an OpenProject connection, on XWiki 18.8.0.

      Attachments

        Activity

          People

            Unassigned Unassigned
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: