Chromex.Authentication
2.0.0
dotnet add package Chromex.Authentication --version 2.0.0
NuGet\Install-Package Chromex.Authentication -Version 2.0.0
<PackageReference Include="Chromex.Authentication" Version="2.0.0" />
<PackageVersion Include="Chromex.Authentication" Version="2.0.0" />
<PackageReference Include="Chromex.Authentication" />
paket add Chromex.Authentication --version 2.0.0
#r "nuget: Chromex.Authentication, 2.0.0"
#:package Chromex.Authentication@2.0.0
#addin nuget:?package=Chromex.Authentication&version=2.0.0
#tool nuget:?package=Chromex.Authentication&version=2.0.0
Chromex Authentication
A branded, environment-aware authentication package for .NET applications. Provides development workarounds (CLI credentials, database JWT keys) and production paths (Managed Identity, Key Vault). Supports pluggable extensions for SQL and JWT.
Features
- Environment-Aware Authentication: Automatically detects development vs. production environments with configuration-driven behavior
- Development Support:
- Azure CLI credentials (via
az login) - Database JWT key storage
- Early startup verification to fail fast if credentials are unavailable
- Azure CLI credentials (via
- Production Support:
- Azure Managed Identity (recommended)
- Azure Key Vault integration
- Intelligent Token Caching: Per-scope/audience caching with 5-minute refresh buffer to prevent token expiration during use
- Thread-Safe Operations: Concurrent cache access with proper synchronization
- Pluggable Extensions: SQL and JWT extension points for customization
- Comprehensive Logging: Detailed diagnostics for troubleshooting
Supported Frameworks
- .NET 8.0
- .NET 9.0
Installation
Install via NuGet Package Manager:
dotnet add package Chromex.Authentication
Or via Package Manager Console:
Install-Package Chromex.Authentication
Usage
Basic Setup
Register the authentication service in your application:
using Chromex.Authentication;
using Chromex.Authentication.Configuration;
var builder = WebApplication.CreateBuilder(args);
// Add Chromex Authentication
builder.Services.AddChromexAuthentication();
var app = builder.Build();
// Initialize during startup (automatic mode detection)
var authService = app.Services.GetRequiredService<IChromexAuthenticationService>();
await authService.InitializeAsync();
app.Run();
Getting Access Tokens
public class MyService
{
private readonly IChromexAuthenticationService _authService;
public MyService(IChromexAuthenticationService authService)
{
_authService = authService;
}
public async Task<string> GetSqlTokenAsync()
{
// Get token for SQL Database
return await _authService.GetAccessTokenAsync("https://database.windows.net/.default");
}
public async Task<string> GetKeyVaultTokenAsync()
{
// Get token for Key Vault
return await _authService.GetAccessTokenAsync("https://vault.azure.net/.default");
}
}
Configuration
Development Environment
In development, ensure Azure CLI is logged in:
az login
The service will verify credentials are available and fail fast if they're not.
Production Environment
In production, use Azure Managed Identity:
// This is handled automatically - no explicit configuration needed
// The service will use Managed Identity when running in production
Architecture
Token Caching
- Separate cache per audience/scope ensures tokens for different Azure services don't interfere
- 5-minute refresh buffer prevents token expiration during active use
- Thread-safe cache operations using locks
- Automatic cache invalidation before token expires
Environment Detection
- Development: Uses Azure CLI credentials (
az login), applies early verification at startup - Production: Uses Azure Managed Identity, skips verification (assumes proper identity is assigned)
Startup Verification
During development, InitializeAsync() must be called:
- Verifies
az logincredentials are cached and accessible - 30-second timeout prevents hanging if Azure CLI is unresponsive
- Clear error messages guide users to run
az login
Not Suitable For
- ❌ Service principals (use
ServicePrincipalCredentialorDefaultAzureCredentialinstead) - ❌ Applications requiring interactive user authentication
- ❌ VDI environments relying on VDI managed identity
Dependencies
- Azure.Identity (1.17.x)
- Azure.Core (1.51.x)
- Azure.Security.KeyVault.Certificates (4.7.x)
- Azure.Security.KeyVault.Keys (4.7.x)
- System.IdentityModel.Tokens.Jwt (8.16.x)
- Microsoft.IdentityModel.Tokens (8.16.x)
- Microsoft.AspNetCore.Authentication.JwtBearer (8.0.x for .NET 8, 9.0.x for .NET 9)
Documentation
For detailed API documentation, see the XML documentation in the package or visit our GitHub repository.
License
See LICENSE.md for details.
Contributing
We welcome contributions! Please feel free to submit pull requests or open issues for bugs and feature requests.
Support
For issues, questions, or contributions, please visit our GitHub repository.
| 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 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. |
-
net8.0
- Azure.Core (>= 1.51.1)
- Azure.Identity (>= 1.17.2)
- Azure.Security.KeyVault.Certificates (>= 4.7.0)
- Azure.Security.KeyVault.Keys (>= 4.7.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.28)
- Microsoft.IdentityModel.Tokens (>= 8.16.0)
- System.IdentityModel.Tokens.Jwt (>= 8.16.0)
-
net9.0
- Azure.Core (>= 1.51.1)
- Azure.Identity (>= 1.17.2)
- Azure.Security.KeyVault.Certificates (>= 4.7.0)
- Azure.Security.KeyVault.Keys (>= 4.7.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 9.0.17)
- Microsoft.IdentityModel.Tokens (>= 8.16.0)
- System.IdentityModel.Tokens.Jwt (>= 8.16.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Chromex.Authentication:
| Package | Downloads |
|---|---|
|
Chromex.Authentication.SqlServer
Optional SqlServer integration for Chromex.Authentication. Provides SqlServerAuthInterceptor for automatic Azure CLI credential injection into SQL Server connections. For use with applications that require EF Core database access in Chromex environments. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 204 | 6/18/2026 |