Exemple #1
0
    def get_access_data(self, endpoint_config=None, user_config=None):
        endpoint_config = endpoint_config or UserAuthConfig()
        user_config = user_config or UserConfig()

        if endpoint_config.strategy.lower() == 'keystone':
            token_client = OSTokenAPI_Client(
                endpoint_config.auth_endpoint, 'json', 'json')
            token_behaviors = OSTokenAPI_Behaviors(token_client)
            return token_behaviors.get_access_data(user_config.username,
                                                   user_config.password,
                                                   user_config.tenant_name)

        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
Exemple #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() == '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
Exemple #3
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
Exemple #4
0
 def get_saio_tempauth_access_data(
         cls, username, password, auth_endpoint):
     client = SaioAuthAPI_Client(auth_endpoint)
     behaviors = SaioAuthAPI_Behaviors(client)
     return behaviors.get_access_data(username, password)
Exemple #5
0
 def get_saio_tempauth_access_data(
         cls, username, password, auth_endpoint):
     client = SaioAuthAPI_Client(auth_endpoint)
     behaviors = SaioAuthAPI_Behaviors(client)
     return behaviors.get_access_data(username, password)