Skip to content

Commit

Permalink
docs: add example of how to apply policy
Browse files Browse the repository at this point in the history
  • Loading branch information
NikiforovAll committed May 6, 2024
1 parent 329333b commit 4cef3c0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/authorization/resources-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ Here is how to use to use protected resource authorization.

<<< @/../tests/Keycloak.AuthServices.IntegrationTests/AuthorizationServerPolicyTests.cs#RequireProtectedResource_Scopes_Verified{7,12-15,18 cs:line-numbers}

Here is an example of how to use registered policies:

```cs
var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/", () => "Hello World!")
.RequireAuthorization(policyName);

app.Run();
```

Here are the assertions from the integration test for this scenario:

<<< @/../tests/Keycloak.AuthServices.IntegrationTests/AuthorizationServerPolicyTests.cs#RequireProtectedResource_Scopes_Verified_Assertion
Expand Down

0 comments on commit 4cef3c0

Please sign in to comment.