Reorganized files
This commit is contained in:
@@ -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<string> HelloWorld() {
|
|
||||||
return "Hello, World!";
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
// Only logged-in users can access this endpoint
|
|
||||||
[HttpGet("hello"), Authorized]
|
|
||||||
public ActionResult<string> 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<string> 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
|
|
||||||
<!-- You can either specify one 'Permission', multiple 'Permissions' or none if the user only needs to be logged-in -->
|
|
||||||
<AuthorizedView Permission="test.permission">
|
|
||||||
<p>This paragraph is only visible if the user is logged-in and has the required permission</p>
|
|
||||||
</AuthorizedView>
|
|
||||||
```
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!-- This component will redirect the user to the login page if the user is unauthorized -->
|
|
||||||
<AuthorizedView RedirectIfUnauthorized="/login" />
|
|
||||||
```
|
|
||||||
30
docs/api/authorization.md
Normal file
30
docs/api/authorization.md
Normal file
@@ -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<string> HelloWorld() {
|
||||||
|
return "Hello, World!";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// Only logged-in users can access this endpoint
|
||||||
|
[HttpGet("hello"), Authorized]
|
||||||
|
public ActionResult<string> 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<string> HelloWorld() {
|
||||||
|
return "Hello, World!";
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Ho to use the Web API version
|
# 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:
|
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
|
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`
|
3. Add the HopFrame services to your application, provide the previously created `DatabaseContext` that inherits from `HopDbContextBase`
|
||||||
|
|
||||||
20
docs/blazor/authorization.md
Normal file
20
docs/blazor/authorization.md
Normal file
@@ -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
|
||||||
|
<!-- You can either specify one 'Permission', multiple 'Permissions' or none if the user only needs to be logged-in -->
|
||||||
|
<AuthorizedView Permission="test.permission">
|
||||||
|
<p>This paragraph is only visible if the user is logged-in and has the required permission</p>
|
||||||
|
</AuthorizedView>
|
||||||
|
```
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- This component will redirect the user to the login page if the user is unauthorized -->
|
||||||
|
<AuthorizedView RedirectIfUnauthorized="/login" />
|
||||||
|
```
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
## How to use the Blazor API
|
## 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
|
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
|
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`
|
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<DatabaseContext>();
|
builder.Services.AddHopFrame<DatabaseContext>();
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Optional:** You can also add your [AdminContext](../admin)
|
4. **Optional:** You can also add your [AdminContext](./admin.md)
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
builder.Services.AddAdminContext<AdminContext>();
|
builder.Services.AddAdminContext<AdminContext>();
|
||||||
@@ -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).
|
|
||||||
Reference in New Issue
Block a user