From 27b72c918061e14fddf2e4a3009163c7447e657c Mon Sep 17 00:00:00 2001 From: Kovalov Maxim Date: Sun, 12 Apr 2015 11:00:33 +0300 Subject: [PATCH] BK_1305_refresh_token --- keystoneclient/auth/identity/v3.py | 8 +++++--- keystoneclient/v3/client.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/keystoneclient/auth/identity/v3.py b/keystoneclient/auth/identity/v3.py index 99d7562fc..ef20c92a7 100644 --- a/keystoneclient/auth/identity/v3.py +++ b/keystoneclient/auth/identity/v3.py @@ -191,7 +191,6 @@ def get_auth_data(self, session, auth, headers, **kwargs): class AuthConstructor(Auth): """AuthConstructor is a means of creating an Auth Plugin that contains only one authentication method. This is generally the required usage. - An AuthConstructor creates an AuthMethod based on the method's arguments and the auth_method_class defined by the plugin. It then creates the auth plugin with only that authentication method. @@ -261,7 +260,7 @@ def get_options(cls): class TokenMethod(AuthMethod): - _method_parameters = ['token'] + _method_parameters = ['token', 'refresh_token'] def __init__(self, **kwargs): """Construct an Auth plugin to fetch a token from a token. @@ -272,7 +271,10 @@ def __init__(self, **kwargs): def get_auth_data(self, session, auth, headers, **kwargs): headers['X-Auth-Token'] = self.token - return 'token', {'id': self.token} + payload = {'id': self.token} + if self.refresh_token: + payload['refresh'] = True + return 'token', payload class Token(AuthConstructor): diff --git a/keystoneclient/v3/client.py b/keystoneclient/v3/client.py index a271db37d..fa6732e15 100644 --- a/keystoneclient/v3/client.py +++ b/keystoneclient/v3/client.py @@ -187,6 +187,9 @@ def __init__(self, **kwargs): # DEPRECATED: if session is passed then we go to the new behaviour of # authenticating on the first required call. + + self._refresh_token = kwargs.get('refresh_token', False) + if 'session' not in kwargs and self.management_url is None: self.authenticate() @@ -239,7 +242,7 @@ def get_raw_token_from_identity_service(self, auth_url, user_id=None, auth_methods = [] if token: - auth_methods.append(v3_auth.TokenMethod(token=token)) + auth_methods.append(v3_auth.TokenMethod(token=token, refresh_token=self._refresh_token)) if password: m = v3_auth.PasswordMethod(user_id=user_id,