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: README.md
+33-23Lines changed: 33 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,18 @@
1
1
# GraphQL Authorization
2
2
3
-
[](https://gitter.im/graphql-dotnet/graphql-dotnet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
A toolset for authorizing access to graph types for [GraphQL.NET](https://github.com/graphql-dotnet/graphql-dotnet).
21
17
22
18
Provides the following packages:
@@ -30,47 +26,61 @@ Note that GitHub requires authentication to consume the feed. See [here](https:/
30
26
31
27
# Usage
32
28
33
-
- Register the authorization classes in your DI container - `IAuthorizationEvaluator`, `AuthorizationSettings`, and the `AuthorizationValidationRule`.
34
-
- Provide a custom `UserContext` class that implements `IProvideClaimsPrincipal`.
29
+
- Register the authorization classes in your DI container - call `AddAuthorization` on the provided `IGraphQLBuilder` inside `AddGraphQL` extension method.
30
+
- Provide the `ClaimsPrincipal` through `ExecutionOptions.User`.
35
31
- Add policies to the `AuthorizationSettings`.
36
-
- Apply a policy to a GraphType or Field (both implement `IProvideMetadata`):
37
-
- using `AuthorizeWith(string policy)` extension method
38
-
- or with `GraphQLAuthorize` attribute if using Schema + Handler syntax.
32
+
- Apply a policy to a GraphType or Field - both implement `IProvideMetadata`:
33
+
- using `AuthorizeWithPolicy(string policy)` extension method
34
+
- or with `AuthorizeAttribute` attribute if using Schema + Handler syntax.
39
35
- The `AuthorizationValidationRule` will run and verify the policies based on the registered policies.
40
36
- You can write your own `IAuthorizationRequirement`.
41
37
38
+
# Limitations
39
+
40
+
`@skip` and `@include` directives are ignored; all selected fields of the selected operation will
41
+
be checked for authentication requirements, including referenced fragments. (Other operations
42
+
in the same document will correctly be skipped.)
43
+
44
+
This authorization framework only supports policy-based authorization. It does not support role-based authorization, or the
45
+
`[AllowAnonymous]` attribute/extension, or the `[Authorize]` attribute/extension indicating authorization is required
46
+
but without specifying a policy. It also does not integrate with ASP.NET Core's authorization framework.
47
+
48
+
The [GraphQL.Server](https://www.github.com/graphql-dotnet/server) repository contains an authorization rule which has the above
49
+
missing features, intended for use with ASP.NET Core. It may also be tailored with custom authentication code if desired, rather than
50
+
relying on ASP.NET Core's authentication framework.
0 commit comments