LumoAuth.AspNetCore
1.6.0
dotnet add package LumoAuth.AspNetCore --version 1.6.0
NuGet\Install-Package LumoAuth.AspNetCore -Version 1.6.0
<PackageReference Include="LumoAuth.AspNetCore" Version="1.6.0" />
<PackageVersion Include="LumoAuth.AspNetCore" Version="1.6.0" />
<PackageReference Include="LumoAuth.AspNetCore" />
paket add LumoAuth.AspNetCore --version 1.6.0
#r "nuget: LumoAuth.AspNetCore, 1.6.0"
#:package LumoAuth.AspNetCore@1.6.0
#addin nuget:?package=LumoAuth.AspNetCore&version=1.6.0
#tool nuget:?package=LumoAuth.AspNetCore&version=1.6.0
LumoAuth.AspNetCore
LumoAuth for ASP.NET Core 8 and newer. The package registers the LumoAuth SDK as services and connects it to ASP.NET Core:
- Dependency injection from
appsettings.jsonandLUMOAUTH_*environment variables. - A bearer authentication scheme that turns LumoAuth access tokens into a
ClaimsPrincipal. - OpenID Connect sign-in with a cookie session, for web apps.
- Authorization with
[RequirePermission],[RequireRelation]and[RequireAbac], andILumoAuthorizationfor checks inside handlers. - A health check for your LumoAuth organization.
It installs the LumoAuth SDK with it.
Install
dotnet add package LumoAuth.AspNetCore
Quick start
{
"LumoAuth": {
"OrgId": "acme-corp",
"ApiKey": "lmk_...",
"Login": { "ClientId": "lumo_abc", "ClientSecret": "..." }
}
}
using LumoAuth.AspNetCore;
using LumoAuth.AspNetCore.Authentication;
using LumoAuth.AspNetCore.Authorization;
builder.Services.AddLumoAuth(builder.Configuration); // the "LumoAuth" section
builder.Services.AddAuthentication(LumoAuthDefaults.BearerScheme).AddLumoAuthBearer(); // APIs: bearer tokens
// builder.Services.AddLumoAuthWebAppAuthentication(builder.Configuration); // web apps: cookie + OpenID Connect
builder.Services.AddAuthorization();
builder.Services.AddHealthChecks().AddLumoAuth();
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.MapPost("/invoices/{id}/approve", Approve).RequirePermission("invoice.approve");
app.MapGet("/documents/{id}", GetDocument).RequireRelation("viewer", "document:{id}");
app.MapHealthChecks("/health");
Configuration
| Key | Environment variable | Meaning |
|---|---|---|
LumoAuth:BaseUrl |
LUMOAUTH_URL |
LumoAuth region URL. The default is https://app.lumoauth.dev. |
LumoAuth:OrgId |
LUMOAUTH_ORG_ID |
Your organization's slug |
LumoAuth:ApiKey |
LUMOAUTH_API_KEY |
Organization API key |
LumoAuth:Login:* |
ClientId, ClientSecret, Scopes (default openid, profile, email) and CallbackPath (default /signin-lumoauth) for OpenID Connect sign-in |
|
LumoAuth:Agent:* |
AGENT_CLIENT_ID, AGENT_CLIENT_SECRET |
Registers a LumoAgent singleton |
LumoAuth:AAuth:* |
AgentIdentifier and PrivateKeyPem register an AAuthClient singleton |
Add authz:read to Login:Scopes when the app lists the user's permissions. Add abac:read when the app uses [RequireAbac].
How authorization checks run
The attributes and ILumoAuthorization run a live LumoAuth check for each request:
- When the scheme saved the caller's access token (both LumoAuth schemes do), the check runs with that token.
- When no token was saved, the check runs with the API key and names the signed-in user as the subject. The subject is the principal's
subclaim, which is the user's LumoAuth ID for LumoAuth sign-ins. A principal whosesubisagent_<id>is checked as that agent. The API key then needs theauthz:checkscope.
ABAC checks ([RequireAbac] and ILumoAuthorization.AbacAsync) always run with the user's own access token, because the ABAC routes do not accept API keys. The token needs the abac:read scope:
- After an OpenID Connect sign-in, the SDK takes the token that the handler saved. Keep
Login:SaveTokenson (the default) and addabac:readtoLogin:Scopes. - On an API request, the SDK takes the token that the bearer scheme saved. If no token was saved, it takes the token from the
Authorization: Bearerheader. - If neither exists, the check is denied and a warning is logged. The SDK never sends the API key to the ABAC routes.
A missing permission gives 403, and a request without a signed-in principal gives 401. If LumoAuth cannot be reached, the request is denied with 403 and a warning is logged.
More information
- Full guide: github.com/lumoauth/sdk-csharp
- Quickstart: docs.lumoauth.dev/quickstarts/aspnetcore
| 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
- LumoAuth (>= 1.6.0)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 8.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.