Auth upgrade
Change-Id: I79ab17ab95152fc483cde8eb8bbe4e123f66cfef
This commit is contained in:
0
cloudcafe/auth/__init__.py
Normal file
0
cloudcafe/auth/__init__.py
Normal file
27
cloudcafe/auth/config.py
Normal file
27
cloudcafe/auth/config.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from cloudcafe.common.models.configuration import ConfigSectionInterface
|
||||
|
||||
|
||||
class UserEndpointConfig(ConfigSectionInterface):
|
||||
|
||||
SECTION_NAME = 'user_auth_endpoint'
|
||||
|
||||
@property
|
||||
def endpoint(self):
|
||||
return self.get("endpoint")
|
||||
|
||||
@property
|
||||
def strategy(self):
|
||||
return self.get("strategy")
|
||||
|
||||
|
||||
class ComputeAdminEndpointConfig(ConfigSectionInterface):
|
||||
|
||||
SECTION_NAME = 'compute_admin_auth_endpoint'
|
||||
|
||||
@property
|
||||
def endpoint(self):
|
||||
return self.get("endpoint")
|
||||
|
||||
@property
|
||||
def strategy(self):
|
||||
return self.get("strategy")
|
||||
20
cloudcafe/auth/provider.py
Normal file
20
cloudcafe/auth/provider.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from cloudcafe.extensions.rax_auth.v2_0.tokens_api.client import TokenAPI_Client
|
||||
from cloudcafe.extensions.rax_auth.v2_0.tokens_api.behaviors import TokenAPI_Behaviors
|
||||
from cloudcafe.extensions.rax_auth.v2_0.tokens_api.config import TokenAPI_Config
|
||||
from cloudcafe.identity.v2_0.tokens_api.client import TokenAPI_Client as OSTokenAPI_Client
|
||||
from cloudcafe.identity.v2_0.tokens_api.behaviors import TokenAPI_Behaviors as OSTokenAPI_Behaviors
|
||||
from cloudcafe.identity.v2_0.tokens_api.config import TokenAPI_Config as OSTokenAPI_Config
|
||||
|
||||
class AuthProvider(object):
|
||||
|
||||
def __init__(self, auth_config):
|
||||
self.auth_config = auth_config
|
||||
|
||||
def get_access_data(self):
|
||||
if self.auth_config.strategy.lower() == 'keystone':
|
||||
token_client = OSTokenAPI_Client(
|
||||
self.auth_config.authentication_endpoint, 'json', 'json')
|
||||
token_behaviors = OSTokenAPI_Behaviors(token_client)
|
||||
return token_behaviors.get_access_data(self.auth_config.username,
|
||||
self.auth_config.password,
|
||||
self.auth_config.tenant_name)
|
||||
@@ -17,9 +17,9 @@ limitations under the License.
|
||||
from cloudcafe.common.models.configuration import ConfigSectionInterface
|
||||
|
||||
|
||||
class ComputeConfig(ConfigSectionInterface):
|
||||
class ComputeEndpointConfig(ConfigSectionInterface):
|
||||
|
||||
SECTION_NAME = 'compute'
|
||||
SECTION_NAME = 'compute_endpoint'
|
||||
|
||||
@property
|
||||
def region(self):
|
||||
@@ -47,22 +47,10 @@ class ComputeAuthorizationConfig(ConfigSectionInterface):
|
||||
return self.get("tenant_name")
|
||||
|
||||
|
||||
class ComputeAdminConfig(ConfigSectionInterface):
|
||||
class ComputeAdminUserConfig(ConfigSectionInterface):
|
||||
|
||||
SECTION_NAME = 'compute_admin_user'
|
||||
|
||||
@property
|
||||
def authentication_endpoint(self):
|
||||
return self.get("authentication_endpoint")
|
||||
|
||||
@property
|
||||
def compute_endpoint_name(self):
|
||||
return self.get("compute_endpoint_name")
|
||||
|
||||
@property
|
||||
def region(self):
|
||||
return self.get("region")
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
return self.get("username")
|
||||
|
||||
@@ -19,7 +19,7 @@ from cloudcafe.common.models.configuration import ConfigSectionInterface
|
||||
|
||||
class TokenAPI_Config(ConfigSectionInterface):
|
||||
|
||||
SECTION_NAME = 'rax_token_api'
|
||||
SECTION_NAME = 'user'
|
||||
|
||||
@property
|
||||
def serialize_format(self):
|
||||
@@ -29,10 +29,6 @@ class TokenAPI_Config(ConfigSectionInterface):
|
||||
def deserialize_format(self):
|
||||
return self.get("deserialize_format")
|
||||
|
||||
@property
|
||||
def authentication_endpoint(self):
|
||||
return self.get("authentication_endpoint")
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
return self.get("username")
|
||||
|
||||
@@ -19,7 +19,20 @@ from cloudcafe.common.models.configuration import ConfigSectionInterface
|
||||
|
||||
class TokenAPI_Config(ConfigSectionInterface):
|
||||
|
||||
SECTION_NAME = 'token_api'
|
||||
SECTION_NAME = 'user_auth_endpoint'
|
||||
|
||||
@property
|
||||
def endpoint(self):
|
||||
return self.get("endpoint")
|
||||
|
||||
@property
|
||||
def strategy(self):
|
||||
return self.get("strategy")
|
||||
|
||||
|
||||
class TokenAPI_Config(ConfigSectionInterface):
|
||||
|
||||
SECTION_NAME = 'user'
|
||||
|
||||
@property
|
||||
def serialize_format(self):
|
||||
@@ -29,10 +42,6 @@ class TokenAPI_Config(ConfigSectionInterface):
|
||||
def deserialize_format(self):
|
||||
return self.get("deserialize_format")
|
||||
|
||||
@property
|
||||
def authentication_endpoint(self):
|
||||
return self.get("authentication_endpoint")
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
return self.get("username")
|
||||
|
||||
Reference in New Issue
Block a user