VOOZH about

URL: https://www.nuget.org/packages/DKNet.EfCore.DataAuthorization/

⇱ NuGet Gallery | DKNet.EfCore.DataAuthorization 10.0.27




👁 Image
DKNet.EfCore.DataAuthorization 10.0.27

dotnet add package DKNet.EfCore.DataAuthorization --version 10.0.27
 
 
NuGet\Install-Package DKNet.EfCore.DataAuthorization -Version 10.0.27
 
 
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="DKNet.EfCore.DataAuthorization" Version="10.0.27" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DKNet.EfCore.DataAuthorization" Version="10.0.27" />
 
Directory.Packages.props
<PackageReference Include="DKNet.EfCore.DataAuthorization" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DKNet.EfCore.DataAuthorization --version 10.0.27
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DKNet.EfCore.DataAuthorization, 10.0.27"
 
 
#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.
#:package DKNet.EfCore.DataAuthorization@10.0.27
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DKNet.EfCore.DataAuthorization&version=10.0.27
 
Install as a Cake Addin
#tool nuget:?package=DKNet.EfCore.DataAuthorization&version=10.0.27
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

DKNet.EfCore.DataAuthorization

A .NET library for secure, multi-tenant data authorization in Entity Framework Core. Enables automatic filtering of data based on ownership, supports DDD and API scenarios, and is designed for extensibility.

Features

  • Automatic global query filtering based on data ownership keys
  • Interfaces for associating entities with owners (IOwnedBy), providing ownership keys (IDataOwnerProvider), and integrating with DbContext (IDataOwnerDbContext)
  • Extension methods for easy setup via dependency injection (EfCoreDataAuthSetup)
  • Support for multi-tenancy and secure data isolation
  • .NET 9.0 compatible

Installation

Add the NuGet package to your project:

dotnet add package DKNet.EfCore.DataAuthorization

Usage

Register the data authorization provider and setup in your DI container:

using Microsoft.Extensions.DependencyInjection;
using DKNet.EfCore.DataAuthorization;

services.AddAutoDataKeyProvider<MyDbContext, MyOwnerProvider>();

Implement IOwnedBy on your entities:

public class Document : IOwnedBy
{
 public string? OwnedBy { get; private set; }
 public void SetOwnedBy(string ownerKey) => OwnedBy = ownerKey;
}

Implement IDataOwnerProvider to supply ownership keys and accessible keys:

public class MyOwnerProvider : IDataOwnerProvider
{
 public IEnumerable<string> GetAccessibleKeys() => ...; // e.g., from user context
 public string GetOwnershipKey() => ...; // e.g., current user's tenant key
}

API

  • EfCoreDataAuthSetup.AddAutoDataKeyProvider<TDbContext, TProvider>(IServiceCollection): Registers automatic data key management for a DbContext.
  • IOwnedBy: Interface for entities supporting ownership, with methods to get/set the owner key.
  • IDataOwnerProvider: Interface for providing accessible keys and ownership key for new entities.
  • IDataOwnerDbContext: Interface for DbContexts supporting data authorization, exposing accessible keys.

License

MIT © 2026 drunkcoding

Repository

https://github.com/baoduy/DKNet

Contributing

Pull requests and issues are welcome!

Product Versions Compatible and additional computed target framework versions.
.NET net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.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
10.0.27 119 5/22/2026
10.0.26 99 5/19/2026
10.0.25 153 3/27/2026
10.0.24 114 3/27/2026
10.0.23 116 3/27/2026
10.0.22 113 3/26/2026
10.0.21 159 3/17/2026
10.0.20 126 2/2/2026
10.0.19 120 1/21/2026
10.0.18 117 1/21/2026
10.0.17 122 1/19/2026
10.0.16 117 1/18/2026
10.0.15 128 1/18/2026
10.0.14 128 1/18/2026
10.0.13 129 1/17/2026
10.0.12 114 1/17/2026
10.0.11 128 1/17/2026
10.0.10 122 1/17/2026
10.0.9 125 1/16/2026
10.0.8 121 1/16/2026
Loading failed