Valtuutus.Data.Postgres 0.4.0-alpha

This is a prerelease version of Valtuutus.Data.Postgres.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Valtuutus.Data.Postgres --version 0.4.0-alpha                
NuGet\Install-Package Valtuutus.Data.Postgres -Version 0.4.0-alpha                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Valtuutus.Data.Postgres" Version="0.4.0-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Valtuutus.Data.Postgres --version 0.4.0-alpha                
#r "nuget: Valtuutus.Data.Postgres, 0.4.0-alpha"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Valtuutus.Data.Postgres as a Cake Addin
#addin nuget:?package=Valtuutus.Data.Postgres&version=0.4.0-alpha&prerelease

// Install Valtuutus.Data.Postgres as a Cake Tool
#tool nuget:?package=Valtuutus.Data.Postgres&version=0.4.0-alpha&prerelease                

Valtuutus

A Google Zanzibar inspired authorization library in .NET

The implementation is based on the permify and other ReBac open source projects.

NuGet Version Coverage Technical Debt

Code Smells Reliability Rating Vulnerabilities Bugs

Security Rating Maintainability Rating

Functionality

The library is designed to be simple and easy to use. Each subset of functionality is divided in engines. The engines are:

  • DataEngine: The engine that handles the write and deletion of relation tuples and attributes.
    • Read here about how the relational data is stored.
  • CheckEngine: The engine that handles the answering of two questions:
    • Can entity U perform action Y in resource Z? For that, use the Check function.
    • What permissions entity U have in resource Z? For that, use the SubjectPermission function.
  • LookupSubjectEngine: The engine that can answer: Which subjects of type T have permission Y on entity:X? For that, use the Lookup function.
  • LookupEntityEngine: The engine that can answer: Which resources of type T can entity:X have permission Y? For that, use the LookupEntity function.

Usage

Install the package from NuGet:

If using Postgres:

dotnet add package Valtuutus.Data.Postgres

If using SqlServer:

dotnet add package Valtuutus.Data.SqlServer

Adding to DI:

builder.Services.AddValtuutusCore(c =>
        ... 

See examples of how to define your schema here.

If using Postgres:

builder.Services.AddValtuutusData()
    .AddPostgres(_ => () => new NpgsqlConnection(builder.Configuration.GetConnectionString("PostgresDb")!));

If using SqlServer:

builder.Services.AddValtuutusData()
    .AddSqlServer(_ => () => new SqlConnection(builder.Configuration.GetConnectionString("SqlServerDb")!));

Using check 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.AddValtuutusData()
    .AddPostgres(_ => () => new NpgsqlConnection(builder.Configuration.GetConnectionString("PostgresDb")!))
    .AddConcurrentQueryLimit(10);

Change your data provider according to your database.

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 Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 41 11/19/2024
0.6.0-beta 56 10/9/2024
0.5.0-beta 82 8/21/2024
0.4.0-alpha 49 7/26/2024
0.3.0-alpha 71 4/4/2024
0.2.0-alpha 69 3/27/2024
0.1.0-alpha 66 3/25/2024

Version 0.4-alpha:
     - Improved DI using a builder instead of an extension on top of IServiceCollection
     - Exposed InMemoryProvider for testing purposes
     - Updated dependencies
     - Sql Server columns are now NVARCHAR (to allow for unicode characters)