Forwarding Original Client IP Addresses to Backend Applications in Auth0

Overview

Administrators can pass the original client IP address to a backend application in Auth0 by using a custom claim in the ID token. While HTTP redirects cannot forward X-Forwarded-For (XFF) headers, this custom claim allows applications to preserve or restore the original client IP address when Auth0 sends traffic back to the application servers.

Applies To

  • Auth0
  • Post-Login Actions
  • Resource Owner Password Grant (ROPG)
  • Refresh Token Exchange

Solution

How is the client IP address passed to the backend application?

Auth0 does not support inserting or forwarding X-Forwarded-For (XFF) or X-Real-IP headers via HTTP redirects when making callback requests to application servers. Instead, administrators must set a custom claim with the real client IP in the id_token to allow the application to retrieve the value.

 

Configuring the custom claim in a Post-Login Action

Create a Post-Login Action and use the request object to populate the custom claim with the client IP address.

  1. Create a Post-Login Action.
  2. Use event.request.ip to populate the value in the custom claim.

 

How are other flows configured to pass the IP address?

Configure the application to trust the token endpoint's IP header and pass the forwarded header in the token request for flows such as Resource Owner Password Grant (ROPG) or Refresh Token Exchange.

  1. Navigate to the Application dashboard and open the Credentials tab.
  2. Select Trust Token Endpoint IP Header.
  3. Pass the auth0-forwarded-for header in the calls to the token endpoint.

Recommended content

No recommended content found...