Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IdentityToken.IsExpired is always true #630

Closed
hapthien opened this issue Sep 14, 2016 · 9 comments
Closed

IdentityToken.IsExpired is always true #630

hapthien opened this issue Sep 14, 2016 · 9 comments
Assignees

Comments

@hapthien
Copy link

Hi guys,

Thank you for reviewing my reported issue.
I have a problem with checking IdentityToken.IsExpired flag. It is always True if the date time format of workstation is not the same with the expires value returned by server.
I got problem with

  • OVH Cloud
  • Server in French culture

https://github.com/openstacknetsdk/openstack.net/blob/develop/src/corelib/Core/Domain/IdentityToken.cs

In this file : https://github.com/openstacknetsdk/openstack.net/blob/develop/src/corelib/Core/Domain/IdentityToken.cs
-Should the expires value be in DateTime?
-and when checking the IsExpired, should consider about the Culture when "TryParse"?

Thank you,
hapthien

@carolynvs carolynvs self-assigned this Sep 14, 2016
@carolynvs
Copy link
Member

Thanks for reporting this problem. I think you may be right that it should instead being using ParseExact and specifying the formatstring, instead of relying upon the current culture but I'll need to verify that.

@carolynvs
Copy link
Member

I'm having trouble reproducing the problem. Would you please supply a bit more information:

  • The string value of expires returned from the identity api.
  • The current culture: CultureInfo.CurrentCulture.Name.
  • Does the following code work? If the parsing fails, it assumes that it is expired. This should help us figure out if the problem is parsing or date comparison.
var expires = "the string value of expires, e.g. 2016-09-08T17:47:44.930Z";
DateTimeOffset expiration;
var success = DateTimeOffset.TryParse(expires, out expiration);
Debug.Assert(success);
Debug.Assert(DateTimeOffset.UtcNow < expiration);

@hapthien
Copy link
Author

Sorry for the late reply.
The following is information you ask when I had issue with IsExpired always True

  • Expires value from OVH Public Cloud (the bases on Openstack): "09/20/2016 03:21:27" (without quotes)
  • CultureInfo.CurrentCulture.Name value: "fr-BE" (without quotes)
  • var success = DateTimeOffset.TryParse(expires, out expiration); --> success = False
  • DateTimeOffset.UtcNow < expiration --> False

with the same code (I mean code for checking IsExpired and logging the above data), if I change my DateTime format as this image. It works well
image

Thank you for your time to verify my problem.

@carolynvs
Copy link
Member

Oh! Wow, I did not expect that their cloud would send a non-iso datetime for expires. That's why I wasn't able to reproduce, since vanilla openstack and rackspace API's both the ISO 8601 format, e.g. 2016-09-08T17:47:44.930Z.

I'll see what I can do to support that...

@carolynvs
Copy link
Member

I don't have access to an OVH public cloud instance to test against. Can you send me a sample identity response? Remove sensitive info from the response (such as the username, token, and ip addresses), and either post it back here or even better email it directly to me carolyn.vanslyck@rackspace.com. I'll use that for my tests.

Here is an example from the OVH docs showing how to use curl to request a token. Funny, in their docs they show a ISO formatted date in the response, so I'm really curious what's going on! 😄

$ curl -d '{"auth": {"tenantName": "admin", "passwordCredentials":{"username": "admin", "password": "1234"}}}' -H "Content-type: application/json" {KEYSTONE_ADMINISTRATION_ENDPOINT}:5443/v2.0/tokens | python -mjson.tool

@hapthien
Copy link
Author

@carolynvs : I sent an email to your email address ( carolyn.vanslyck@rackspace.com) with sensitive information.
Thank you for your time.

@carolynvs
Copy link
Member

Thanks for the info! I am able to reproduce and am working on a fix today.

@carolynvs
Copy link
Member

Wow, this has been a bug for quite a while. Here's a ⭐ for finding it and helping get it fixed!

You can get the fix in v1.7.6 on nuget.

@hapthien
Copy link
Author

It works as expected now.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants