Source code for sdkms.v1.apis.two_factor_authentication_api

# coding: utf-8

"""
    Fortanix DSM REST API

    This is a set of REST APIs for accessing the Fortanix Data Security Manager. This includes APIs for managing accounts, and for performing cryptographic and key management operations. 

    OpenAPI spec version: 1.0.0-20200608
    Contact: support@fortanix.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..api_client import ApiClient


# NOTE: This class is auto generated by the swagger code generator program.
# Do not edit the class manually.
# Ref: https://github.com/swagger-api/swagger-codegen
[docs]class TwoFactorAuthenticationApi(object):
[docs] def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client
[docs] def authorize_recovery_code(self, async_call=False, **kwargs): """ Complete two factor authentication with a backup recovery code. The caller needs to provide a bearer token for the session in the request body. Each recovery code may only be used once, so users should update their two factor configuration after using this API. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.authorize_recovery_code_with_http_info(async_call=async_call, **kwargs) else: (data) = self.authorize_recovery_code_with_http_info(async_call=async_call, **kwargs) return data
def authorize_recovery_code_with_http_info(self, async_call=False, **kwargs): """ Complete two factor authentication with a backup recovery code. The caller needs to provide a bearer token for the session in the request body. Each recovery code may only be used once, so users should update their two factor configuration after using this API. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.authorize_recovery_code_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method authorize_recovery_code" % key ) params[key] = val del params['kwargs'] collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/session/auth/2fa/recovery_code', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def authorize_u2_f(self, async_call=False, **kwargs): """ Complete two factor authentication with a U2F authentication token to authenticate to SDKMS. The response body contains a bearer authentication token which needs to be provided by subsequent calls for the duration of the session. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.authorize_u2_f_with_http_info(async_call=async_call, **kwargs) else: (data) = self.authorize_u2_f_with_http_info(async_call=async_call, **kwargs) return data
def authorize_u2_f_with_http_info(self, async_call=False, **kwargs): """ Complete two factor authentication with a U2F authentication token to authenticate to SDKMS. The response body contains a bearer authentication token which needs to be provided by subsequent calls for the duration of the session. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.authorize_u2_f_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method authorize_u2_f" % key ) params[key] = val del params['kwargs'] collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['basicAuth'] return self.api_client.call_api('/sys/v1/session/auth/2fa/u2f', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def generate_recovery_codes(self, async_call=False, **kwargs): """ Generate backup recovery codes that may be used to complete complete two factor authentication. The caller needs to provide a bearer token for the session in the request body. Two factor configuration must be unlocked to use this API. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `RecoveryCodes` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.generate_recovery_codes_with_http_info(async_call=async_call, **kwargs) else: (data) = self.generate_recovery_codes_with_http_info(async_call=async_call, **kwargs) return data
def generate_recovery_codes_with_http_info(self, async_call=False, **kwargs): """ Generate backup recovery codes that may be used to complete complete two factor authentication. The caller needs to provide a bearer token for the session in the request body. Two factor configuration must be unlocked to use this API. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.generate_recovery_codes_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `RecoveryCodes` :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method generate_recovery_codes" % key ) params[key] = val del params['kwargs'] collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/users/generate_recovery_code', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='RecoveryCodes', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def generate_u2_f_challenge(self, async_call=False, **kwargs): """ Generate a new challenge that may be used to register U2F devices. The caller needs to provide a bearer token for the session in the request body. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `MfaChallenge` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.generate_u2_f_challenge_with_http_info(async_call=async_call, **kwargs) else: (data) = self.generate_u2_f_challenge_with_http_info(async_call=async_call, **kwargs) return data
def generate_u2_f_challenge_with_http_info(self, async_call=False, **kwargs): """ Generate a new challenge that may be used to register U2F devices. The caller needs to provide a bearer token for the session in the request body. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.generate_u2_f_challenge_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `MfaChallenge` :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method generate_u2_f_challenge" % key ) params[key] = val del params['kwargs'] collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/session/config_2fa/new_challenge', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='MfaChallenge', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def lock2_f(self, async_call=False, **kwargs): """ Lock two factor configuration after completing two factor reconfiguration. The caller needs to provide a bearer token for the session in the request body. If this API is not called, two factor configuration will be locked automatically after ten minutes. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.lock2_f_with_http_info(async_call=async_call, **kwargs) else: (data) = self.lock2_f_with_http_info(async_call=async_call, **kwargs) return data
def lock2_f_with_http_info(self, async_call=False, **kwargs): """ Lock two factor configuration after completing two factor reconfiguration. The caller needs to provide a bearer token for the session in the request body. If this API is not called, two factor configuration will be locked automatically after ten minutes. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.lock2_f_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method lock2_f" % key ) params[key] = val del params['kwargs'] collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/session/config_2fa/terminate', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)