CodeConCarne.EntityFrameworkCore.Auth
8.0.0
dotnet add package CodeConCarne.EntityFrameworkCore.Auth --version 8.0.0
NuGet\Install-Package CodeConCarne.EntityFrameworkCore.Auth -Version 8.0.0
<PackageReference Include="CodeConCarne.EntityFrameworkCore.Auth" Version="8.0.0" />
<PackageVersion Include="CodeConCarne.EntityFrameworkCore.Auth" Version="8.0.0" />
<PackageReference Include="CodeConCarne.EntityFrameworkCore.Auth" />
paket add CodeConCarne.EntityFrameworkCore.Auth --version 8.0.0
#r "nuget: CodeConCarne.EntityFrameworkCore.Auth, 8.0.0"
#:package CodeConCarne.EntityFrameworkCore.Auth@8.0.0
#addin nuget:?package=CodeConCarne.EntityFrameworkCore.Auth&version=8.0.0
#tool nuget:?package=CodeConCarne.EntityFrameworkCore.Auth&version=8.0.0
What
CodeConCarne.EntityFrameworkCore.Auth adds role-based, table-level read and write authorization to EF Core.
Why
Pushing authorization down into EF Core unburdens developers from worrying about accidental privilege escalation in complex LINQ queries. This can be considered the primary authorization mechanism in an app built on EF Core. For example, in an ASP.NET Core Web app, service and endpoint authorization with [Authorize] can be considered a secondary layer of security and a performance optimization to short-circuit requests that would be rejected in EF Core.
How
Read authorization is performed by an IQueryCompiler that analyzes queries and extracts the authentication attributes from involved entity types. EF Core caches the function returned by the compiler so this analysis is only performed once for each query that EF Core recognizes as different. Write authorization is performed by an ISaveChangesInterceptor that extracts authentication attributes from entity types found in the change tracker and internally caches the attributes for each entity type.
The application service provider must provide an IPrincipalProvider.
services.AddScoped<IPrincipalProvider, AppPrincipalProvider>();
services.AddDbContext<AppDbContext>(options =>
{
options.AddAuthorization();
...
});
Authorization attributes are applied to entity types.
[AuthorizeRead] /* requires authentication */
[AuthorizeWrite(AppRoles.FooManager)] /* requires authorization */
public class Foo
{
...
}
Limitations
Authorization is bypassed by RelationalDatabaseFacadeExtensions like ExecuteSql and RelationalQueryableExtensions like ExecuteDelete. If you use these in your application you'll need to guard them with traditional authorization mechanisms.
License
This project is licensed under the GNU Affero General Public License version 3.0 only. Commercial closed-source licensing is also available.
Contributing
To simplify licensing, bug reports and feature suggestions are preferred over code contributions. Any code contribution must include an assignment of copyright.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
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 |
|---|---|---|
| 8.0.0 | 194 | 12/24/2025 |