Merge "Log reauth"

This commit is contained in:
Jenkins
2015-07-09 16:39:08 +00:00
committed by Gerrit Code Review
2 changed files with 15 additions and 1 deletions

View File

@@ -15,12 +15,15 @@
# limitations under the License.
import datetime
import logging
from oslo_utils import timeutils
from openstack.auth import service_catalog as catalog
logger = logging.getLogger(__name__)
# Do not use token before expiration
BEST_BEFORE_SECONDS = 30
@@ -70,7 +73,12 @@ class AccessInfo(object):
"""
norm_expires = timeutils.normalize_time(self.expires)
soon = (timeutils.utcnow() + datetime.timedelta(seconds=best_before))
return norm_expires < soon
expiring = norm_expires < soon
if expiring:
logger.debug("Token expiring at %s", norm_expires)
return expiring
@classmethod
def is_valid(cls, body, **kwargs):

View File

@@ -15,6 +15,8 @@ The base identity plugin. Identity plugins must define the authorize method.
For examples of this class, see the v2 and v3 authentication plugins.
"""
import logging
import abc
import six
@@ -22,6 +24,9 @@ import six
from openstack.auth import base
logger = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class BaseIdentityPlugin(base.BaseAuthPlugin):
@@ -106,6 +111,7 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
:returns AccessInfo: Valid AccessInfo
"""
if self._needs_reauthenticate():
logger.debug("Re-authentication required")
self.access_info = self.authorize(transport)
return self.access_info