本文整理汇总了Python中okta.framework.Utils.Utils类的典型用法代码示例。如果您正苦于以下问题:Python Utils类的具体用法?Python Utils怎么用?Python Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: default
def default(self, obj):
if isinstance(obj, datetime):
return obj.strftime('dt(%Y-%m-%dT%H:%M:%SZ)')
elif isinstance(obj, object):
no_nulls = Utils.remove_nulls(obj.__dict__)
formatted = Utils.replace_alt_names(obj, no_nulls)
return formatted
else:
return JSONEncoder.default(self, obj)
示例2: enroll_factor
def enroll_factor(self, state_token, factor_type, provider, profile, relay_state=None):
"""Enroll in an MFA factor during the auth flow. Usually only encountered if MFA is required for authentication
:param state_token: current state token from the previous AuthResult
:type state_token: str
:param factor_type: type of factor (sms, token, question, token:software:totp, token:hardware etc)
:type factor_type: str
:param provider: factor provider (OKTA, RSA, SYMANTEC, GOOGLE etc)
:type provider: str
:param profile: factor profile that depends on the factor type
:type profile: FactorProfile
: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,
'factorType': factor_type,
'provider': provider,
'profile': profile,
'relayState': relay_state
}
response = ApiClient.post_path(self, '/factors', request)
return Utils.deserialize(response.text, AuthResult)
示例3: test_user_applinks_deserialization
def test_user_applinks_deserialization(self):
json_str = '''
[{
"id": "auc9pp3udhKTBhNyS0h7",
"label": "Application",
"linkUrl": "https://example.okta.com/0oa9pp3udcBnjYs3E0h7/1234",
"logoUrl": "https://example.okta.com/assets/img/logos/logo.png",
"appName": "application",
"appInstanceId": "0oa9pp3udcBnjYs3E0h7",
"appAssignmentId": "0ua9pp3udgbxdDted0h7",
"credentialsSetup": false,
"hidden": false,
"sortOrder": 0
},
{
"id": "1od6bbdxlpb1BgDTi1h7",
"label": "Another application",
"linkUrl": "https://example.okta.com/0oa9pp3udcBnjYs3E0h7/5678",
"logoUrl": "https://example.okta.com/assets/img/logos/logo.png",
"appName": "another_application",
"appInstanceId": "1od7bbdxnpb2BgDTi1h7",
"appAssignmentId": "1od7bbdxnpb2BgDTi1h7",
"credentialsSetup": true,
"hidden": true,
"sortOrder": 1
}]
'''
result = Utils.deserialize(json_str, AppLinks)
self.assertEqual(len(result), 2, "Cannot deserialize nested lists of objects")
serialized = json.dumps(result, cls=Serializer)
self.assertTrue("1od6bbdxlpb1BgDTi1h7" in serialized, "Nested lists aren't serialized properly")
示例4: authenticate
def authenticate(self, username, password,
relay_state=None, response_type=None, force_mfa=None, context=None):
"""Begin the authentication process with a username and password
:param username: user's username
:type username: str
:param password: user's password
:type password: str
:param relay_state: data that will persist for the lifetime of the authentication or recovery token
:type relay_state: str or None
:param response_type: the type of session to return (session_token or session_token_url usually)
:type response_type: str
:param force_mfa: whether to force mfa even if the auth is exempt
:type force_mfa: bool
:param context: contextual info about the auth request like ip and location
: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)
示例5: verify_factor
def verify_factor(self, user_id, user_factor_id, activation_token=None, answer=None, passcode=None, next_passcode=None):
"""Verify an enrolled factor
:param user_id: target user id
:type user_id: str
:param user_factor_id: target factor id
:type user_factor_id: str
:param activation_token: token required for activation
: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)
示例6: auth_with_factor
def auth_with_factor(self, state_token, factor_id, passcode,
relay_state=None, remember_device=None):
"""Continue authentication with an MFA attempt
: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 passcode: passcode required for authenticating the factor
:type passcode: str
:param relay_state: data that will persist for the lifetime of the authentication or recovery token
:type relay_state: str or None
:param remember_device: whether to remember this device to avoid requiring MFA next time
:type remember_device: bool
:rtype: AuthResult
"""
request = {
'stateToken': state_token,
'passCode': passcode,
'relayState': relay_state
}
params = {
'rememberDevice': remember_device
}
response = ApiClient.post_path(self, '/factors/{0}/verify'.format(factor_id),
request, params=params)
return Utils.deserialize(response.text, AuthResult)
示例7: validate_session
def validate_session(self, id):
"""Validate a session
:param id: the target session id
:rtype: Session
"""
response = ApiClient.get_path(self, '/{0}'.format(id))
return Utils.deserialize(response.text, Session)
示例8: default
def default(self, obj):
if isinstance(obj, datetime):
return obj.strftime('dt(%Y-%m-%dT%H:%M:%SZ)')
elif isinstance(obj, object):
return Utils.remove_nulls(obj.__dict__)
else:
return JSONEncoder.default(self, obj)
示例9: extend_session
def extend_session(self, id):
"""Extend a session's lifespan
:param id: the target session id
:rtype: Session
"""
response = ApiClient.put_path(self, '/{0}'.format(id), None)
return Utils.deserialize(response.text, Session)
示例10: get_user_applinks
def get_user_applinks(self, uid):
"""Get applinks of a single user
:param uid: the user id or login
:type uid: str
:rtype: AppLinks
"""
response = ApiClient.get_path(self, '/{0}/appLinks'.format(uid))
return Utils.deserialize(response.text, AppLinks)
示例11: create_app_instance
def create_app_instance(self, app_instance):
"""Create a app instance
:param app_instance: the data to create a user
:type app_instance: AppInstance
:rtype: AppInstance
"""
response = ApiClient.post_path(self, '/', app_instance)
return Utils.deserialize(response.text, AppInstance)
示例12: get_group_users
def get_group_users(self, gid):
"""Get the users of a group
:param gid: the group id
:type gid: str
:rtype: User
"""
response = ApiClient.get_path(self, '/{0}/users'.format(gid))
return Utils.deserialize(response.text, User)
示例13: unlock_user
def unlock_user(self, uid):
"""Unlock user by target id
:param uid: the target user id
:type uid: str
:return: User
"""
response = ApiClient.post_path(self, '/{0}/lifecycle/unlock'.format(uid))
return Utils.deserialize(response.text, User)
示例14: deactivate_user
def deactivate_user(self, uid):
"""Deactivate user by target id
:param uid: the target user id
:type uid: str
:return: User
"""
response = ApiClient.post_path(self, '/{0}/lifecycle/deactivate'.format(uid))
return Utils.deserialize(response.text, User)
示例15: get_available_questions
def get_available_questions(self, user_id):
"""Get available factor questions
:param user_id: target user id
:type user_id: str
:rtype: list of Question
"""
response = ApiClient.get_path(self, '/{0}/factors/questions'.format(user_id))
return Utils.deserialize(response.text, Question)