From 63a0052bb9b982d9e24ce31f358b595530d2ce82 Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Wed, 11 Jun 2025 08:32:14 -0600 Subject: [PATCH 1/4] rate limiting config change for pwless send phone --- pkg/fusionauth/Domain.go | 20 +------------------- pkg/fusionauth/Domain_dynamic_test.go | 7 ------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/pkg/fusionauth/Domain.go b/pkg/fusionauth/Domain.go index 2679450..9298e30 100644 --- a/pkg/fusionauth/Domain.go +++ b/pkg/fusionauth/Domain.go @@ -5067,25 +5067,6 @@ type RateLimitedRequestConfiguration struct { TimePeriodInSeconds int `json:"timePeriodInSeconds,omitempty"` } -/** - * @author Daniel DeGroff - */ -type RateLimitedRequestType string - -func (e RateLimitedRequestType) String() string { - return string(e) -} - -const ( - RateLimitedRequestType_FailedLogin RateLimitedRequestType = "FailedLogin" - RateLimitedRequestType_ForgotPassword RateLimitedRequestType = "ForgotPassword" - RateLimitedRequestType_SendEmailVerification RateLimitedRequestType = "SendEmailVerification" - RateLimitedRequestType_SendPasswordless RateLimitedRequestType = "SendPasswordless" - RateLimitedRequestType_SendRegistrationVerification RateLimitedRequestType = "SendRegistrationVerification" - RateLimitedRequestType_SendTwoFactor RateLimitedRequestType = "SendTwoFactor" - RateLimitedRequestType_SendPhoneVerification RateLimitedRequestType = "SendPhoneVerification" -) - /** * Raw login information for each time a user logs into an application. * @@ -6154,6 +6135,7 @@ type TenantRateLimitConfiguration struct { ForgotPassword RateLimitedRequestConfiguration `json:"forgotPassword,omitempty"` SendEmailVerification RateLimitedRequestConfiguration `json:"sendEmailVerification,omitempty"` SendPasswordless RateLimitedRequestConfiguration `json:"sendPasswordless,omitempty"` + SendPasswordlessPhone RateLimitedRequestConfiguration `json:"sendPasswordlessPhone,omitempty"` SendPhoneVerification RateLimitedRequestConfiguration `json:"sendPhoneVerification,omitempty"` SendRegistrationVerification RateLimitedRequestConfiguration `json:"sendRegistrationVerification,omitempty"` SendTwoFactor RateLimitedRequestConfiguration `json:"sendTwoFactor,omitempty"` diff --git a/pkg/fusionauth/Domain_dynamic_test.go b/pkg/fusionauth/Domain_dynamic_test.go index 9a97ff0..206a3d0 100644 --- a/pkg/fusionauth/Domain_dynamic_test.go +++ b/pkg/fusionauth/Domain_dynamic_test.go @@ -462,13 +462,6 @@ func Test_PublicKeyCredentialTypeImplementsStringer(t *testing.T) { } } -func Test_RateLimitedRequestTypeImplementsStringer(t *testing.T) { - var enum interface{} = RateLimitedRequestType("Test") - if _, ok := enum.(fmt.Stringer); !ok { - t.Errorf("RateLimitedRequestType does not implement stringer interface\n") - } -} - func Test_ReactorFeatureStatusImplementsStringer(t *testing.T) { var enum interface{} = ReactorFeatureStatus("Test") if _, ok := enum.(fmt.Stringer); !ok { From 7d5da8b5ae5d5363d5e3969dbb8e4bc64aabde3e Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Thu, 12 Jun 2025 11:21:02 -0600 Subject: [PATCH 2/4] client update --- pkg/fusionauth/Domain.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/fusionauth/Domain.go b/pkg/fusionauth/Domain.go index 9298e30..cf191bc 100644 --- a/pkg/fusionauth/Domain.go +++ b/pkg/fusionauth/Domain.go @@ -6135,7 +6135,6 @@ type TenantRateLimitConfiguration struct { ForgotPassword RateLimitedRequestConfiguration `json:"forgotPassword,omitempty"` SendEmailVerification RateLimitedRequestConfiguration `json:"sendEmailVerification,omitempty"` SendPasswordless RateLimitedRequestConfiguration `json:"sendPasswordless,omitempty"` - SendPasswordlessPhone RateLimitedRequestConfiguration `json:"sendPasswordlessPhone,omitempty"` SendPhoneVerification RateLimitedRequestConfiguration `json:"sendPhoneVerification,omitempty"` SendRegistrationVerification RateLimitedRequestConfiguration `json:"sendRegistrationVerification,omitempty"` SendTwoFactor RateLimitedRequestConfiguration `json:"sendTwoFactor,omitempty"` From a19746ebb310ea36816fc2dcfa52b41793ee5def Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Thu, 12 Jun 2025 11:23:39 -0600 Subject: [PATCH 3/4] wrong branch, another client update --- pkg/fusionauth/Domain.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/fusionauth/Domain.go b/pkg/fusionauth/Domain.go index cf191bc..9298e30 100644 --- a/pkg/fusionauth/Domain.go +++ b/pkg/fusionauth/Domain.go @@ -6135,6 +6135,7 @@ type TenantRateLimitConfiguration struct { ForgotPassword RateLimitedRequestConfiguration `json:"forgotPassword,omitempty"` SendEmailVerification RateLimitedRequestConfiguration `json:"sendEmailVerification,omitempty"` SendPasswordless RateLimitedRequestConfiguration `json:"sendPasswordless,omitempty"` + SendPasswordlessPhone RateLimitedRequestConfiguration `json:"sendPasswordlessPhone,omitempty"` SendPhoneVerification RateLimitedRequestConfiguration `json:"sendPhoneVerification,omitempty"` SendRegistrationVerification RateLimitedRequestConfiguration `json:"sendRegistrationVerification,omitempty"` SendTwoFactor RateLimitedRequestConfiguration `json:"sendTwoFactor,omitempty"` From 8d09d6928d81d1ba5e10837688f7c17104fd8991 Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Thu, 12 Jun 2025 17:00:48 -0600 Subject: [PATCH 4/4] updated stuff from issue 1 branch --- pkg/fusionauth/Client.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pkg/fusionauth/Client.go b/pkg/fusionauth/Client.go index f8913d0..fe1145c 100644 --- a/pkg/fusionauth/Client.go +++ b/pkg/fusionauth/Client.go @@ -375,6 +375,42 @@ func (c *FusionAuthClient) ChangePasswordWithContext(ctx context.Context, change return &resp, &errors, err } +// ChangePasswordByJWT +// Changes a user's password using their access token (JWT) instead of the changePasswordId +// A common use case for this method will be if you want to allow the user to change their own password. +// +// Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword. +// +// string encodedJWT The encoded JWT (access token). +// ChangePasswordRequest request The change password request that contains all the information used to change the password. +func (c *FusionAuthClient) ChangePasswordByJWT(encodedJWT string, request ChangePasswordRequest) (*ChangePasswordResponse, *Errors, error) { + return c.ChangePasswordByJWTWithContext(context.TODO(), encodedJWT, request) +} + +// ChangePasswordByJWTWithContext +// Changes a user's password using their access token (JWT) instead of the changePasswordId +// A common use case for this method will be if you want to allow the user to change their own password. +// +// Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword. +// +// string encodedJWT The encoded JWT (access token). +// ChangePasswordRequest request The change password request that contains all the information used to change the password. +func (c *FusionAuthClient) ChangePasswordByJWTWithContext(ctx context.Context, encodedJWT string, request ChangePasswordRequest) (*ChangePasswordResponse, *Errors, error) { + var resp ChangePasswordResponse + var errors Errors + + restClient := c.StartAnonymous(&resp, &errors) + err := restClient.WithUri("/api/user/change-password"). + WithAuthorization("Bearer " + encodedJWT). + WithJSONBody(request). + WithMethod(http.MethodPost). + Do(ctx) + if restClient.ErrorRef == nil { + return &resp, nil, err + } + return &resp, &errors, err +} + // ChangePasswordByIdentity // Changes a user's password using their identity (loginId and password). Using a loginId instead of the changePasswordId // bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword