Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auth0-forwarded-for header to passwordless sms authentication for… #530

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Auth0.AuthenticationApi/AuthenticationApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,14 @@ public Task<AccessTokenResponse> GetTokenAsync(PasswordlessSmsTokenRequest reque
{ "audience", request.Audience },
{ "scope", request.Scope } };

var headers = String.IsNullOrEmpty(request.ForwardedForIp) ? null
: new Dictionary<string, string> { { "auth0-forwarded-for", request.ForwardedForIp } };

return connection.SendAsync<AccessTokenResponse>(
HttpMethod.Post,
tokenUri,
body,
headers,
cancellationToken: cancellationToken);
}

Expand Down Expand Up @@ -371,10 +375,14 @@ public Task<PasswordlessSmsResponse> StartPasswordlessSmsFlowAsync(PasswordlessS
phone_number = request.PhoneNumber
};

var headers = String.IsNullOrEmpty(request.ForwardedForIp) ? null
: new Dictionary<string, string> { { "auth0-forwarded-for", request.ForwardedForIp } };

return connection.SendAsync<PasswordlessSmsResponse>(
HttpMethod.Post,
BuildUri("passwordless/start"),
body,
headers,
cancellationToken: cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,14 @@ public class PasswordlessSmsRequest
/// </summary>
[JsonProperty("phone_number")]
public string PhoneNumber { get; set; }

/// <summary>
/// IP address of the end user this token is requested for for rate limit purposes.
/// </summary>
/// <remarks>
/// See https://auth0.com/docs/connections/passwordless/best-practices#link-accounts for more details.
/// </remarks>
[JsonIgnore]
public string ForwardedForIp { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ public class PasswordlessSmsTokenRequest : PasswordlessTokenRequestBase
/// Phonenumber used for the Passwordless flow
/// </summary>
public string PhoneNumber { get; set; }


/// <summary>
/// IP address of the end user this token is requested for for rate limit purposes.
/// </summary>
/// <remarks>
/// See https://auth0.com/docs/connections/passwordless/best-practices#link-accounts for more details.
/// </remarks>
public string ForwardedForIp { get; set; }

}
}