Ejemplo n.º 1
0
    def get_access_data(endpoint_config=None, user_config=None):
        endpoint_config = endpoint_config or UserAuthConfig()
        user_config = user_config or UserConfig()

        if endpoint_config.strategy.lower() == 'keystone':
            return IdentityServiceBehaviors.get_access_data(
                user_config.username, user_config.password,
                user_config.tenant_name, endpoint_config.auth_endpoint)

        elif endpoint_config.strategy.lower() == 'rax_auth':
            token_client = RaxTokenAPI_Client(
                endpoint_config.auth_endpoint, 'json', 'json')
            token_behaviors = RaxTokenAPI_Behaviors(token_client)
            return token_behaviors.get_access_data(user_config.username,
                                                   user_config.api_key,
                                                   user_config.tenant_id)

        elif endpoint_config.strategy.lower() == 'saio_tempauth':
            auth_client = SaioAuthAPI_Client(endpoint_config.auth_endpoint)
            auth_behaviors = SaioAuthAPI_Behaviors(auth_client)
            return auth_behaviors.get_access_data(
                user_config.username, user_config.password)

        else:
            raise NotImplementedError
Ejemplo n.º 2
0
    def get_access_data(endpoint_config=None, user_config=None):
        endpoint_config = endpoint_config or UserAuthConfig()
        user_config = user_config or UserConfig()

        if endpoint_config.strategy.lower() == 'keystone':
            return IdentityServiceBehaviors.get_access_data(
                user_config.username, user_config.password,
                user_config.tenant_name, endpoint_config.auth_endpoint)

        elif endpoint_config.strategy.lower() == 'rax_auth':
            token_client = RaxTokenAPI_Client(endpoint_config.auth_endpoint,
                                              'json', 'json')
            token_behaviors = RaxTokenAPI_Behaviors(token_client)
            return token_behaviors.get_access_data(user_config.username,
                                                   user_config.api_key,
                                                   user_config.tenant_id)

        elif endpoint_config.strategy.lower() == 'saio_tempauth':
            auth_client = SaioAuthAPI_Client(endpoint_config.auth_endpoint)
            auth_behaviors = SaioAuthAPI_Behaviors(auth_client)
            return auth_behaviors.get_access_data(user_config.username,
                                                  user_config.password)

        else:
            raise NotImplementedError
Ejemplo n.º 3
0
 def authenticate(self):
     resp = IdentityServiceBehaviors.memoized_authenticate(
         self.username, self.password, self.tenant_name, self.client.url,
         self.serialize_format, self.deserialize_format)
     if resp.entity is None:
         raise Exception("Failed to authenticate")
     self.access_data = resp.entity
     self.client.token = self.access_data.token.id_
     self.user_id = self.access_data.user.id_
     self.tenant_id = self.access_data.token.tenant.id_
     service = self.access_data.get_service(self.service_name)
     endpoint = service.get_endpoint(self.region)
     self.public_url = endpoint.public_url
     self.private_url = endpoint.private_url
     self.admin_url = endpoint.admin_url
Ejemplo n.º 4
0
 def authenticate(self):
     resp = IdentityServiceBehaviors.memoized_authenticate(
         self.username, self.password, self.tenant_name, self.client.url,
         self.serialize_format, self.deserialize_format)
     if resp.entity is None:
         raise Exception("Failed to authenticate")
     self.access_data = resp.entity
     self.client.token = self.access_data.token.id_
     self.user_id = self.access_data.user.id_
     self.tenant_id = self.access_data.token.tenant.id_
     service = self.access_data.get_service(self.service_name)
     if service:
         endpoint = service.get_endpoint(self.region)
         self.public_url = endpoint.public_url
         self.private_url = endpoint.private_url
         self.admin_url = endpoint.admin_url
