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

User authentication tokens never expire (UserAuthenticationToken.Timestamp comparison) #2011

Closed
ahukkanen opened this issue Jul 25, 2014 · 1 comment
Assignees
Milestone

Comments

@ahukkanen
Copy link

Noticed this line of code when debugging our SSO implementation:

->Where('(uat.Timestamp + uat.Lifetime) >=', 'NOW()')

(I picked a specific commit tree so that the code reference does not change.)

I believe this comparison makes the tokens valid forever.

The comparison that I checked from the MySQL logs looked like this:

select uat.* from GDN_UserAuthenticationToken uat
  where uat.ForeignUserKey = '999999'
  and uat.ProviderKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  and ((uat.Timestamp + uat.Lifetime) >= 'NOW()' or uat.Lifetime = '0')

Now, let's say the uat.Timestamp value is for example "2014-07-25 18:00:00". The "+" equation (uat.Timestamp + uat.Lifetime) results in an integer like this for a lifetime value of "60":
20140725180060

So, it just converts the date string "2014-07-25 18:00:00" into an integer "20140725180000" and adds the lifetime value of "60" to it.

Therefore, the actual comparison done by MySQL is equal to this query:

SELECT 20140725180060 >= 'NOW()'

It compares the first integer into string "NOW()". And the "NOW()" string evaluates always to zero in its integer conversion, so this statement is always true.

It makes the tokens valid forever.

@ahukkanen
Copy link
Author

Also, I'd like to know what unit the "Lifetime" column refers to. I couldn't find this information anywhere. Is it seconds or minutes?

@linc linc added the Bug label Feb 14, 2015
@linc linc removed the Bug label Sep 26, 2015
@linc linc added this to the Sprint 12 milestone Apr 25, 2016
@linc linc modified the milestones: Sprint 13, Sprint 12 May 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants