diff --git a/docs/Authorization.md b/docs/Authorization.md index 4f03292..312aaa1 100644 --- a/docs/Authorization.md +++ b/docs/Authorization.md @@ -1,6 +1,6 @@ # HopFrame Authentication -With the provided HopFrame services, you can secure your endpoints and blazor pages so that only logged-in users or users with the right permissions can access the endpoint/page +With the provided HopFrame services, you can secure your endpoints and blazor pages so that only logged-in users or users with the right permissions can access the endpoint/page. ## Usage ### Secure your endpoints @@ -12,13 +12,17 @@ You can secure your endpoints by adding the `Authorized` attribute. public ActionResult HelloWorld() { return "Hello, World!"; } +``` +```csharp // Only logged-in users can access this endpoint [HttpGet("hello"), Authorized] public ActionResult HelloWorld() { return "Hello, World!"; } +``` +```csharp // Only logged-in users with the specified permissions can access this endpoint [HttpGet("hello"), Authorized("test.permission", "test.permission.another")] public ActionResult HelloWorld() { @@ -31,12 +35,14 @@ You can secure your Blazor pages by using the `AuthorizedView` component. Everything placed inside this component will only be displayed if the authorization was successful. You can also redirect the user if the authorization fails by specifying a `RedirectIfUnauthorized` url. -```htmlinblazor +```html

This paragraph is only visible if the user is logged-in and has the required permission

+``` +```html ``` diff --git a/docs/installation/Blazor.md b/docs/installation/Blazor.md index abbe172..d427551 100644 --- a/docs/installation/Blazor.md +++ b/docs/installation/Blazor.md @@ -8,7 +8,6 @@ This Installation adds all HopFrame [pages](../pages) and [services](../services ``` 2. Create a [DbContext](./Database.md) that inherits the ``HopDbContext`` and add a data source -

 

3. Add the HopFrame services to your application, provide the previously created `DatabaseContext` that inherits from `HopDbContextBase` diff --git a/docs/installation/Database.md b/docs/installation/Database.md index 2ebef13..c695a8f 100644 --- a/docs/installation/Database.md +++ b/docs/installation/Database.md @@ -1,9 +1,10 @@ # Database initialization -You also need to initialize the data source with the tables from HopFrame +You also need to initialize the data source with the tables from HopFrame. ## Create a DbContext -1. Create a c# class that inherits from the `HopDbContextBase` and add a data source (In the example Sqlite is used) +1. Create a c# class that inherits from the `HopDbContextBase` and add a data source (In the example Sqlite is used)\ + **IMPORTANT:** You need to leave the `base.OnConfiguring(optionsBuilder)` in place so the HopFrame model relations are set correctly. ```csharp public class DatabaseContext : HopDbContextBase { @@ -14,9 +15,6 @@ You also need to initialize the data source with the tables from HopFrame } } ``` - - **IMPORTANT:** You need to leave the `base.OnConfiguring(optionsBuilder)` in place so the HopFrame model relations are set correctly. -

 

2. Register the `DatabaseContext` as a service diff --git a/docs/installation/WebAPI.md b/docs/installation/WebAPI.md index 6166db0..429ee5d 100644 --- a/docs/installation/WebAPI.md +++ b/docs/installation/WebAPI.md @@ -8,7 +8,6 @@ This Installation adds all HopFrame [endpoints](../endpoints) and [services](../ ``` 2. Create a [DbContext](./Database.md) that inherits the ``HopDbContext`` and add a data source -

 

3. Add the HopFrame services to your application, provide the previously created `DatabaseContext` that inherits from `HopDbContextBase`