From eafb3d79e69275216539c2a5581378cea5e0a33e Mon Sep 17 00:00:00 2001 From: enisn Date: Thu, 22 Apr 2021 10:01:22 +0300 Subject: [PATCH] Docs - Add GlobalStateProviders to Authorization.md --- docs/en/Authorization.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/en/Authorization.md b/docs/en/Authorization.md index 22a88ce8cc..e44f96a034 100644 --- a/docs/en/Authorization.md +++ b/docs/en/Authorization.md @@ -285,7 +285,38 @@ See examples below: authorPermission.AddStateProviders(new MyCustomPermissionStateProvider()); ``` - Custom condition class have to implement `IPermissionStateProvider` + Custom condition class have to implement `IPermissionStateProvider`. + + - Also State Providers can be configured globally via using `GlobalStateProviders` in **AbpPermissionOptions** + + ```csharp + Configure(options => + { + options.GlobalStateProviders.Add(); + + // Or type can be pass as parameter: + options.GlobalStateProviders.Add(typeof(MyCustomPermissionStateProvider)); + }); + ``` + + Content of **MyCustomPermissionStateProvider** looks like: + + ```csharp + public class MyCustomPermissionStateProvider : IPermissionStateProvider + { + public Task IsEnabledAsync(PermissionStateContext context) + { + // You can implement your own logic here. + // That check works globally for each permission. + return Task.FromResult( + context.Permission.Name.StartsWith("Acme.BookStore")); + } + } + ``` + + + + ## IAuthorizationService