Skip to content

Commit

Permalink
[EDU-3202] feat: Fingerprint integration guide (#528)
Browse files Browse the repository at this point in the history
* feat: create EN version

* fix: description

* Apply suggestions from code review

* Update src/content/docs/en/pages/guides/marketplace/integrations/fingerprint/fingerprint.mdx

* feat: variables descriptions

* Apply suggestions from code review

* Apply suggestions from code review

* feat: pt version

* feat: refinement

* feat: JS injection

* Apply suggestions from code review

Co-authored-by: Bru Andrade <[email protected]>
Co-authored-by: Gabriel França <[email protected]>
Co-authored-by: hannah <[email protected]>

* Apply suggestions from code review

Co-authored-by: Bru Andrade <[email protected]>
Co-authored-by: hannah <[email protected]>

* Apply suggestions from code review

---------

Co-authored-by: Bru Andrade <[email protected]>
Co-authored-by: Gabriel França <[email protected]>
Co-authored-by: hannah <[email protected]>
  • Loading branch information
4 people authored Dec 8, 2023
1 parent 316cfe4 commit df6611e
Show file tree
Hide file tree
Showing 2 changed files with 316 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
title: How to install the Fingerprint integration through Azion Marketplace
description: Use this integration to capture devices and network data to better identify devices accessing your applications.
meta_tags: protection, cybersecurity, edge computing
namespace: docs_use_case_fingerprint
permalink: /documentation/products/guides/fingerprint/
---

Azion **Fingerprint** enables you to capture device and network data to better identify devices accessing your applications. It can be classified as a *Session Fingerprinting* integration and uses the collected data to generate a unique identifier and add it as a request header.

This integration includes two features:

- A **browser-level script** (optional): a [JavaScript code](#embedding-the-script) that could be added to the web page. It captures data about the browser and sets it as a session cookie named `_azfp_sc`, so this data is always sent by the browser. Even when the usage of this script is optional, it increases the precision of the integration.
- An **edge function** (mandatory): a function to capture connection-related data as well as the "frontend fingerprint" (created by the browser script), when available, to create the session fingerprint. It'll then add this fingerprint as a request header named `X-AZFP`.

---

## Embedding the script

The browser script is a JavaScript code that runs on the web page you want to fingerprint, a process also known as JavaScript injection. It captures multiple data from the web browser:

- Audio and video support
- Canvas rendering
- If the browser has access to device-level API, such as accelerometer and gyroscope
- Manufacturer's data
- Timezone
- WebGL rendering

Then, it creates a unique identifier containing all this information and sets it as a session cookie named `_azfp_sc`, as cookies are always sent in the requests made by the browser. The script checks if the session cookie already exists. If so, it won't create a new one.

Azion provides a code sample for JavaScript injection.

1. You can find the code in [this file](https://mal2u8n8zk.map.azionedge.net/274addd29ac1edb2b200a297b98581cd88465e2ee36f18cfdbdc063402063fe5.js).
2. Then, add it on your HTML source. Example:

```bash
<script src="anything.azion.xyz/arquivo.js"></script>
```

:::note
This is an optional step. However, using this script increases the precision of the **Fingerprint** integration. The code is a modularized script, in order to avoid collateral damage in any other scripts that might be running in the same web page.
:::

---

## Getting the integration

To install Azion **Fingerprint**:

1. Access [Real-Time Manager (RTM)](/en/documentation/products/guides/how-to-access-rtm/) > **Marketplace**.
2. On the Marketplace's homepage, select the integration's card.
3. Once the integration's page opens, click the **Get It Now** button, at the bottom-right corner of the page.

A successful message appears to confirm your integration is installed.

:::tip
You can search any integration by browsing through the cards or typing a keyword in the search bar.
:::

---

## Configuring the integration

### Setting up the Edge Firewall

To do so, follow the steps:

1. On the upper-left corner, select **Products menu** > **Edge Firewall** in the **SECURE** section.
2. Click the **Add Rule Set** button.
3. Give an easy-to-remember name to your new rule.
4. Select the domains you want to protect with the function.
5. Enable the **Edge Functions** switch in the **Edge Firewall Modules** section.
6. Click the **Save** button.

Done. Now you've instantiated the rule for your function and have access to edge functions on your edge firewall.

### Setting up the function

While still on the **Edge Firewall** page:

1. Select the **Functions** tab.
2. Click the **Add Function** button.
3. Give an easy-to-remember name to your instance.
4. On the dropdown menu, select the **Fingerprint** function.

This action will load the function, showing a form with the function code and, just above it, two tabs: **Code** and **Args**.

By clicking the **Code** tab, you'll be able to navigate through the source code but not to change it.

The following data is used to create the fingerprint hash:

- Autonomous System Numbers (ASN)
- Cookie `_azfp_sc`
- Geoip City Code
- Geoip Country Code
- Geoip Region Code
- Header `Accept`
- Header `Accept-CH`
- Header `Accept-Encoding`
- Header `Accept-Language`
- Header `User-Agent`
- Header `X-Forwarded-For`
- Remote Address
- SSL Cipher
- SSL Version

On the **Args** tab, you'll pass your variables. In this case, you must declare only the variables that you want the function **to ignore**, as an **array of strings**. It isn't a required action. If blank, the function will collect all the data.

```json
{
"fingerprint_ignore": []
}
```

Possible variables to be ignored in the creation of the fingerprint:

- `cookie_fingerprint`: the cookie created by the [browser script](#embedding-the-script), named `_azfp_sc`
- `header_accept`: the content types the client can understand. Example: `text/html`
- `header_accept_ch`: the client hints headers a client should include in subsequent requests. Example: `Viewport-Width, Width`
- `header_accept_encoding`: the encoding algorithms a client supports. Example: `gzip`
- `header_accept_language`: the language the client prefers. Example: `"en-US"`
- `header_user_agent`: the software and version the client uses. Example: `Chrome/51.0.2704.106`
- `geoip_asn`: the ASN associated with the device's IP. Example: `52580`
- `geoip_city`: the city associated with the device's IP. Example: `"Brasilia"`
- `geoip_country_code`: the country code associated with the device's IP. Example: `"BR"`
- `geoip_region`: the region or state associated with the device's IP. Example: `"DF"`
- `remote_addr`: the device's remote IP address. Example: `000.0.0.0`
- `ssl_cipher`: the SSL cipher used in the device's connection. Example: `"ECDHE-RSA-AES128-GCM-SHA256"`
- `ssl_protocol`: the SSL protocol used in the device's connection. Example: `"TLSv1.2"`

:::note
Any variable as `null` or blank will still be a valid value.
:::

5. When you're done, click the **Save** button.

### Setting up the Rules Engine

To finish, you have to set up a **Rules Engine** to configure the *criteria* and the *behavior* to run the function.

Still in the **Edge Firewall** page:

1. Select the **Rules Engine** tab.
2. Click the **New Rule** button.
3. Give an easy-to-remember name to the rule.
- You can add a description, but it's an optional step.
4. Select a *criteria* to run and catch the domains that you want to run the integration on.
5. Below, select a *behavior* to the *criteria*. In this case, it'll be **Run Function**.
6. Select the adequate function according to the name you gave it in the instantiate step.
7. Click the **Save** button.

Done. You now have you can collect session data by using Azion **Fingerprint**.

---

import ContributorList from '~/components/ContributorList.astro'

**Contributors** <ContributorList>Contributor</ContributorList>
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
title: Como instalar a integração Fingerprint através do Marketplace da Azion
description: Use this integration to capture session data to better identify devices accessing your applications.
meta_tags: proteção, cybersecurança, edge computing
namespace: docs_use_case_fingerprint
permalink: /documentacao/produtos/guias/fingerprint/
---

Azion **Fingerprint** permite que você capture dados de dispositivos e rede para melhor identificar os dispositivos que acessam suas aplicações. Ela pode ser classificada como uma integração de *Session Fingerprinting*, ou fingerprinting de sessão, e usa os dados coletados para gerar um identificador único e adicioná-lo como um cabeçalho de requisição.

Esta integração inclui duas funcionalidades:

- Um **script de nível de navegador** (opcional): um [código JavaScript](#embede-o-script) que pode ser adicionado à página web. Ele captura dados sobre o navegador e os define como um cookie de sessão (chamado `_azfp_sc`), então esses dados são sempre enviados pelo navegador. Mesmo quando o uso deste script é opcional, ele aumenta a precisão da integração.
- Uma **edge function** (obrigatória): uma função para capturar dados relacionados à conexão, bem como o "fingerprint do frontend" (criado pelo script do navegador), quando disponível, para criar o fingerprint da sessão. Em seguida, adicionará este fingerprint como um cabeçalho de requisição (chamado `X-AZFP`).

---

## Embede o script

O script do navegador é um código JavaScript que é executado na página da web que você deseja identificar, um processo também conhecido como injeção de JavaScript. Ele captura vários dados do navegador web:

- Suporte a áudio e vídeo
- Renderização de Canvas
- Se o navegador tem acesso à API de nível de dispositivo, como acelerômetro e giroscópio
- Dados do fabricante
- Fuso horário
- Renderização WebGL

Em seguida, ele cria um identificador único contendo todas essas informações e o define como um cookie de sessão chamado `_azfp_sc`, pois os cookies são sempre enviados nas requisições feitas pelo navegador. O script verifica se o cookie de sessão já existe. Se sim, ele não criará um novo.

Azion fornece um exemplo de código para fazer a injeção de JavaScript.

1. Você pode encontrar o código [nesse arquivo](https://mal2u8n8zk.map.azionedge.net/274addd29ac1edb2b200a297b98581cd88465e2ee36f18cfdbdc063402063fe5.js)
2. Em seguida, adicioná-lo no seu HTML fonte. Exemplo:

```bash
<script src="anything.azion.xyz/arquivo.js"></script>
```

:::note
Esse passo é opcional, mas o uso deste script aumenta a precisão da integração **Fingerprint**. O código é um script modularizado, para evitar danos colaterais em quaisquer outros scripts que possam estar sendo executados na mesma página da web.
:::

---

## Obtenha a integração

Para instalar o **Fingerprint** da Azion:

1. Accesse o [Real-Time Manager (RTM)](/pt-br/documentacao/produtos/guias/como-acessar-o-rtm/) > **Marketplace**.
2. Na página inicial do Marketplace, selecione o card da integração.
3. Quando a página da integração abrir, clique no botão **Get It Now**, no canto inferior direito da página.

Uma mensagem de sucesso aparece para confirmar que sua integração está instalada.

:::tip
Você pode pesquisar qualquer integração navegando pelos cards ou digitando uma palavra-chave na barra de pesquisa.
:::

---

## Configure a integração

### Configure o Edge Firewall

Para fazer isso, siga os passos:

1. No canto superior esquerdo, selecione **Products menu** > **Edge Firewall** na seção **SECURE**.
2. Clique no botão **Add Rule Set**.
3. Dê um nome fácil de lembrar para sua nova regra.
4. Selecione os domínios que você deseja proteger com a função.
5. Ative o switch **Edge Functions** na seção **Edge Firewall Modules**.
6. Clique no botão **Save**.

Pronto. Agora você instanciou a regra para sua função e tem acesso a edge functions no seu edge firewall.

### Configure a função

Ainda na página **Edge Firewall**:

1. Selecione a aba **Functions**.
2. Clique no botão **Add Function**.
3. Dê um nome fácil de lembrar para sua instância.
4. No menu suspenso, selecione a função **Fingerprint**.

Esta ação carregará a função, mostrando um formulário com o código da função e, logo acima dele, duas abas: **Code** e **Args**.

Ao clicar na aba **Code**, você poderá navegar pelo código-fonte, mas não poderá alterá-lo.

Os seguintes dados são usados para criar o hash de identificação:

- Autonomous System Numbers (ASN)
- Cookie `_azfp_sc`
- Geoip City Code
- Geoip Country Code
- Geoip Region Code
- Header Accept
- Header Accept-CH
- Header Accept-Encoding
- Header Accept-Language
- Header User-Agent
- Header X-Forwarded-For
- Remote Address
- SSL Cipher
- SSL Version

Na aba **Args**, você passará suas variáveis. Neste caso, você deve declarar apenas as variáveis que deseja que a função **ignore**, como um **array de strings**. Não é uma ação obrigatória. Se deixado em branco, a função coletará todos os dados.

```json
{
"fingerprint_ignore": []
}
```

Possíveis variáveis a serem ignoradas na criação do fingerprint:

- `cookie_fingerprint`: o cookie criado pelo [script do navegador](#embede-o-script), chamado `_azfp_sc`
- `header_accept`: os tipos de conteúdo que o cliente pode entender. Exemplo: `text/html`
- `header_accept_ch`: os cabeçalhos com hints do cliente que um cliente deve incluir em requisições subsequentes. Exemplo: `Viewport-Width, Width`
- `header_accept_encoding`: os algoritmos de codificação que um cliente suporta. Exemplo: `gzip`
- `header_accept_language`: o idioma preferido do cliente. Exemplo: `"en-US"`
- `header_user_agent`: o software e a versão usados pelo cliente. Exemplo: `Chrome/51.0.2704.106`
- `geoip_asn`: o ASN associado ao IP do dispositivo. Exemplo: `52580`
- `geoip_city`: a cidade associada ao IP do dispositivo. Exemplo: `"Brasilia"`
- `geoip_country_code`: o código do país associado ao IP do dispositivo. Exemplo: `"BR"`
- `geoip_region`: a região ou estado associado ao IP do dispositivo. Exemplo: `"DF"`
- `remote_addr`: o endereço IP remoto do dispositivo. Exemplo: `000.0.0.0`
- `ssl_cipher`: a cifra SSL usada na conexão do dispositivo. Exemplo: `"ECDHE-RSA-AES128-GCM-SHA256"`
- `ssl_protocol`: o protocolo SSL usado na conexão do dispositivo. Exemplo: `"TLSv1.2"`

:::note
Qualquer variável declarada como "null" ou em branco ainda será um valor válido.
:::

5. Quando terminar, clique no botão **Save**.

### Configure o Rules Engine

Para finalizar, você precisa configurar o **Rules Engine** para definir o *criteria* (critério) e o *behavior* (comportamento) para executar a função.

Ainda na página do **Edge Firewall**:

1. Selecione a aba **Rules Engine**.
2. Clique no botão **New Rule**.
3. Dê um nome fácil de lembrar para a regra.
- Você pode adicionar uma descrição, mas é um passo opcional.
4. Selecione um *criteria* para executar e capturar os domínios em que você deseja executar a integração.
5. Logo, selecione um *behavior* para o *criteria*. Neste caso, será **Run Function**.
6. Selecione a função adequada de acordo com o nome que você deu a ela na etapa de instanciação.
7. Clique no botão **Save**.

Pronto. Agora você pode coletar dados de sessão usando o **Fingerprint** da Azion.

---

import ContributorList from '~/components/ContributorList.astro'

**Contribuidores** <ContributorList>Contributor</ContributorList>

0 comments on commit df6611e

Please sign in to comment.