Skip to content

Allow ISO Date encoded timestamp fields in JWT tokens. #6187

Closed

Description

@greyfairer

Summary

Both Auth0 and OneLogin identity providers use ISO Date strings for the 'updated_at' claim in JWT Tokens, even if the spec says these should be numeric (unix timestamp). https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims

If this happens, the StandardClaimAccessor#getUpdatedAt throws exceptions.

Actual Behavior

If you use an OpenID Connector that writes the 'updated_at' claim in a JWT token in ISO Date format instead of a numerical unix timestamp, the getters on OidcUserInfo throw errors, so you cannot use e.g. jackson to serialize this user info.

Expected Behavior

In general, getters should not throw exceptions. If the field is invalid, the constructor or the setter should throw an exception, or the field should be null.

In this case, it would be nice to accept ISO Date formatted timestamps as valid values, since apparently this is used by at least two major OIDC vendors.

Version

5.1.1.RELEASE

Sample

@Controller
public class MyCollaboratorInfoController {
    @RequestMapping(value = "/myCollaboratorInfo.json")
    @ResponseBody
    public Principal currentUser(Principal principal) {
        return principal; //throws java.lang.IllegalArgumentException: Unable to convert claim 'updated_at' of type 'class java.lang.String' to Instant.
    }

    @RequestMapping(value = "/myCollaboratorInfo2.json")
    @ResponseBody
    public Map<String, Object> currentUser2(Principal principal) {
        return ((OAuth2AuthenticationToken)principal).getPrincipal().getAttributes(); //workaround that avoids the ClaimAccessor issue.
    }

Activity

  1. greyfairer commented on Nov 29, 2018

    @greyfairer
    Author
  2. self-assigned this
    on Nov 29, 2018
  3. added
    in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
    on Nov 29, 2018
  4. added this to the 5.2.0.M1 milestone on Nov 29, 2018
  5. jgrandja commented on Nov 29, 2018

    @jgrandja
    Collaborator

    @greyfairer Agreed...

    getters should not throw exceptions

    I'll apply some improvements here.

  6. modified the milestones: 5.2.0.M1, 5.1.3 on Dec 6, 2018
  7. jgrandja commented on Dec 6, 2018

    @jgrandja
    Collaborator

    @greyfairer After giving this some further thought, we need to apply some more involved changes to ClaimAccessor to ensure it's more robust going forward. I have logged #6245 detailing the required changes. We're going to target this improvement for the 5.2.0 release.

    Given this, I'm going to close this issue and associated PR as ClaimAccessor needs a bigger improvement compared to what is in the PR. I apologize for the back-and-forth and really appreciate your efforts and bringing up this issue so we can address it for the next release.

  8. added and removed
    in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
    on Dec 6, 2018
  9. removed their assignment
    on Dec 6, 2018
  10. removed this from the 5.1.3 milestone on Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions