GitHub user Kami opened a pull request:
https://github.com/apache/libcloud/pull/178
[LIBCLOUD-428] Fix auth token caching and re-use in the OpenStack based
drivers
This branch fixes an issue described in LIBCLOUD-436
(https://issues.apache.org/jira/browse/LIBCLOUD-428).
As noted in the ticket description, the problem is that current version of
code doesn't properly check if the token has expired before using it. This
causes `InvalidCredsError` exception to be thrown if the token has expired.
This is usually a non-issue for short running scripts, but if you are using
a driver in a long running process, there is a bigger chance that the token
will expire during the life-time of the process and as such, the exception will
be thrown.
While working on this bug, I also discovered an issue with
`ex_force_auth_token` argument. Currently we support skipping the
authentication process by passing a valid auth token to the driver constructor
using `ex_force_auth_token` argument.
The problem is that we don't know about the token expiration time when this
argument is used. Ss such, we can't invalidate the token when it's about to
expire. My solution to this problem was documenting this behavior better in the
documentation.
As you can see in the diff, I also needed to update the fixtures for tests
to pass. The approach that I used is not ideal since it's basically a ticking
time bomb, but I opted for a simple and less time-consuming solution at this
point and hopefully we will figure a better one by 2031 :P
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Kami/libcloud
fix_openstack_token_caching_and_reuse
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/libcloud/pull/178.patch
----
commit a5648b34e3c33549913201013133a48488598b76
Author: Tomaz Muraus <[email protected]>
Date: 2013-11-13T13:49:49Z
Fix the following auth related things in the OpenStack classes:
- Correctly handle ex_force_auth_token argument
- Correctly cache, re-use and expire auth tokens
Also update affected tests and test fixtures.
Reported by Michael Farrell, part of LIBCLOUD-428.
----