Metadata API

The edge functions on Edge Firewall have access to a set of metadata that can be manipulated to:

  • Filter and manage access to your application.
  • Apply specific logic in different scenarios.

This reference documentation describes the available metadata and their usage.


GeoIP

The GeoIP metadata provides information on the geographical location of the client based on IP data.

NameDescription
geoip_asnAutonomous system number
geoip_cityCity code
geoip_city_continent_codeCity continent code information
geoip_city_country_codeCity country code
geoip_city_country_nameCity country name
geoip_continent_codeContinent code
geoip_country_codeCountry code
geoip_country_nameCountry name
geoip_regionRegion code
geoip_region_nameRegion name

Remote

The Remote metadata provides details about the remote client’s IP address and TCP port.

NameDescription
remote_addrRemote (client) IP address
remote_portRemote (client) TCP port
remote_userUser informed in the URL. Example: user in http://user@site.com/

Server

The Server metadata provides details about the protocol being used in the request.

NameDescription
server_protocolProtocol being used in the request. Example: HTTP/1.1

TLS

The TLS metadata provides details about TLS certificates.

NameDescription
ssl_cipherTLS cipher used
ssl_protocolTLS protocol used

Usage

You can access the metadata through event.request.metadata["remote_addr"], as in:

let ip = event.request.metadata["remote_addr"] // Accessing the remote address

Implementation

In the code sample below:

  • The remote address is accessed.
  • It’s verified if this address is in a network list.
  • If it’s in the network list, the request is denied.
addEventListener("firewall", (event) => {
let ip = event.request.metadata["remote_addr"] // Accessing the remote address
try {
let found = Azion.networkList.contains(String(networkListId), ip); // Checking if the ip is in the list
if (found) {
event.deny(); // If it's in the list, deny the request
}
} catch (err) {
event.console.error(`Error: `, err.stack);
}
});

Contributors