Skip to content

Commit 45513c9

Browse files
Merge branch 'develop' of github.com:FusionAuth/fusionauth-python-client into lyle/ENG-3375/introspect-and-libs
2 parents 6460b3a + ca41f58 commit 45513c9

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

src/main/python/fusionauth/fusionauth_client.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,24 @@ def check_change_password_using_id(self, change_password_id):
213213
.get() \
214214
.go()
215215

216+
def check_change_password_using_id_and_ip_address(self, change_password_id, ip_address=None):
217+
"""
218+
Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
219+
When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
220+
your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
221+
222+
An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
223+
224+
Attributes:
225+
change_password_id: The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated.
226+
ip_address: (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
227+
"""
228+
return self.start_anonymous().uri('/api/user/change-password') \
229+
.url_segment(change_password_id) \
230+
.url_parameter('ipAddress', self.convert_true_false(ip_address)) \
231+
.get() \
232+
.go()
233+
216234
def check_change_password_using_jwt(self, encoded_jwt):
217235
"""
218236
Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
@@ -229,6 +247,24 @@ def check_change_password_using_jwt(self, encoded_jwt):
229247
.get() \
230248
.go()
231249

250+
def check_change_password_using_jwt_and_ip_address(self, encoded_jwt, ip_address=None):
251+
"""
252+
Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
253+
When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
254+
your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
255+
256+
An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
257+
258+
Attributes:
259+
encoded_jwt: The encoded JWT (access token).
260+
ip_address: (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
261+
"""
262+
return self.start_anonymous().uri('/api/user/change-password') \
263+
.authorization("Bearer " + encoded_jwt) \
264+
.url_parameter('ipAddress', self.convert_true_false(ip_address)) \
265+
.get() \
266+
.go()
267+
232268
def check_change_password_using_login_id(self, login_id):
233269
"""
234270
Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
@@ -245,6 +281,24 @@ def check_change_password_using_login_id(self, login_id):
245281
.get() \
246282
.go()
247283

284+
def check_change_password_using_login_id_and_ip_address(self, login_id, ip_address=None):
285+
"""
286+
Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
287+
When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
288+
your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
289+
290+
An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
291+
292+
Attributes:
293+
login_id: The loginId (email or username) of the User that you intend to change the password for.
294+
ip_address: (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
295+
"""
296+
return self.start().uri('/api/user/change-password') \
297+
.url_parameter('loginId', self.convert_true_false(login_id)) \
298+
.url_parameter('ipAddress', self.convert_true_false(ip_address)) \
299+
.get() \
300+
.go()
301+
248302
def check_change_password_using_login_id_and_login_id_types(self, login_id, login_id_types):
249303
"""
250304
Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
@@ -263,6 +317,26 @@ def check_change_password_using_login_id_and_login_id_types(self, login_id, logi
263317
.get() \
264318
.go()
265319

320+
def check_change_password_using_login_id_and_login_id_types_and_ip_address(self, login_id, login_id_types, ip_address=None):
321+
"""
322+
Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
323+
When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
324+
your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
325+
326+
An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
327+
328+
Attributes:
329+
login_id: The loginId of the User that you intend to change the password for.
330+
login_id_types: The identity types that FusionAuth will compare the loginId to.
331+
ip_address: (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
332+
"""
333+
return self.start().uri('/api/user/change-password') \
334+
.url_parameter('loginId', self.convert_true_false(login_id)) \
335+
.url_parameter('loginIdTypes', self.convert_true_false(login_id_types)) \
336+
.url_parameter('ipAddress', self.convert_true_false(ip_address)) \
337+
.get() \
338+
.go()
339+
266340
def client_credentials_grant(self, client_id=None, client_secret=None, scope=None):
267341
"""
268342
Make a Client Credentials grant request to obtain an access token.
@@ -3543,6 +3617,22 @@ def retrieve_two_factor_status(self, user_id, application_id, two_factor_trust_i
35433617
.get() \
35443618
.go()
35453619

3620+
def retrieve_two_factor_status_with_request(self, request):
3621+
"""
3622+
Retrieve a user's two-factor status.
3623+
3624+
This can be used to see if a user will need to complete a two-factor challenge to complete a login,
3625+
and optionally identify the state of the two-factor trust across various applications. This operation
3626+
provides more payload options than retrieveTwoFactorStatus.
3627+
3628+
Attributes:
3629+
request: The request object that contains all the information used to check the status.
3630+
"""
3631+
return self.start().uri('/api/two-factor/status') \
3632+
.body_handler(JSONBodyHandler(request)) \
3633+
.post() \
3634+
.go()
3635+
35463636
def retrieve_user(self, user_id):
35473637
"""
35483638
Retrieves the user for the given Id.

0 commit comments

Comments
 (0)