Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Resend an a passcode for an authentication factor
:param state_token: current state token from the previous AuthResult
:type state_token: str
:param factor_id: target factor id
:type factor_id: str
:param relay_state: data that will persist for the lifetime of the authentication or recovery token
:type relay_state: str or None
:rtype: AuthResult
"""
request = {
'stateToken': state_token,
'relayState': relay_state
}
response = ApiClient.post_path(self, '/factors/{0}/lifecycle/resend'.format(factor_id), request)
return Utils.deserialize(response.text, AuthResult)
:param state_token: current state token from the previous AuthResult
:type state_token: str
:param security_answer: answer to the user's security question
:type security_answer: str
:param relay_state: data that will persist for the lifetime of the authentication or recovery token
:type relay_state: str or None
:rtype: AuthResult
"""
request = {
'stateToken': state_token,
'securityAnswer': security_answer,
'relayState': relay_state
}
response = ApiClient.post_path(self, '/recovery/answer', request)
return Utils.deserialize(response.text, AuthResult)
def activate_app_instance(self, id):
"""Activate app by target id
:param id: the target app id
:type id: str
:return: None
"""
ApiClient.post_path(self, '/{0}/lifecycle/activate'.format(id), None)
def create_session(self, username, password, additional_fields=None):
"""Create a session
:param username: the user's username
:type username: str
:param password: the user's password
:type password: str
:param additional_fields: additional fields that will be included in the response
:type additional_fields: str
:rtype: Session
"""
creds = Credentials()
creds.username = username
creds.password = password
params = {'additionalFields': additional_fields}
response = ApiClient.post_path(self, '/', creds, params=params)
return Utils.deserialize(response.text, Session)
:type context: Context
:rtype: AuthResult
"""
request = {
'username': username,
'password': password,
'relayState': relay_state,
'context': context
}
params = {
'force_mfa': force_mfa,
'response_type': response_type
}
response = ApiClient.post_path(self, '/', request, params=params)
return Utils.deserialize(response.text, AuthResult)
def activate_user(self, uid):
"""Activate user by target id
:param uid: the target user id
:type uid: str
:return: User
"""
response = ApiClient.post_path(self, '/{0}/lifecycle/activate'.format(uid))
return Utils.deserialize(response.text, User)
:type activation_token: str
:param answer: answer usually required for a question factor
:type answer: str
:param passcode: code required for verification
:type passcode: str
:param next_passcode: code usually required for TOTP
:type next_passcode: str
:return:
"""
request = {
'activationToken': activation_token,
'answer': answer,
'passCode': passcode,
'nextPassCode': next_passcode
}
response = ApiClient.post_path(self, '/{0}/factors/{1}/verify'.format(user_id, user_factor_id), request)
return Utils.deserialize(response.text, FactorVerificationResponse)
def create_group(self, group):
"""Create a group
:param group: the data to create a group
:type group: UserGroup
:rtype: UserGroup
"""
response = ApiClient.post_path(self, '/', group)
return Utils.deserialize(response.text, UserGroup)
"""Activate a factor device for a user
:param user_id: target user id
:type user_id: str
:param user_factor_id: target factor id
:type user_factor_id: str
:param device_id: target factor device id
:type device_id: str
:param passcode: code required to activate the factor device
:type passcode: str
:rtype: FactorDevice
"""
request = {
'passCode': passcode
}
response = ApiClient.post_path(self, '/{0}/factors/{1}/devices/{2}/lifecycle/activate'.format(
user_id, user_factor_id, device_id), request)
return Utils.deserialize(response.text, Factor)