50
Views
7
Comments
Solved
[JWT] JWT fails to interpret null datetime values
Question
jwt
Service icon
Forge asset by João Almeida
Application Type
Service

Hi,

I was trying to create tokens signed with symmetric algorithms without expiration, not before and issued at dates since they are optional.

However, the error keeps appearing: IDX12401: Expires: '01/01/1900 00:00:00' must be after NotBefore: '01/01/1900 00:00:00'.

My guess is that the Outsystems NullDate value (01/01/1900 00:00:00) is not being handled in JWT Core.

Any help on this issue?

2022-02-18 15-32-27
João Almeida
Champion
Solution

The thing is I didn't specify any datetime for all 3 fields.

As I mentioned above, that's the default behaviour of Microsoft's IdentityModel, which the component is based on. For now the default will stick with that, because changing it would be a bigger change and added for a future bigger release.

The "Expires" and "Not Before" are generated according to my server timezone but not the "Issued At" field.

Not really sure why, should use the server's datetime but those dates are being set inside IdentityModel . I just double checked the code to see if could be any default being set in the logic, but there is none. Could be something related with the library's version, and it's due to be updated in the future.



2022-02-18 15-32-27
João Almeida
Champion

Hi!

Let me test that, and even add that scenario ro the test cases, and I'll get back to you.

2022-02-18 15-32-27
João Almeida
Champion

The component was indeed not handling correctly null dates, just fixed that and uploaded a new version. For now it will stick to the default behaviour of Microsoft's IdentityModel: which is to set the dates with an one hour expiration if no dates are is provided, this could be overridden but it would be a bigger change and added for a future bigger release.

UserImage.jpg
c3d

Hi João Almeida,

I generated the token using JWT_Demo with empty values at 17:18 (my time zone) but the issued at time seems to be in UTC without timezone.

  • Issued At                 2022-06-27 09:18:35
  • Not Before              2022-06-27 17:18:35
  • Expires                   2022-06-27 18:18:35
2022-02-18 15-32-27
João Almeida
Champion

You generated the token in which server? By default it will use the server's time, and the Outsystems Cloud servers usually are in UTC.

Regarding the datetime not having timezone, that's a shortcoming of outsystems (https://www.outsystems.com/ideas/11961/add-timezone-support-for-current-datetime-data-type/#) that I was trying to avoid to address here. 

In the end settings the dates will allow more control.


UserImage.jpg
c3d

It was generated in an on-premise server.

The thing is I didn't specify any datetime for all 3 fields. The "Expires" and "Not Before" are generated according to my server timezone but not the "Issued At" field.

2022-02-18 15-32-27
João Almeida
Champion
Solution

The thing is I didn't specify any datetime for all 3 fields.

As I mentioned above, that's the default behaviour of Microsoft's IdentityModel, which the component is based on. For now the default will stick with that, because changing it would be a bigger change and added for a future bigger release.

The "Expires" and "Not Before" are generated according to my server timezone but not the "Issued At" field.

Not really sure why, should use the server's datetime but those dates are being set inside IdentityModel . I just double checked the code to see if could be any default being set in the logic, but there is none. Could be something related with the library's version, and it's due to be updated in the future.



UserImage.jpg
c3d

Thanks, João Almeida!


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.