Rwd.IAM.Client.AspNetCore 2.0.2

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

Rwd.IAM.Client.AspNetCore

Optional helpers for ASP.NET Core on top of Rwd.IAM.Client: bearer middleware (validates JWT and sets HttpContext.User), permission filters, and minimal API extensions.


Registers IAM JWT validation once in the pipeline: reads Authorization: Bearer, calls IIamAccessTokenValidator, assigns HttpContext.User. Endpoints marked [AllowAnonymous] are skipped.

Program.cs example

using Rwd.IAM.Client.AspNetCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRwdIamAccessTokenValidation(o =>
{
    o.BaseUrl = new Uri(builder.Configuration["Iam:ApiBaseUrl"]!);
    o.IssuerUrl = new Uri(builder.Configuration["Iam:IssuerUrl"]!);
    o.RealmName = builder.Configuration["Iam:Realm"]!;
    // Central services may trust several realms:
    // o.TrustedRealmNames = ["citizens", "main", "master"];
});

builder.Services.AddIamBearerAuthentication(o =>
{
    o.Audience = builder.Configuration["Iam:ApiAudience"]; // e.g. "dms-api"; recommended
    o.AllowAnonymousWhenMissingBearer = true; // default: no Bearer → anonymous
});

builder.Services.AddControllers();
builder.Services.AddAuthorization();

var app = builder.Build();

app.UseRouting();

// After routing (so [AllowAnonymous] / endpoint metadata is visible)
app.UseIamBearerAuthentication();

app.UseAuthorization();
app.MapControllers();

app.Run();

Controller

[ApiController]
[Route("api/[controller]")]
[Authorize] // user must be authenticated (middleware set HttpContext.User)
public class DistrictsController : ControllerBase
{
    [AllowAnonymous]
    [HttpGet("public")]
    public IActionResult Public() => Ok();

    [HttpGet("secure")]
    [RequireIamPermission("districts", "view")]
    public IActionResult Secure() => Ok();
}

Order matters: UseRouting → UseIamBearerAuthentication → UseAuthorization → Map*.
If you omit AddIamBearerAuthentication(), options still default; call it when you need Audience or AllowAnonymousWhenMissingBearer.


2. MVC — [RequireIamPermission] only (no middleware)

If you already set HttpContext.User elsewhere, use the attribute alone:

[HttpGet]
[RequireIamPermission("districts", "view")]
public IActionResult List() => Ok();

Multiple attributes = AND. Alternative: [RequireIamPermission("districts:view")].


3. Minimal APIs

app.MapGet("/districts", () => Results.Ok())
   .RequireIamPermission("districts", "view");

With middleware, add RequireAuthorization() on routes that need a validated user:

app.MapGet("/districts", () => Results.Ok())
   .RequireAuthorization()
   .RequireIamPermission("districts", "view");

Packages

dotnet add package Rwd.IAM.Client
dotnet add package Rwd.IAM.Client.AspNetCore

Version both together when publishing from this repository.

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
2.0.2 111 8/30/2026
2.0.1 155 8/28/2026
2.0.0 94 8/28/2026