You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/api-management/graphql-validation-policies.md
+39-22Lines changed: 39 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,14 @@ documentationcenter: ''
6
6
author: dlepow
7
7
ms.service: api-management
8
8
ms.topic: article
9
-
ms.date: 10/21/2021
9
+
ms.date: 01/21/2022
10
10
ms.author: danlep
11
11
ms.custom: ignite-fall-2021
12
12
---
13
13
14
14
# API Management policy to validate and authorize GraphQL requests (preview)
15
15
16
-
This article provides a reference for a new API Management policy to validate and authorize requests to a [GraphQL API](graphql-api.md) imported to API Management.
16
+
This article provides a reference for an API Management policy to validate and authorize requests to a [GraphQL API](graphql-api.md) imported to API Management.
17
17
18
18
For more information on adding and configuring policies, see [Policies in API Management](./api-management-policies.md).
19
19
@@ -40,34 +40,51 @@ Because GraphQL queries use a flattened schema:
40
40
* Interfaces
41
41
* The schema element
42
42
43
-
**Authorization elements**
44
-
You can use multiple authorization elements. The most specific path is used to select the appropriate authorization rule for each leaf node in the query.
45
-
* Each authorization can optionally provide a different action.
46
-
*`if` clauses allow the admin to specify conditional actions.
43
+
**Authorize element**
44
+
Configure the `authorize` element to set an appropriate authorization rule for one or more paths.
45
+
* Each rule can optionally provide a different action.
46
+
*Use policy expressions to specify conditional actions.
47
47
48
48
**Introspection system**
49
49
The policy for path=`/__*` is the [introspection](https://graphql.org/learn/introspection/) system. You can use it to reject introspection requests (`__schema`, `__type`, etc.).
50
50
51
51
### Policy statement
52
52
53
53
```xml
54
-
<validate-graphql-request error-variable-name="variable name" max-size="size in bytes"max-depth="query depth">
55
-
<authorize-path="query path, for example: /Query/list Users or /__*" action="allow|remove|reject" />
|`authorize`| Add one or more of these elements to provides field-level authorization with both request- and field-level errors. |Yes|
80
-
|`if`| Add one or more of these elements for conditional changes to the action for a field-level authorization. | No |
96
+
|`authorize`| Add this element to provide field-level authorization with both request- and field-level errors. |No|
97
+
|`rule`| Add one or more of these elements to authorize specific query paths. Each rule can optionally specify a different [action](#request-actions). | No |
81
98
82
99
### Attributes
83
100
@@ -86,19 +103,19 @@ In the following example, we validate a GraphQL query and reject:
86
103
|`error-variable-name`| Name of the variable in `context.Variables` to log validation errors to. | No | N/A |
87
104
|`max-size`| Maximum size of the request payload in bytes. Maximum allowed value: 102,400 bytes (100 KB). (Contact [support](https://azure.microsoft.com/support/options/) if you need to increase this limit.) | Yes | N/A |
88
105
|`max-depth`| An integer. Maximum query depth. | No | 6 |
89
-
|`path`| Query path to execute authorization validation on. | Yes | N/A |
90
-
|`action`|[Action](#request-actions) to perform for the matching field. May be changed if a matching condition is specified. | Yes | N/A |
91
-
|`condition`| Boolean value that determines if the [policy expression](api-management-policy-expressions.md) matches. The first matching condition is used. | No | N/A |
106
+
|`path`| Path to execute authorization validation on. It must follow the pattern: `/type/field`. | Yes | N/A |
107
+
|`action`|[Action](#request-actions) to perform if the rule applies. May be specified conditionally using a policy expression. | No | allow |
92
108
93
109
### Request actions
94
110
95
111
Available actions are described in the following table.
96
112
97
113
|Action |Description |
98
114
|---------|---------|
99
-
|`reject`| A request error happens, and the request is not sent to the back end. |
115
+
|`reject`| A request error happens, and the request is not sent to the back end. Additional rules if configured are not applied.|
100
116
|`remove`| A field error happens, and the field is removed from the request. |
101
117
|`allow`| The field is passed to the back end. |
118
+
|`ignore`| The rule is not valid for this case and the next rule is applied. |
0 commit comments