openstacknetsdk / openstack.net

An OpenStack Cloud SDK for Microsoft .NET
http://www.openstacknetsdk.org
Other
117 stars 101 forks source link

OpenStackIdentityProvider always refreshes UserAccess even though IdentityToken is not expired #586

Open Ectobius opened 8 years ago

Ectobius commented 8 years ago

I tried to debug the code and I've noticed that IdentityToken.Expires property contains date in en-us format but from server it comes in ISO 8601 format. Locale on my machine is not en-us so that parsing of the Expires property fails and IdentityToken.IsExpired is always false which causes the token to be refreshed. So to summarize: inside the refreshCallback in OpenStackIdentityProvider.GetUserAccess method: After executing this line:

var response = ExecuteRESTRequest<JObject>(identity, new Uri(UrlBase, "/v2.0/tokens"), HttpMethod.POST, requestBody, isTokenRequest: true);

response.access.expires = "2016-01-29T10:46:36Z". And after executing this line:

UserAccess access = userAccessObject.ToObject<UserAccess>();

access.Token.Expires = "01/29/2016 10:46:36". But IdentityToken.Expires property is intended to store expiration time in the format originally returned by the authentication response (as its comment indicates).

carolynvs commented 8 years ago

Thank you for reporting this! I'll take a look today and work on a fix.

carolynvs commented 8 years ago

I think this is due to the SDK using the global json.net serialization settings. I wasn't able to reproduce to know for sure.

I've built the 1.5.1 branch (75b867c9076927eb6e8029b53e6878a1e1173ab4), and published the nuget package to myget as 1.5.1-beta1. Please try that out (the only change is this bug fix), and let me know if that resolves the problem for you. If it does, I'll release it officially.

Ectobius commented 8 years ago

No, unfortunately it doesn't resolve my problem.