Sondor.Authorization 1.0.8

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

Sondor Authorization

The Sondor Authorization package provides a simplified way to set up .NET Core authorization and authentication using Microsoft Identity Web and JWT Bearer tokens. It is designed for easy integration with ASP.NET Core applications, supporting multi-tenant scenarios and secure API access.

Features

  • Plug-and-play JWT Bearer authentication for ASP.NET Core.
  • Integration with Microsoft Identity Web.
  • Centralized configuration via SondorAuthorizationOptions.
  • Customizable error handling and translation support.
  • Validation for required authorization options.

Installation

Install via NuGet Package Manager:

Install-Package Sondor.Authorization

Or via .NET CLI:

dotnet add package Sondor.Authorization

Configuration

Add the following section to your appsettings.json (or any configuration source):

"SondorAuthorizationOptions": {
	"TenantId": "<your-tenant-id>",
	"ClientId": "<your-client-id>",
	"ClientSecret": "<your-client-secret>",
	"Instance": "https://login.microsoftonline.com/"
}

Usage

1. Register Authorization in Startup

In your Program.cs or Startup.cs, register Sondor Authorization:

using Sondor.Authorization;

var builder = WebApplication.CreateBuilder(args);

// Add Sondor Authorization
builder.Services.AddSondorAuthorization();
var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();

app.MapControllers();

app.Run();

You can specify a custom configuration section name if needed:

builder.Services.AddSondorAuthorization("Custom:Authorization");

2. Protect Endpoints

Use standard ASP.NET Core [Authorize] attributes to protect your controllers or actions:

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("[controller]")]
public class SecureController : ControllerBase
{
	[Authorize]
	[HttpGet]
	public IActionResult GetSecret() {
		return Ok("This is a protected resource.");
	}
}

SondorAuthorizationOptions

The following options must be configured:

Property Description Example Value
TenantId Azure AD Tenant ID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ClientId Azure AD Application Client ID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ClientSecret Azure AD Application Secret your-client-secret
Instance Authority Instance URL https://login.microsoftonline.com/

Validation is performed to ensure all fields are present and correctly formatted.

Error Handling

Custom exceptions are thrown for authentication and authorization failures:

  • UnauthorisedException for failed authentication.
  • ForbiddenException for forbidden access.

Translations for error messages are supported via ISondorTranslationManager.

Testing

For unit/integration testing, use the provided helper:

builder.Services.AddTestSondorAuthorizationOptions();

This registers mock options and configuration for test scenarios.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please submit issues or pull requests via the repository.

Support

For questions or support, contact Sondor Dev or open an issue in the repository.


Example: Minimal API Setup

var builder = WebApplication.CreateBuilder(args); builder.Services.AddSondorAuthorization();
var app = builder.Build(); app.UseAuthentication(); app.UseAuthorization();

app.MapGet("/secure", [Authorize] () => "Protected data");
app.Run();
Product 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 is compatible.  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. 
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
1.0.8 244 11/7/2025
1.0.7 282 10/15/2025
1.0.6 254 10/6/2025
1.0.5 171 10/4/2025
1.0.4 180 10/4/2025
1.0.3 200 10/3/2025
1.0.2 272 9/20/2025
1.0.1 248 9/20/2025
1.0.0 231 8/19/2025

The initial release.