diff --git a/docs/en/Authorization.md b/docs/en/Authorization.md index 888d907b59..1522fa586a 100644 --- a/docs/en/Authorization.md +++ b/docs/en/Authorization.md @@ -142,6 +142,20 @@ myGroup.AddPermission( ); ``` +#### Enable/Disable Permissions + +A permission is enabled by default. It is possible to disable a permission. A disabled permission will be prohibited for everyone. You can still check for the permission, but it will always return prohibited. + +Example definition: + +````csharp +myGroup.AddPermission("Author_Management", isEnabled: false); +```` + +You normally don't need to define a disabled permission (unless you temporary want disable a feature of your application). However, you may want to disable a permission defined in a depended module. In this way you can disable the related application functionality. See the "*Changing Permission Definitions of a Depended Module*" section below for an example usage. + +> Note: Checking an undefined permission will throw an exception while a disabled permission check simply returns prohibited (false). + #### Child Permissions A permission may have child permissions. It is especially useful when you want to create a hierarchical permission tree where a permission may have additional sub permissions which are available only if the parent permission has been granted. @@ -208,6 +222,18 @@ See [policy based authorization](https://docs.microsoft.com/en-us/aspnet/core/se A class deriving from the `PermissionDefinitionProvider` (just like the example above) can also get existing permission definitions (defined by the depended [modules](Module-Development-Basics.md)) and change their definitions. +Example: + +````csharp +context + .GetPermissionOrNull(IdentityPermissions.Roles.Delete) + .IsEnabled = false; +```` + +When you write this code inside your permission definition provider, it finds the "role deletion" permission of the [Identity Module](Modules/Identity.md) and disabled the permission, so no one can delete a role on the application. + +> Tip: It is better to check the value returned by the `GetPermissionOrNull` method since it may return null if the given permission was not defined. + ## IAuthorizationService ASP.NET Core provides the `IAuthorizationService` that can be used to check for authorization. Once you inject, you can use it in your code to conditionally control the authorization. diff --git a/docs/en/Background-Jobs-Hangfire.md b/docs/en/Background-Jobs-Hangfire.md index 622558ac68..3a98fed66e 100644 --- a/docs/en/Background-Jobs-Hangfire.md +++ b/docs/en/Background-Jobs-Hangfire.md @@ -39,20 +39,20 @@ public class YourModule : AbpModule ```` ## Configuration + You can install any storage for Hangfire. The most common one is SQL Server (see the [Hangfire.SqlServer](https://www.nuget.org/packages/Hangfire.SqlServer) NuGet package). After you have installed these NuGet packages, you need to configure your project to use Hangfire. 1.First, we change the `Module` class (example: `HttpApiHostModule`) to add Hangfire configuration of the storage and connection string in the `ConfigureServices` method: - ````csharp public override void ConfigureServices(ServiceConfigurationContext context) { var configuration = context.Services.GetConfiguration(); var hostingEnvironment = context.Services.GetHostingEnvironment(); - //... other configarations + //... other configarations. ConfigureHangfire(context, configuration); } diff --git a/docs/en/UI/Angular/Content-Security-Strategy.md b/docs/en/UI/Angular/Content-Security-Strategy.md index 344aaf2a6e..f32317c9ca 100644 --- a/docs/en/UI/Angular/Content-Security-Strategy.md +++ b/docs/en/UI/Angular/Content-Security-Strategy.md @@ -8,12 +8,20 @@ ## API -### constructor(public nonce?: string) +### constructor + +```js +constructor(public nonce?: string) +``` - `nonce` enables whitelisting inline script or styles in order to avoid using `unsafe-inline` in [script-src](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script) and [style-src](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src#Unsafe_inline_styles) directives. -### applyCSP(element: HTMLScriptElement | HTMLStyleElement): void +### applyCSP + +```js +applyCSP(element: HTMLScriptElement | HTMLStyleElement): void +``` This method maps the aforementioned properties to the given `element`. @@ -39,18 +47,28 @@ This method maps the aforementioned properties to the given `element`. Predefined content security strategies are accessible via `CONTENT_SECURITY_STRATEGY` constant. -### Loose(nonce: string) +### Loose + +```js +CONTENT_SECURITY_STRATEGY.Loose(nonce: string) +``` `nonce` will be set. -### None() +### None + +```js +CONTENT_SECURITY_STRATEGY.None() +``` Nothing will be done. -## What's Next? +## See Also + +- [DomInsertionService](./Dom-Insertion-Service.md) +- [ContentStrategy](./Content-Strategy.md) -TODO: Place new ContentStrategy link here. diff --git a/docs/en/UI/Angular/Content-Strategy.md b/docs/en/UI/Angular/Content-Strategy.md new file mode 100644 index 0000000000..8544042c32 --- /dev/null +++ b/docs/en/UI/Angular/Content-Strategy.md @@ -0,0 +1,95 @@ +# ContentStrategy + +`ContentStrategy` is an abstract class exposed by @abp/ng.core package. It helps you create inline scripts or styles. + +## API + + +### constructor + +```js +constructor( + public content: string, + protected domStrategy?: DomStrategy, + protected contentSecurityStrategy?: ContentSecurityStrategy +) +``` + +- `content` is set to `` element will place at the **end** of ``. + +Please refer to [ContentStrategy](./Content-Strategy.md) to see all available content strategies and how you can build your own content strategy. + + +### How to Insert Styles + +If you pass a `StyleContentStrategy` instance as the first parameter of `insertContent` method, the `DomInsertionService` will create a `` element will place at the **end** of ``. + +Please refer to [ContentStrategy](./Content-Strategy.md) to see all available content strategies and how you can build your own content strategy. + + +## API + +### insertContent + +```js +insertContent(strategy: ContentStrategy): void +``` + +`strategy` parameter is the primary focus here and is explained above. + + +## What's Next? + +- [TrackByService](./Track-By-Service.md) diff --git a/docs/en/UI/Angular/Dom-Strategy.md b/docs/en/UI/Angular/Dom-Strategy.md index 1b5fb1011a..2318e13205 100644 --- a/docs/en/UI/Angular/Dom-Strategy.md +++ b/docs/en/UI/Angular/Dom-Strategy.md @@ -6,16 +6,26 @@ ## API -### constructor(public target?: HTMLElement, public position?: InsertPosition) +### constructor + +```js +constructor( + public target?: HTMLElement, + public position?: InsertPosition +) +``` - `target` is an HTMLElement (_default: document.head_). - `position` defines where the created element will be placed. All possible values of `position` can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentElement) (_default: 'beforeend'_). -### insertElement(element: HTMLElement): void +### insertElement -This method inserts given `element` to `target` based on the `position`. +```js +insertElement(element: HTMLElement): void +``` +This method inserts given `element` to `target` based on the `position`. @@ -24,35 +34,56 @@ This method inserts given `element` to `target` based on the `position`. Predefined dom strategies are accessible via `DOM_STRATEGY` constant. -### AppendToBody() +### AppendToBody + +```js +DOM_STRATEGY.AppendToBody() +``` `insertElement` will place the given `element` at the end of ``. -### AppendToHead() +### AppendToHead + +```js +DOM_STRATEGY.AppendToHead() +``` `insertElement` will place the given `element` at the end of ``. -### PrependToHead() +### PrependToHead + +```js +DOM_STRATEGY.PrependToHead() +``` `insertElement` will place the given `element` at the beginning of ``. -### AfterElement(target: HTMLElement) +### AfterElement + +```js +DOM_STRATEGY.AfterElement(target: HTMLElement) +``` `insertElement` will place the given `element` after (as a sibling to) the `target`. -### BeforeElement(target: HTMLElement) +### BeforeElement + +```js +DOM_STRATEGY.BeforeElement(target: HTMLElement) +``` `insertElement` will place the given `element` before (as a sibling to) the `target`. -## What's Next? +## See Also +- [DomInsertionService](./Dom-Insertion-Service.md) +- [LazyLoadService](./Lazy-Load-Service.md) - [LoadingStrategy](./Loading-Strategy.md) - -TODO: Place new InsertionStrategy link here. +- [ContentStrategy](./Content-Strategy.md) diff --git a/docs/en/UI/Angular/Lazy-Load-Service.md b/docs/en/UI/Angular/Lazy-Load-Service.md index f165075c8f..a03381869e 100644 --- a/docs/en/UI/Angular/Lazy-Load-Service.md +++ b/docs/en/UI/Angular/Lazy-Load-Service.md @@ -185,13 +185,21 @@ In this example, the second file needs the first one to be loaded beforehand. Rx -### loaded: Set +### loaded + +```js +loaded: Set +``` All previously loaded paths are available via this property. It is a simple [JavaScript Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set). -### load(strategy: LoadingStrategy, retryTimes?: number, retryDelay?: number): Observable +### load + +```js +load(strategy: LoadingStrategy, retryTimes?: number, retryDelay?: number): Observable +``` - `strategy` parameter is the primary focus here and is explained above. - `retryTimes` defines how many times the loading will be tried again before fail (_default: 2_). @@ -202,4 +210,4 @@ All previously loaded paths are available via this property. It is a simple [Jav ## What's Next? -- [TrackByService](./Track-By-Service.md) +- [DomInsertionService](./Dom-Insertion-Service.md) diff --git a/docs/en/UI/Angular/Loading-Strategy.md b/docs/en/UI/Angular/Loading-Strategy.md index 8fb7b68a45..1a7e7b362f 100644 --- a/docs/en/UI/Angular/Loading-Strategy.md +++ b/docs/en/UI/Angular/Loading-Strategy.md @@ -7,8 +7,15 @@ ## API +### constructor -### constructor(public path: string, protected domStrategy?: DomStrategy, protected crossOriginStrategy?: CrossOriginStrategy) +```js +constructor( + public path: string, + protected domStrategy?: DomStrategy, + protected crossOriginStrategy?: CrossOriginStrategy +) +``` - `path` is set to `