Skip to content

Commit 8863125

Browse files
committed
asd
1 parent 8447990 commit 8863125

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

packages/web/docs/src/content/router/security/authorization.mdx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,22 +220,22 @@ As you can see, the second group is a superset of the first and third groups, so
220220

221221
The composition process automatically simplified the merged policy by removing redundant scope groups.
222222

223-
## Authorization Rules by GraphQL Type
223+
### Usage on Interface Types
224224

225-
### Object Types
226-
Auth directives can be applied at type and field levels. Requirements are combined using AND.
225+
Auth directives **cannot be applied directly to interface definitions**. Instead, authorization rules are **inherited** from the concrete types that implement the interface. When you query an interface or its fields, the authorization check applies the combined policies from all implementing types using logical `AND`.
227226

228-
### Scalars and Enums
229-
Can have auth directives applied. When returned in a field, combined with field-level requirements.
227+
<Callout type="note">
228+
Interface authorization is computed during composition of the supergraph schema.
229+
</Callout>
230230

231-
### Interface Types
232-
Auth directives on interfaces are **disallowed**. Instead, apply directives to concrete implementing types. The effective policy for an interface is the logical `AND` of all implementing types' policies.
231+
Look at this example with an `Item` interface implemented by `Book` and `Video` types, each with its own authorization requirements:
233232

234-
```graphql
235-
# Disallowed
236-
interface Item @authenticated { ... }
233+
```graphql filename="Subgraph Schema"
234+
interface Item {
235+
id: ID!
236+
title: String
237+
}
237238
238-
# Allowed - apply to concrete types
239239
type Book implements Item @authenticated {
240240
id: ID!
241241
title: String @requiresScopes(scopes: [["book:read"]])
@@ -247,14 +247,22 @@ type Video implements Item @requiresScopes(scopes: [["video:read"]]) {
247247
}
248248
```
249249

250-
When querying the interface directly, the combined policy from all implementing types is applied.
250+
After the composition phase, the `Item` interface will have the combined authorization requirements from both `Book` and `Video`.
251+
252+
```graphql filename="Supergraph Schema"
253+
interface Item @authenticated @requiresScopes(scopes: [["video:read"]]) {
254+
id: ID!
255+
title: String @requiresScopes(scopes: [["book:read"]])
256+
}
257+
```
258+
259+
In this example, when querying items through the `Item` interface, both the `Book` and `Video` type requirements must be satisfied.
260+
261+
### Fields with `@requires`
251262

252-
### Union Types
253-
Auth directives on unions are **prohibited**. Apply directives to concrete member types instead. This aligns with federation rules and avoids ambiguity.
263+
A field using `@requires` to access fields from another entity must define an authorization policy that is a **superset** of the policies on all required fields. This prevents bypassing security policies by accessing protected fields through other fields.
254264

255-
## Field-Level Dependencies (`@requires`)
256265

257-
A field using `@requires` to access fields from another entity must define an authorization policy that is a **superset** of the policies on all required fields. This prevents bypassing security policies through federated queries.
258266

259267
## Handling Authorization Errors
260268

0 commit comments

Comments
 (0)