Valtuutus.Data.Postgres
0.7.0-beta
dotnet add package Valtuutus.Data.Postgres --version 0.7.0-beta
NuGet\Install-Package Valtuutus.Data.Postgres -Version 0.7.0-beta
<PackageReference Include="Valtuutus.Data.Postgres" Version="0.7.0-beta" />
paket add Valtuutus.Data.Postgres --version 0.7.0-beta
#r "nuget: Valtuutus.Data.Postgres, 0.7.0-beta"
// Install Valtuutus.Data.Postgres as a Cake Addin #addin nuget:?package=Valtuutus.Data.Postgres&version=0.7.0-beta&prerelease // Install Valtuutus.Data.Postgres as a Cake Tool #tool nuget:?package=Valtuutus.Data.Postgres&version=0.7.0-beta&prerelease
Valtuutus
A Google Zanzibar inspired authorization library in .NET
The implementation is inspired on permify and other ReBac open source projects.
<a href="https://bencher.dev/perf/valtuutus?key=true&reports_per_page=4&branches_per_page=8&testbeds_per_page=8&benchmarks_per_page=8&plots_per_page=8&reports_page=1&branches_page=1&testbeds_page=1&benchmarks_page=1&plots_page=1&report=f7c35e30-f513-402c-af44-56d8c876fff3&branches=9e4cbdcf-9fee-4cd3-ada1-62aefe433145&heads=5bdd1841-0a0f-4532-84b7-87ef3d065302&testbeds=072da3db-e609-4676-99a6-5b9262df6086&benchmarks=22f44ad6-7979-4757-aa00-3286de603788%2Cd0d39808-ab7a-42f9-95fb-9193853640f3%2Cd3f76a50-964b-4526-9c33-89a38c18f474%2Cb0c2d4d2-2cae-4dfd-89d2-35b49a00b23e&measures=b549a9dd-6ff0-4525-b90a-c9e3af815580&start_time=1725897568000&end_time=1728489813000&lower_boundary=false&upper_boundary=false&clear=true"><img src="https://api.bencher.dev/v0/projects/valtuutus/perf/img?branches=9e4cbdcf-9fee-4cd3-ada1-62aefe433145&heads=5bdd1841-0a0f-4532-84b7-87ef3d065302&testbeds=072da3db-e609-4676-99a6-5b9262df6086&benchmarks=22f44ad6-7979-4757-aa00-3286de603788%2Cd0d39808-ab7a-42f9-95fb-9193853640f3%2Cd3f76a50-964b-4526-9c33-89a38c18f474%2Cb0c2d4d2-2cae-4dfd-89d2-35b49a00b23e&measures=b549a9dd-6ff0-4525-b90a-c9e3af815580&start_time=1725897568000&end_time=1728489813000" title="valtuutus" alt="valtuutus - Bencher" /></a>
Functionality
The library is designed to be simple and easy to use. Each subset of functionality is divided in engines. The engines are:
- ICheckEngine: The engine that handles the answering of two questions:
Can entity U perform action Y in resource Z
? For that, use theCheck
function.What permissions entity U have in resource Z
? For that, use theSubjectPermission
function.
- ILookupSubjectEngine: The engine that can answer:
Which subjects of type T have permission Y on entity:X?
For that, use theLookup
function. - ILookupEntityEngine: The engine that can answer:
Which resources of type T can entity:X have permission Y?
For that, use theLookupEntity
function. - IDataWriterProvider: This is the provider that can write your relational or attribute data.
- IDbDataWriterProvider: Works similarly to
IDataWriterProvider
, with the addition of accepting a connection and transaction as parameters. - Read here about how the relational data is stored.
Usage
Install the package from NuGet:
If using Postgres:
dotnet add package Valtuutus.Data.Postgres
If using SqlServer:
dotnet add package Valtuutus.Data.SqlServer
If you prefer using an InMemory provider:
dotnet add package Valtuutus.Data.InMemory
Adding to DI:
builder.Services.AddValtuutusCore(c =>
...
See examples of how to define your schema here.
If using Postgres:
builder.Services
.AddPostgres(_ => () => new NpgsqlConnection(builder.Configuration.GetConnectionString("PostgresDb")!));
If using SqlServer:
builder.Services
.AddSqlServer(_ => () => new SqlConnection(builder.Configuration.GetConnectionString("SqlServerDb")!));
If using InMemory:
builder.Services
.AddInMemory();
Database migrations
If you are using a DB provider to store your data, please look at the scripts that create the tables that Valtuutus require to function.
Schema and table name customization
Our database providers allows the customization of schema and table names to your needs. When adding to dependency injection, checkout the optional parameter.
Using query concurrent limiting
It is expected that you don't want to allow Valtuutus to expand queries while it has resources. The default limit is 5 concurrent queries for the same request. To change that, you can use the AddConcurrentQueryLimit
method, for example:
builder.Services
.AddPostgres(_ => () => new NpgsqlConnection(builder.Configuration.GetConnectionString("PostgresDb")!)) // Replace this with any provider you want
.AddConcurrentQueryLimit(10);
Change your data provider according to your database.
Caching
Valtuutus supports caching the calls to the engines through the Valtuutus.Data.Caching package. To use it, install like:
dotnet add package Valtuutus.Data.Caching
In your DI setup, add the caching component:
builder.Services
.AddPostgres(_ => () => new NpgsqlConnection(builder.Configuration.GetConnectionString("PostgresDb")!)) // Replace this with any provider you want
.AddCaching(); // <-- This line
This packages requires that you set up the amazing FusionCache library. Click here for more information.
Telemetry
The library uses OpenTelemetry to provide telemetry data. To enable it, just add a source with the name "Valtuutus":
builder.Services
.AddOpenTelemetry()
.WithTracing(telemetry =>
{
telemetry
.AddSource("Valtuutus")
...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Npgsql (>= 6.0.11)
- Valtuutus.Data.Db (>= 0.7.0-beta)
-
net6.0
- Npgsql (>= 6.0.11)
- Valtuutus.Data.Db (>= 0.7.0-beta)
-
net7.0
- Npgsql (>= 6.0.11)
- Valtuutus.Data.Db (>= 0.7.0-beta)
-
net8.0
- Npgsql (>= 6.0.11)
- Valtuutus.Data.Db (>= 0.7.0-beta)
-
net9.0
- Npgsql (>= 6.0.11)
- Valtuutus.Data.Db (>= 0.7.0-beta)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.7.0-beta | 31 | 11/19/2024 |
0.6.0-beta | 52 | 10/9/2024 |
0.5.0-beta | 79 | 8/21/2024 |
0.4.0-alpha | 44 | 7/26/2024 |
0.3.0-alpha | 68 | 4/4/2024 |
0.2.0-alpha | 66 | 3/27/2024 |
0.1.0-alpha | 61 | 3/25/2024 |
Version 0.7-beta:
- dotnet 9 support
- New interface for writing with db providers