Ejemplo n.º 5
0
    def get_access_data(endpoint_config=None, user_config=None):
        endpoint_config = endpoint_config or UserAuthConfig()
        user_config = user_config or UserConfig()

        if endpoint_config.strategy.lower() == 'keystone':
            return IdentityServiceBehaviors.get_access_data(
                user_config.username, user_config.password,
                user_config.tenant_name, endpoint_config.auth_endpoint)

        elif endpoint_config.strategy.lower() == 'rax_auth':
            token_client = RaxTokenAPI_Client(endpoint_config.auth_endpoint,
                                              'json', 'json')
            token_behaviors = RaxTokenAPI_Behaviors(token_client)
            return token_behaviors.get_access_data(user_config.username,
                                                   user_config.api_key,
                                                   user_config.tenant_id)

        elif endpoint_config.strategy.lower() == 'rax_auth_mfa':
            passcode = user_config.passcode
            if passcode is None:
                # TODO: This is a place holder for adding the functionality to
                # use an external service (e.g. - SMS) to provide the passcode
                pass
            token_client = RaxToken_MFA_API_Client(
                url=endpoint_config.auth_endpoint,
                serialize_format='json',
                deserialize_format='json')
            token_behaviors = RaxToken_MFA_API_Behaviors(token_client)
            return token_behaviors.get_access_data(
                username=user_config.username,
                password=user_config.password,
                tenant_id=user_config.tenant_id,
                passcode=passcode)

        elif endpoint_config.strategy.lower() == 'saio_tempauth':
            auth_client = SaioAuthAPI_Client(endpoint_config.auth_endpoint)
            auth_behaviors = SaioAuthAPI_Behaviors(auth_client)
            return auth_behaviors.get_access_data(user_config.username,
                                                  user_config.password)

        else:
            raise NotImplementedError
Ejemplo n.º 6
0
    def get_access_data(endpoint_config=None, user_config=None):
        endpoint_config = endpoint_config or UserAuthConfig()
        user_config = user_config or UserConfig()

        if endpoint_config.strategy.lower() == 'keystone':
            return IdentityServiceBehaviors.get_access_data(
                user_config.username, user_config.password,
                user_config.tenant_name, endpoint_config.auth_endpoint)

        elif endpoint_config.strategy.lower() == 'rax_auth':
            token_client = RaxTokenAPI_Client(
                endpoint_config.auth_endpoint, 'json', 'json')
            token_behaviors = RaxTokenAPI_Behaviors(token_client)
            return token_behaviors.get_access_data(user_config.username,
                                                   user_config.api_key,
                                                   user_config.tenant_id)

        elif endpoint_config.strategy.lower() == 'rax_auth_mfa':
            passcode = user_config.passcode
            if passcode is None:
                # TODO: This is a place holder for adding the functionality to
                # use an external service (e.g. - SMS) to provide the passcode
                pass
            token_client = RaxToken_MFA_API_Client(
                url=endpoint_config.auth_endpoint,
                serialize_format='json', deserialize_format='json')
            token_behaviors = RaxToken_MFA_API_Behaviors(token_client)
            return token_behaviors.get_access_data(
                username=user_config.username, password=user_config.password,
                tenant_id=user_config.tenant_id, passcode=passcode)

        elif endpoint_config.strategy.lower() == 'saio_tempauth':
            auth_client = SaioAuthAPI_Client(endpoint_config.auth_endpoint)
            auth_behaviors = SaioAuthAPI_Behaviors(auth_client)
            return auth_behaviors.get_access_data(
                user_config.username, user_config.password)

        else:
            raise NotImplementedError
Ejemplo n.º 7
0
    def __init__(self):
        ident_config = IdentityConfig()
        user_config = self._user_config_class()
        self.serialize_format = ident_config.serialize_format
        self.deserialize_format = ident_config.deserialize_format
        self.config_token = ident_config.token_id
        self.service_name = ident_config.identity_service_name
        self.region = ident_config.region
        self.username = user_config.username
        self.password = user_config.password
        self.tenant_name = user_config.tenant_name
        self.config_tenant_id = user_config.tenant_id
        self.endpoint = user_config.authentication_endpoint

        self.client = IdentityServiceClient(
            url=self.endpoint,
            serialize_format=self.serialize_format,
            deserialize_format=self.deserialize_format)
        self.behaviors = IdentityServiceBehaviors(self.client)
        self.public_url = None
        self.private_url = None
        self.admin_url = None
Ejemplo n.º 8
0
 def get_keystone_access_data(
         cls, username, password, tenant_name, auth_endpoint):
     return IdentityServiceBehaviors.get_access_data(
         username, password, tenant_name, auth_endpoint)
Ejemplo n.º 9
0
 def get_keystone_access_data(
         cls, username, password, tenant_name, auth_endpoint):
     return IdentityServiceBehaviors.get_access_data(
         username, password, tenant_name, auth_endpoint)