From a531cd7a47c0fa1ae6515591dedb4fcc38a3c534 Mon Sep 17 00:00:00 2001 From: Leon Hoppe Date: Fri, 22 Nov 2024 10:49:48 +0100 Subject: [PATCH] Reorganized files --- docs/Authorization.md | 48 ------------------- docs/api/authorization.md | 30 ++++++++++++ .../WebAPI.md => api/installation.md} | 4 +- docs/blazor/authorization.md | 20 ++++++++ .../Blazor.md => blazor/installation.md} | 6 +-- .../{installation/Database.md => database.md} | 0 docs/installation/README.md | 2 - 7 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 docs/Authorization.md create mode 100644 docs/api/authorization.md rename docs/{installation/WebAPI.md => api/installation.md} (61%) create mode 100644 docs/blazor/authorization.md rename docs/{installation/Blazor.md => blazor/installation.md} (72%) rename docs/{installation/Database.md => database.md} (100%) delete mode 100644 docs/installation/README.md diff --git a/docs/Authorization.md b/docs/Authorization.md deleted file mode 100644 index 312aaa1..0000000 --- a/docs/Authorization.md +++ /dev/null @@ -1,48 +0,0 @@ -# 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. - -## Usage -### Secure your endpoints -You can secure your endpoints by adding the `Authorized` attribute. - -```csharp -// Everyone can access this endpoint -[HttpGet("hello")] -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() { - return "Hello, World!"; -} -``` - -### Secure your Blazor pages -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. - -```html - - -

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

-
-``` - -```html - - -``` diff --git a/docs/api/authorization.md b/docs/api/authorization.md new file mode 100644 index 0000000..8fe422f --- /dev/null +++ b/docs/api/authorization.md @@ -0,0 +1,30 @@ +# HopFrame Authentication + +With the provided HopFrame services, you can secure your endpoints so that only logged-in users or users with the right permissions can access the endpoint. + +## Usage +You can secure your endpoints by adding the `Authorized` attribute. + +```csharp +// Everyone can access this endpoint +[HttpGet("hello")] +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() { + return "Hello, World!"; +} +``` diff --git a/docs/installation/WebAPI.md b/docs/api/installation.md similarity index 61% rename from docs/installation/WebAPI.md rename to docs/api/installation.md index 429ee5d..249bcd7 100644 --- a/docs/installation/WebAPI.md +++ b/docs/api/installation.md @@ -1,5 +1,5 @@ # Ho to use the Web API version -This Installation adds all HopFrame [endpoints](../endpoints) and [services](../services) to the application. +This Installation adds all HopFrame [endpoints](./endpoints.md) and [services](./services.md) to the application. 1. Add the HopFrame.Api library to your project: @@ -7,7 +7,7 @@ This Installation adds all HopFrame [endpoints](../endpoints) and [services](../ dotnet add package HopFrame.Api ``` -2. Create a [DbContext](./Database.md) that inherits the ``HopDbContext`` and add a data source +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/blazor/authorization.md b/docs/blazor/authorization.md new file mode 100644 index 0000000..952de9c --- /dev/null +++ b/docs/blazor/authorization.md @@ -0,0 +1,20 @@ +# HopFrame Authentication + +With the provided HopFrame services, you can secure your blazor pages so that only logged-in users or users with the right permissions can access the page. + +## Usage +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. + +```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/blazor/installation.md similarity index 72% rename from docs/installation/Blazor.md rename to docs/blazor/installation.md index d427551..91e87d7 100644 --- a/docs/installation/Blazor.md +++ b/docs/blazor/installation.md @@ -1,5 +1,5 @@ ## How to use the Blazor API -This Installation adds all HopFrame [pages](../pages) and [services](../services) to the application. +This Installation adds all HopFrame [pages](./pages.md) and [services](./services.md) to the application. 1. Add the HopFrame.Web library to your project @@ -7,7 +7,7 @@ This Installation adds all HopFrame [pages](../pages) and [services](../services dotnet add package HopFrame.Web ``` -2. Create a [DbContext](./Database.md) that inherits the ``HopDbContext`` and add a data source +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` @@ -15,7 +15,7 @@ This Installation adds all HopFrame [pages](../pages) and [services](../services builder.Services.AddHopFrame(); ``` -4. **Optional:** You can also add your [AdminContext](../admin) +4. **Optional:** You can also add your [AdminContext](./admin.md) ```csharp builder.Services.AddAdminContext(); diff --git a/docs/installation/Database.md b/docs/database.md similarity index 100% rename from docs/installation/Database.md rename to docs/database.md diff --git a/docs/installation/README.md b/docs/installation/README.md deleted file mode 100644 index 0f3cda1..0000000 --- a/docs/installation/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# HopFrame Usage -There are two different versions of HopFrame, either the [Web API](./WebAPI.md) version or the full [Blazor web version](./Blazor.md).