Skip to content

Commit 4fd82c0

Browse files
authored
Merge wied03/ENG-3608/mfa-change-password (#59)
* add IP address client overload * forgot to update method names
1 parent 07c2602 commit 4fd82c0

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/main/python/fusionauth/fusionauth_client.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,24 @@ def check_change_password_using_id(self, change_password_id):
194194
.get() \
195195
.go()
196196

197+
def check_change_password_using_id_and_ip_address(self, change_password_id, ip_address=None):
198+
"""
199+
Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
200+
When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
201+
your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
202+
203+
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.
204+
205+
Attributes:
206+
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.
207+
ip_address: (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
208+
"""
209+
return self.start_anonymous().uri('/api/user/change-password') \
210+
.url_segment(change_password_id) \
211+
.url_parameter('ipAddress', self.convert_true_false(ip_address)) \
212+
.get() \
213+
.go()
214+
197215
def check_change_password_using_jwt(self, encoded_jwt):
198216
"""
199217
Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
@@ -210,6 +228,24 @@ def check_change_password_using_jwt(self, encoded_jwt):
210228
.get() \
211229
.go()
212230

231+
def check_change_password_using_jwt_and_ip_address(self, encoded_jwt, ip_address=None):
232+
"""
233+
Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
234+
When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
235+
your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
236+
237+
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.
238+
239+
Attributes:
240+
encoded_jwt: The encoded JWT (access token).
241+
ip_address: (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
242+
"""
243+
return self.start_anonymous().uri('/api/user/change-password') \
244+
.authorization("Bearer " + encoded_jwt) \
245+
.url_parameter('ipAddress', self.convert_true_false(ip_address)) \
246+
.get() \
247+
.go()
248+
213249
def check_change_password_using_login_id(self, login_id):
214250
"""
215251
Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
@@ -226,6 +262,24 @@ def check_change_password_using_login_id(self, login_id):
226262
.get() \
227263
.go()
228264

265+
def check_change_password_using_login_id_and_ip_address(self, login_id, ip_address=None):
266+
"""
267+
Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
268+
When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
269+
your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
270+
271+
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.
272+
273+
Attributes:
274+
login_id: The loginId (email or username) of the User that you intend to change the password for.
275+
ip_address: (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
276+
"""
277+
return self.start().uri('/api/user/change-password') \
278+
.url_parameter('loginId', self.convert_true_false(login_id)) \
279+
.url_parameter('ipAddress', self.convert_true_false(ip_address)) \
280+
.get() \
281+
.go()
282+
229283
def check_change_password_using_login_id_and_login_id_types(self, login_id, login_id_types):
230284
"""
231285
Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
@@ -244,6 +298,26 @@ def check_change_password_using_login_id_and_login_id_types(self, login_id, logi
244298
.get() \
245299
.go()
246300

301+
def check_change_password_using_login_id_and_login_id_types_and_ip_address(self, login_id, login_id_types, ip_address=None):
302+
"""
303+
Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
304+
When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
305+
your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
306+
307+
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.
308+
309+
Attributes:
310+
login_id: The loginId of the User that you intend to change the password for.
311+
login_id_types: The identity types that FusionAuth will compare the loginId to.
312+
ip_address: (Optional) IP address of the user changing their password. This is used for MFA risk assessment.
313+
"""
314+
return self.start().uri('/api/user/change-password') \
315+
.url_parameter('loginId', self.convert_true_false(login_id)) \
316+
.url_parameter('loginIdTypes', self.convert_true_false(login_id_types)) \
317+
.url_parameter('ipAddress', self.convert_true_false(ip_address)) \
318+
.get() \
319+
.go()
320+
247321
def client_credentials_grant(self, client_id=None, client_secret=None, scope=None):
248322
"""
249323
Make a Client Credentials grant request to obtain an access token.

0 commit comments

Comments
 (0)