dylanplecki / KeycloakOwinAuthentication

Keycloak Authentication Middleware for the C# OWIN Pipeline
http://keycloak.jboss.org
MIT License
56 stars 90 forks source link

RefreshTokenExpiration and AccessTokenExpiration date try parse without InvariantCulture #28

Closed greibach closed 8 years ago

greibach commented 8 years ago

Today, 1st February (1/2/2016)I realized that all my tokens were expired due to a problem with date format - it was converting wrongly all dates to 2nd January. DateTime.TryParse() in KeycloakAuthenticationHandler file is not using InvariantCulture To fix this the DateTime.TryParse() in SignInAsAuthentication(...) must be changed to something like DateTime.TryParse(expStr, CultureInfo.InvariantCulture, DateTimeStyles.None, out expDate)

dylanplecki commented 8 years ago

Thank you for the report and the fix!

Fixed in version 2.1.5 - will be on NuGet soon. The above suggested fix was implemented.

Final Notes

This was an issue with the cookies expiring (or any other sign-in-as method), and not an interaction between Keycloak Server and this extension. As such, there may still be issues hiding around since a lot of the DateTime JWT parsing is done internally in Microsoft code, and I didn't take the time to sift through it or the possible options yet.