Skip to content

Commit

Permalink
Merge pull request #202 from aserto-dev/dotnet_docs
Browse files Browse the repository at this point in the history
Update dotnet docs
  • Loading branch information
carabasdaniel authored Sep 23, 2024
2 parents f71c2ed + caeb32b commit b407ec0
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 8 deletions.
37 changes: 37 additions & 0 deletions docs/software-development-kits/dotnet/clients.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
sidebar_label: Aserto Clients
title: Aserto SDKs - ASP.NET Clients - Installation and setup
description: Aserto SDKs - ASP.NET Clients - Installing and using the ASP.NET Clients
---

# ASP.NET Clients

Aserto package containing the Aserto Authorizer and Aserto Directory Clients.

## Overview

This package allows .NET Standard 2.0 applications to interact with the Aserto Authorizer and Directory APIs.

## Installation

[Aserto.Clients](https://www.nuget.org/packages/Aserto.Clients/) is provided as a NuGet package.

It can be installed:

- Using Package Manager:

```powershell
Install-Package Aserto.Clients
```

- Using .NET CLI

```cmd
dotnet add package Aserto.Clients
```

## Usage

In the [aserto-dotnet repository examples](https://github.com/aserto-dev/aserto-dotnet/tree/aserto_clients/examples) there are two CLI example applications that use the Aserto Clients package to interact with an Aserto Authorizer API and a Directory API respectively.

You can use [Topaz](https://www.topaz.sh/) to spin up a local instance that exposes the APIs and provided the necessary configuration information in the example's *app.config* files to test and get familiar with the package and the APIs.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
sidebar_label: ASP.NET Core
title: Aserto SDKs - ASP.NET Core middleware - Installation and setup
description: Aserto SDKs - ASP.NET Core middleware - Installing and using the ASP.NET Core middleware
title: Aserto SDKs - ASP.NET Core Aserto middleware - Installation and setup
description: Aserto SDKs - ASP.NET Core Aserto middleware - Installing and using the ASP.NET Core Aserto middleware
---

# ASP.NET Core Middleware
Expand Down Expand Up @@ -39,9 +39,8 @@ The following configuration settings are required for Aserto.AspNetCore middlewa

"Aserto": {
"AuthorizerApiKey": "YOUR_AUTHORIZER_API_KEY",
"TenantID": "YOUR_ASERTO_TENANTID",
"PolicyName": "YOUR_POLICY_NAME",
"PolicyInstanceLabel": "YOUR_POLICY_INSTANCE_LABEL",
"TenantID": "YOUR_ASERTO_TENANT_ID",
"PolicyName": "YOUR_POLICY_NAME",
"PolicyRoot": "YOUR_POLICY_ROOT"
}
```
Expand Down Expand Up @@ -452,7 +451,6 @@ Configure the Authorizer API Key, Tenant ID, Policy root and Policy Name and Ins
"AuthorizerApiKey": "YOUR_AUTHORIZER_API_KEY",
"TenantID": "YOUR_ASERTO_TENANT_ID",
"PolicyName": "YOUR_POLICY_NAME",
"PolicyInstanceLabel": "YOUR_POLICY_INSTANCE_LABEL",
"PolicyRoot": "quickstartmvc"
}
```
Expand Down
81 changes: 81 additions & 0 deletions docs/software-development-kits/dotnet/dotnetcorecheck.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
sidebar_label: ASP.NET Core Check
title: Aserto SDKs - ASP.NET Core Check Middleware - Installation and setup
description: Aserto SDKs - ASP.NET Core Check Middleware - Installing and using the ASP.NET Core Check Middleware
---

# ASP.NET Core Check Middleware (ReBAC)
In addition to the pattern described by the Aserto Middleware, in which each route is authorized by its own policy module, the check middleware can be used to implement Relation-Based Access Control (rebac) in which authorization decisions are made by checking if a given subject has the necessary permission or relation to the object being accessed.

This is achieved using the `Check` attribute of the `CheckMiddleware`.

A check call needs three pieces of information:
- The type and key of the object.
- The name of the relation or permission to look for.
- The type and key of the subject. When omitted, the subject is derived from the middleware's Identity with type "user".

## Installation

[Aserto.AspNetCore.Middleware](https://www.nuget.org/packages/Aserto.AspNetCore.Middleware/) is provided as a NuGet package.

It can be installed:

- Using Package Manager:

```powershell
Install-Package Aserto.AspNetCore.Middleware
```

- Using .NET CLI

```cmd
dotnet add package Aserto.AspNetCore.Middleware
```

## Configuration

The following configuration settings are required for Aserto.AspNetCore middleware. You can add them to your `appsettings.json`:

```json
// appsettings.json

"Aserto": {
"AuthorizerApiKey": "YOUR_AUTHORIZER_API_KEY",
"TenantID": "YOUR_ASERTO_TENANT_ID",
"PolicyName": "YOUR_POLICY_NAME",
"PolicyRoot": "YOUR_POLICY_ROOT"
}
```

These settings can be retrieved from the [Policy Settings](https://console.aserto.com/ui/policies) page of your Aserto account.

The middleware accepts the following optional parameters:

| Parameter name | Default value | Description |
| -------------- | ----------------------------------------- | ------------------------------------------------------------------------------------- |
| Enabled | true | Enables or disables Aserto Authorization. |
| ServiceUrl | `https://authorizer.prod.aserto.com:8443` | Sets the URL for the authorizer endpoint. |
| Decision | "allowed" | The decision that will be used by the middleware when creating an authorizer request. |

## Usage

To use the check middleware in the `Startup.cs` you will need to add the check options and allow the service to add the check authorization:
```
CheckOptions checkOptions = new CheckOptions();
Configuration.GetSection("Aserto").Bind(checkOptions.BaseOptions);
// Adding the check middleware
services.AddAsertoCheckAuthorization(checkOptions,
authorizerConfig =>
{
Configuration.GetSection("Aserto").Bind(authorizerConfig);
});
```

After the initialization in your controllers you can attach the check attribute to a method as show in the example bellow:
```
[HttpPost]
[Check(objectID: "resource-creators", objectType: "resource-creator", relation: "member")]
```

The [todo-dotnet-v2](https://github.com/aserto-demo/todo-dotnet-v2/tree/main) example highlights the usage of the ASP.NET Core Aserto middleware next to the ASP.NET Core Check Middleware.
35 changes: 35 additions & 0 deletions docs/software-development-kits/dotnet/middleware.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
sidebar_label: ASP.NET Framework
title: Aserto SDKs - ASP.NET middleware - Installation and setup
description: Aserto SDKs - ASP.NET middleware - Installing and using the ASP.NET middleware
---

# ASP.NET Middleware

Aserto Authorization middleware for ASP.NET Framework v4.8

## Overview

This package allows ASP.NET Framework compatible applications to use Aserto as the Authorization provider.

## Installation

[Aserto.Middleware](https://www.nuget.org/packages/Aserto.Middleware/) is provided as a NuGet package.

It can be installed:

- Using Package Manager:

```powershell
Install-Package Aserto.Middleware
```

- Using .NET CLI

```cmd
dotnet add package Aserto.Middleware
```

## Usage

In the [aserto-dotnet repository examples](https://github.com/aserto-dev/aserto-dotnet/tree/aserto_clients/examples) there's a WebAPI example built on .NET Framework v4.8 that showcases how to use the Aserto Middleware for authorization.
13 changes: 12 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,18 @@ module.exports = {
'software-development-kits/java/middleware',
],
},
'software-development-kits/dotnetcore',
{
type: 'category',
label: 'DotNet',
collapsed: true,
items: [
'software-development-kits/dotnet/clients',
'software-development-kits/dotnet/dotnetcore',
'software-development-kits/dotnet/dotnetcorecheck',
'software-development-kits/dotnet/middleware',
],

},
{
type: 'category',
label: 'Ruby',
Expand Down
2 changes: 1 addition & 1 deletion src/sdks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default [
icon: 'dotnet-core.svg',
link: 'https://dotnet.microsoft.com/apps/aspnet',
github: 'https://github.com/aserto-dev/aserto-dotnet',
docs: '/docs/software-development-kits/dotnetcore',
docs: '/docs/software-development-kits/dotnet/dotnetcore',
},
{
title: 'Ruby',
Expand Down

0 comments on commit b407ec0

Please sign in to comment.