ioToggle.CoreLib 10.0.0

dotnet add package ioToggle.CoreLib --version 10.0.0
                    
NuGet\Install-Package ioToggle.CoreLib -Version 10.0.0
                    
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="ioToggle.CoreLib" Version="10.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ioToggle.CoreLib" Version="10.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ioToggle.CoreLib" />
                    
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 ioToggle.CoreLib --version 10.0.0
                    
#r "nuget: ioToggle.CoreLib, 10.0.0"
                    
#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 ioToggle.CoreLib@10.0.0
                    
#: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=ioToggle.CoreLib&version=10.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ioToggle.CoreLib&version=10.0.0
                    
Install as a Cake Tool

ioToggle.CoreLib

Shared library for ioToggle API projects. Provides base controllers, authentication/permission plumbing, Swagger filters, persistence interfaces, and core data models — so each API project only needs to implement its own domain logic.

What's included

  • Base controllersMainDbController (opens/closes IMainDb per request) and OrganizationController (resolves and validates organization_id from route + claims)
  • Ready-made endpointsaccountController (/account/login, /account/current_user, /account/logout) and organizationsController (/organizations)
  • Permission enforcement[Permissions("id")] attribute + PermissionsFilter returning HTTP 403 on failure
  • Swagger filters — automatic 401/429/500 responses, organization_uri header injection, permission descriptions
  • MiddlewareRequestResponseLoggerMiddleware for full request/response logging on 4xx/5xx
  • DB connectionsIMainDb/IDataDb PostgreSQL connection abstractions (registered as Transient)
  • Data adapters — SQL implementations for organizations, members, profiles, permissions, tenants
  • HelpersByteArrayConverter (hex instead of Base64), HexStringExtension, ClaimsPrincipal.HasPermission()

Quick start

// 1. Register DB connections
builder.Services.AddTransient<IMainDb, SqlMainDb>(provider =>
    new SqlMainDb(new SqlConnectionFactory(builder.Configuration, "maindb").CreateDbConnection()));

// 2. Register Swagger filters
builder.Services.AddSwaggerGen(c =>
{
    c.OperationFilter<Error401OperationFilter>();
    c.OperationFilter<Error429OperationFilter>();
    c.OperationFilter<Error500OperationFilter>();
    c.OperationFilter<OrganizationURIOperationFilter>();
    c.OperationFilter<PermissionsOperationFilter>();
});

// 3. Extend base controllers
[ApiController]
[Route("/{organization_uri:length(0,255)}/devices")]
[Permissions("telemetry/devices/read")]
public class devicesController : OrganizationController
{
    private IDeviceDataAdapter _adapter = default!;

    protected override async Task OnMainDbOpened()
        => _adapter = MainDb.GetDataAdapter<IDeviceDataAdapter>();

    [HttpGet]
    public async Task<IActionResult> Get() => Json(await _adapter.GetAllAsync());
}

Using with AI agents

The file docs/Implementing-API.md provides a comprehensive reference of the library's API, patterns, and usage examples specifically written to help AI coding assistants (such as GitHub Copilot, Claude, or similar tools) generate correct code when working with this library. If you are using an AI agent in your project, point it to that file.

Authors

  • Fabien Philippe - Initial work - In
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
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.0 106 4/4/2026