Skip to content

Commit c14b4d5

Browse files
guiafonso-olguigoliverMarianaReisAlcantaraLuizaVSantos
authored
[UXE-7251] method route validator guide (#1666)
* feat: add integration guide * feat: add to lists * Apply suggestions from code review Co-authored-by: MarianaReisAlcantara <mariana.alcantara@azion.com> Co-authored-by: LuizaVSantos <luiza.santos@azion.com> --------- Co-authored-by: Guilherme Afonso <profguilherme.as@gmail.com> Co-authored-by: MarianaReisAlcantara <mariana.alcantara@azion.com> Co-authored-by: LuizaVSantos <luiza.santos@azion.com>
1 parent 9b65862 commit c14b4d5

File tree

6 files changed

+331
-0
lines changed

6 files changed

+331
-0
lines changed

src/content/docs/en/pages/guides/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ permalink: /documentation/products/guides/
239239
- [How to install the JWT integration through Azion Marketplace](/en/documentation/products/guides/jwt/)
240240
- [How to install the Limit Payload Size integration through Azion Marketplace](/en/documentation/products/guides/limit-payload-size/)
241241
- [How to install the Massive Redirect integration through Azion Marketplace](/en/documentation/products/guides/massive-redirect-integration/)
242+
- [How to install the Method and Route Validator integration through Azion Marketplace](/en/documentation/products/guides/method-and-route-validator/)
242243
- [How to install the Radware Bot Manager integration through Azion Marketplace](/en/documentation/products/guides/radware-bot-manager/)
243244
- [How to install the reCaptcha integration through Azion Marketplace](/en/documentation/products/guides/recaptcha/)
244245
- [How to install the Process Request Data Into Headers integration from Azion Marketplace](/en/documentation/products/guides/process-request-data-into-headers/)
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
title: Method and Route Validator
3+
description: >-
4+
This function can be used to protect an application by blocking requests based on the URI and method used.
5+
meta_tags: API, website, security, URI, method, route, validator
6+
namespace: docs_use_case_method_and_route_validator
7+
permalink: /documentation/products/guides/method-and-route-validator/
8+
---
9+
10+
import Tag from 'primevue/tag';
11+
12+
<Tag severity="info" client:only="vue">
13+
Preview
14+
</Tag>
15+
16+
The **Method and Route Validator** integration can be used to protect your application by blocking requests based on the URI and method used. It works by validating the arguments received by the function and checking if the request matches the patterns defined in any of the values.
17+
18+
With this integration, you can define a list of routes and which method each route expects. Each time the function is executed, it'll perform the following steps:
19+
20+
1. Validate the arguments passed to the function.
21+
2. Check if the request matches the patterns defined for the routes.
22+
- If there is a match, the function will perform a user-defined blocking action.
23+
- If there is no match, the function can be configured to continue the request or block it.
24+
3. If the arguments are invalid, it'll write a log message and continue the request.
25+
26+
---
27+
28+
## Getting the integration
29+
30+
To install this integration:
31+
32+
1. Access [Azion Console](/en/documentation/products/guides/how-to-access-azion-console/) > **Marketplace**.
33+
2. On the Marketplace homepage, select the **Method and Route Validator** card.
34+
3. On the integration page, click the **Install** button.
35+
36+
You'll see a message indicating that your integration was successfully installed.
37+
38+
:::tip
39+
You can search any integration by browsing through the cards, using the filters, or typing a keyword in the search bar.
40+
:::
41+
42+
---
43+
44+
## Configuring the integration
45+
46+
Once you've installed the **Method and Route Validator** integration, you'll need to complete the steps explained below to configure it.
47+
48+
### Setting up an edge firewall
49+
50+
Follow the steps:
51+
52+
1. On the upper-left corner, open the **Products menu** and select **Edge Firewall** in the **Secure** section.
53+
2. Click the **+ Edge Firewall** button.
54+
3. Give an easy-to-remember name to your edge firewall.
55+
4. Enable the **Edge Functions** switch in the **Modules** section.
56+
- This action gives access to edge functions on your edge firewall.
57+
5. Click the **Save** button.
58+
59+
Done. Now you've instantiated the edge firewall for your function and have access to edge functions on your edge firewall.
60+
61+
:::caution[Warning]
62+
If a product or module is activated, it could generate usage-related costs. Check the [pricing page](/en/documentation/products/pricing/) for more information.
63+
:::
64+
65+
### Setting up the Edge Firewall function
66+
67+
While still on the **Edge Firewall** page:
68+
69+
1. Select the **Functions Instances** tab.
70+
2. Click the **+ Function Instance** button.
71+
3. Give an easy-to-remember name to your instance.
72+
4. On the dropdown menu, select the **Method and Route Validator** function.
73+
- This action will load the **Arguments** tab.
74+
5. In the **Arguments** tab, you'll pass the arguments for your function as in the following example:
75+
76+
```json
77+
{
78+
"restricted_mode": false,
79+
"action": "deny",
80+
"routes": [
81+
{
82+
"match_type": "equals",
83+
"path": "/my/route/",
84+
"methods": ["GET", "POST"]
85+
},
86+
{
87+
"match_type": "contains",
88+
"path": "/something/",
89+
"methods": ["POST"]
90+
},
91+
{
92+
"match_type": "regex",
93+
"path": "^.test.*",
94+
"methods": ["GET", "POST", "PATCH", "DELETE"]
95+
}
96+
]
97+
}
98+
```
99+
100+
Where:
101+
102+
| Property | Type | Required | Description |
103+
| --- | --- | --- | --- |
104+
| `restricted_mode` | Boolean | No | Indicates if the function should operate in restricted mode. Default value: `false`. |
105+
| `action` | String | Yes | Defines which action to take when the function identifies the request as invalid. |
106+
| `routes` | Array | Yes | Contains all the URIs that the protected application expects to handle. |
107+
| `routes.match_type` | String | Yes | String specifying the type of match to be performed on the path. |
108+
| `routes.path` | String | Yes | Defines the argument to be used to validate the request URI. |
109+
| `routes.methods` | Array | Yes | Array of strings specifying which methods can be used when making a request to the given path. |
110+
| `redirect_to` | String | Only when `action` is `redirect` | URL to which the request should be redirected when the `redirect` action is triggered. Can be a complete request URL or a relative path. |
111+
| `custom_response_body` | String | Only when `action` is `custom_response` | Custom response body to be sent when the `custom_response` action is triggered. |
112+
| `custom_response_status` | Number | No | Status code of the response to be sent when the `custom_response` action is triggered. Default value: `400`. |
113+
| `custom_response_content_type` | String | No | Content type of the response to be sent when the `custom_response` action is triggered. Default value: `plain/text`. |
114+
115+
:::caution
116+
If `restricted_mode` is enabled, the function will block every request whose URI does not match any of the possible routes listed in the `routes` array.
117+
:::
118+
119+
The possible values for the `action` argument are:
120+
121+
| Action | Description |
122+
| --- | --- |
123+
| `deny` | Closes the request with an HTTP 403 Forbidden response. |
124+
| `drop` | Closes the request without sending any response to the client. |
125+
| `redirect` | Redirects the request to another location. |
126+
| `custom_response` | Closes the request with a static response to it. |
127+
128+
The possible values for the `match_type` argument are:
129+
130+
| Match Type | Description |
131+
| --- | --- |
132+
| `equals` | The path must be equal to the one defined in the `path` argument. |
133+
| `contains` | The path must contain the one defined in the `path` argument. |
134+
| `regex` | The path must match the regular expression defined in the `path` argument. |
135+
136+
:::note
137+
The `routes.methods` argument expects values in uppercase. Example: `["GET", "POST"]`.
138+
:::
139+
140+
6. Click the **Save** button.
141+
142+
### Setting up the Rules Engine
143+
144+
To finish, you have to set up a rule in **Rules Engine** to configure the **criteria** and the **behavior** to run the function.
145+
146+
Still in the **Edge Firewall** page:
147+
148+
1. Select the **Rules Engine** tab.
149+
2. Click the **+ Rule Engine** button.
150+
3. Give a name to the rule.
151+
4. Select a *criteria* to run and catch the domains that you want to run the integration on.
152+
- Example: if `Host` *matches* `yourdomain.com`.
153+
5. Below, select a *behavior* to the *criteria*. In this case, it'll be **Run Function**.
154+
- Select the adequate function according to the name you gave it during the instantiation step.
155+
6. Click the **Save** button.
156+
157+
On the Console, you must now configure your domain so your edge firewall protects it.
158+
159+
7. On the **Products menu**, select **Domains**.
160+
8. Click on the domain you want to protect with your **Method and Route Validator** function.
161+
9. In the **Settings** section, click on the `Edge Firewall` selector and choose the edge firewall you created.
162+
10. Click the **Save** button.
163+
164+
Done. Now **Method and Route Validator** is running and protecting your domains.

src/content/docs/en/pages/main-menu/additional-resources/templates-and-integrations/understand-azion-integrations.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Integrations based on Edge Firewall functions cover the following scenarios and
148148
| [IP Address Reputation](/en/documentation/products/guides/ip-address-reputation/) | This integration uses a reputation score for a given IP address, provided by IPQualityScore. |
149149
| [Upstash Rate Limiting](/en/documentation/products/guides/upstash-rate-limiting-integration/) | Control incoming traffic right at the edge and protect your applications. |
150150
| [Add Request ID](/en/documentation/products/guides/add-request-id-header/) | Add an additional HTTP header in the incoming request object, assigning a unique identifier to each HTTP request attended by Azion Web Platform. |
151+
| [Method and Route Validator](/en/documentation/products/guides/method-and-route-validator/) | Control the access to your application based on the request method and path. |
151152

152153
- **Workloads and payloads**: manage incoming data sizes efficiently and prevent resource overload using these integrations.
153154

src/content/docs/pt-br/pages/guias/guides.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ permalink: /documentacao/produtos/guias/
238238
- [Como utilizar a integração JWT através do Marketplace da Azion](/pt-br/documentacao/produtos/guias/jwt/)
239239
- [Como utilizar a integração Limit Payload Size através do Marketplace da Azion](/pt-br/documentacao/produtos/guias/limit-payload-size/)
240240
- [Como utilizar a integração Massive Redirect com Azion Marketplace](/pt-br/documentacao/produtos/guias/massive-redirect-integration/)
241+
- [Como instalar a integração Method and Route Validator através do Marketplace da Azion](/pt-br/documentacao/produtos/guias/method-and-route-validator/)
241242
- [Como utilizar a integração Process Request Data Into Headers através do Marketplace da Azion](/pt-br/documentacao/produtos/guias/process-request-data-into-headers/)
242243
- [Como utilizar a integração Process Request Variation Controller através do Marketplace da Azion](/pt-br/documentacao/produtos/guias/request-variation-controller/)
243244
- [Como utilizar a integração Radware Bot Manager através do Marketplace da Azion](/pt-br/documentacao/produtos/guias/radware-bot-manager/)
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
---
2+
title: Method and Route Validator
3+
description: >-
4+
Esta função pode ser usada para proteger uma aplicação bloqueando requisições com base na URI e método utilizados.
5+
meta_tags: API, website, segurança, URI, método, rota, validador
6+
namespace: docs_use_case_method_and_route_validator
7+
permalink: /documentacao/produtos/guias/method-and-route-validator/
8+
---
9+
10+
import Tag from 'primevue/tag';
11+
12+
<Tag severity="info" client:only="vue">
13+
Preview
14+
</Tag>
15+
16+
A integração **Method and Route Validator** pode ser usada para proteger sua aplicação bloqueando requisições com base na URI e método utilizados. Ela funciona validando os argumentos e verificando se a requisição coincide com os padrões definidos em qualquer um dos valores.
17+
18+
Com essa integração, você pode definir uma lista de rotas e qual método cada rota espera. Cada vez que a função é executada, ela seguirá as seguintes etapas:
19+
20+
1. Validará os argumentos passados para a function.
21+
2. Verificará se a requisição coincide com os padrões definidos para as rotas.
22+
- Se uma correspondência for encontrada, a função executará uma ação de bloqueio especificada pelo usuário.
23+
- Se não for encontrada nenhuma correspondência, a função pode ser configurada para continuar a requisição ou bloqueá-la.
24+
3. Se os argumentos forem inválidos, ela escreverá uma mensagem de log e continuará a requisição.
25+
26+
---
27+
28+
## Obtenha a integração
29+
30+
Para instalar esta integração:
31+
32+
1. Acesse [Azion Console](/pt-br/documentacao/produtos/guias/como-acessar-o-azion-console/) > **Marketplace**.
33+
2. Na página inicial do Marketplace, selecione o cartão da **Method and Route Validator**.
34+
3. Na página de integração, clique no botão **Install**.
35+
36+
Você verá uma mensagem indicando que sua integração foi instalada com sucesso.
37+
38+
:::tip
39+
Você pode procurar qualquer integração navegando pelos cards ou digitando uma palavra-chave na barra de busca.
40+
:::
41+
42+
---
43+
44+
## Configure a integração
45+
46+
Depois de instalar a integração **Method and Route Validator**, você precisará concluir as etapas explicadas abaixo para configurá-la.
47+
48+
### Configure uma regra no Edge Firewall
49+
50+
Siga estes passos:
51+
52+
1. No canto superior esquerdo, abra o **Products menu** e selecione **Edge Firewall** na seção **Secure**.
53+
2. Clique no botão **+ Edge Firewall**.
54+
3. Dê um nome fácil de lembrar ao seu edge firewall.
55+
4. Ative a opção **Edge Functions** na seção **Edge Firewall Modules**.
56+
- Esta ação dá acesso a edge functions no edge firewall.
57+
5. Clique no botão **Save**.
58+
59+
Pronto. Agora você instanciou o edge firewall para sua função e tem acesso a edge functions em seu edge firewall.
60+
61+
:::caution[Atenção]
62+
Se um produto ou módulo estiver ativado, pode gerar custos relacionados ao uso. Consulte a [página de preços](/pt-br/documentacao/produtos/precos/) para obter mais informações.
63+
:::
64+
65+
### Configure uma função no Edge Firewall
66+
67+
Enquanto ainda estiver na página do **Edge Firewall**:
68+
69+
1. Selecione a aba **Functions Instances**.
70+
2. Clique no botão **+ Function Instance**.
71+
3. Dê um nome fácil de lembrar à sua instância.
72+
4. No menu suspenso, selecione a função **Method and Route Validator**.
73+
5. Na caixa **Arguments**, passe suas variáveis, como no exemplo:
74+
75+
```json
76+
{
77+
"restricted_mode": false,
78+
"action": "deny",
79+
"routes": [
80+
{
81+
"match_type": "equals",
82+
"path": "/my/route/",
83+
"methods": ["GET", "POST"]
84+
},
85+
{
86+
"match_type": "contains",
87+
"path": "/something/",
88+
"methods": ["POST"]
89+
},
90+
{
91+
"match_type": "regex",
92+
"path": "^.test.*",
93+
"methods": ["GET", "POST", "PATCH", "DELETE"]
94+
}
95+
]
96+
}
97+
```
98+
99+
Onde:
100+
101+
| Propriedade | Tipo | Obrigatório | Descrição |
102+
| --- | --- | --- | --- |
103+
| `restricted_mode` | Boolean | Não | Indica se a função deve operar no modo restrito. Valor padrão: `false`. |
104+
| `action` | String | Sim | Define qual ação usar quando a função identifica a requisição como inválida. |
105+
| `routes` | Array | Sim | Contém todas as URIs que a aplicação protegida espera lidar. |
106+
| `routes.match_type` | String | Sim | String que especifica o tipo de match a ser realizado no caminho. |
107+
| `routes.path` | String | Sim | Define qual argumento será usado para validar a URI da requisição. |
108+
| `routes.methods` | Array | Sim | Array de strings especificando quais métodos podem ser usados ao fazer a requisição para o caminho dado. |
109+
| `redirect_to` | String | Apenas quando `action` é `redirect` | URL para a qual a requisição deve ser redirecionada quando a ação `redirect` é acionada. Pode ser uma URL de requisição completa ou um caminho relativo. |
110+
| `custom_response_body` | String | Apenas quando `action` é `custom_response` | Corpo de resposta personalizado a ser enviado quando a ação `custom_response` é acionada. |
111+
| `custom_response_status` | Number | Não | Código de status de resposta a ser enviado quando a ação `custom_response` é acionada. Valor padrão: `400`. |
112+
| `custom_response_content_type` | String | Não | Tipo de conteúdo de resposta a ser enviado quando a ação `custom_response` é acionada. Valor padrão: `plain/text`. |
113+
114+
:::caution
115+
Se `restricted_mode` estiver habilitado, a função bloqueará toda requisição cuja URI não coincida com nenhuma das rotas possíveis listadas no array `routes`.
116+
:::
117+
118+
Os valores possíveis para o argumento `action` são:
119+
120+
| Ação | Descrição |
121+
| --- | --- |
122+
| `deny` | Fecha a requisição com uma resposta HTTP 403 Forbidden. |
123+
| `drop` | Fecha a requisição sem enviar nenhuma resposta ao cliente. |
124+
| `redirect` | Redireciona a requisição para outra localização. |
125+
| `custom_response` | Fecha a requisição com uma resposta estática a ela. |
126+
127+
Os valores possíveis para o argumento `match_type` são:
128+
129+
| Tipo de Match | Descrição |
130+
| --- | --- |
131+
| `equals` | O caminho deve ser igual ao definido no argumento `path`. |
132+
| `contains` | O caminho deve conter o definido no argumento `path`. |
133+
| `regex` | O caminho deve coincidir com a expressão regular definida no argumento `path`. |
134+
135+
:::note
136+
O argumento `routes.methods` espera valores em maiúsculas. Exemplo: `["GET", "POST"]`.
137+
:::
138+
139+
6. Clique no botão **Save**.
140+
141+
### Configure uma regra no Rules Engine
142+
143+
Para concluir, você deve configurar uma regra no **Rules Engine** para definir os critérios (*criteria*) e o comportamento (*behavior*) para executar a função.
144+
145+
Ainda na página do **Edge Firewall**:
146+
147+
1. Selecione a aba **Rules Engine**.
148+
2. Clique no botão **+ Rule Engine**.
149+
3. Dê um nome fácil de lembrar à sua nova regra.
150+
4. Selecione um *criteria* (critério) para executar a integração.
151+
- Exemplo: if `Host` *matches* `yourdomain.com`.
152+
5. Abaixo, selecione um *behavior* (comportamento) para os *criteria* (critérios). Neste caso, será **Run Function**.
153+
- Selecione a função adequada de acordo com o nome que você deu na etapa de instanciação.
154+
6. Clique no botão **Save**.
155+
156+
Agora, no Console, você deve configurar seu domínio para que ele seja protegido pelo seu Edge Firewall.
157+
158+
7. No **Products menu**, selecione **Domains**.
159+
8. Clique no domínio que você deseja proteger com sua função **Method and Route Validator**.
160+
9. Na seção **Settings**, clique no seletor de `Edge Firewall` e escolha o Edge Firewall que você acabou de criar.
161+
10. Clique no botão **Save**.
162+
163+
Pronto. Agora a integração **Method and Route Validator** está em execução.

src/content/docs/pt-br/pages/menu-principal/recursos-adicionais/templates-e-integracoes/integracoes-visao-geral.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ As integrações baseadas nas funções do Edge Application abrangem os seguinte
147147
| [IP Address Reputation](/pt-br/documentacao/produtos/guias/ip-address-reputation/) | Esta integração usa uma pontuação de reputação para um determinado endereço IP, fornecida pela IPQualityScore. |
148148
| [Upstash Rate Limiting](/pt-br/documentacao/produtos/guias/upstash-rate-limiting-integration/) | Controle o tráfego de entrada diretamente no edge da rede e proteja suas aplicações. |
149149
| [Add Request ID](/pt-br/documentacao/produtos/guias/add-request-id-header/) | Adicione um cabeçalho adicional no objeto da requisição recebida, atribuindo um identificador único a cada requisição HTTP atendida pela Azion Web Platform. |
150+
| [Method and Route Validator](/pt-br/documentacao/produtos/guias/method-and-route-validator/) | Controle o acesso à sua aplicação com base no método e no path da requisição. |
150151

151152
- **Workloads e payloads**: gerencie os tamanhos de dados recebidos com eficiência e evite a sobrecarga de recursos usando essas integrações.
152153

0 commit comments

Comments
 (0)