Linbik.Core
1.1.0
dotnet add package Linbik.Core --version 1.1.0
NuGet\Install-Package Linbik.Core -Version 1.1.0
<PackageReference Include="Linbik.Core" Version="1.1.0" />
<PackageVersion Include="Linbik.Core" Version="1.1.0" />
<PackageReference Include="Linbik.Core" />
paket add Linbik.Core --version 1.1.0
#r "nuget: Linbik.Core, 1.1.0"
#:package Linbik.Core@1.1.0
#addin nuget:?package=Linbik.Core&version=1.1.0
#tool nuget:?package=Linbik.Core&version=1.1.0
Linbik.Core
Core library for the Linbik Authentication Framework with Authorization Code Flow support.
π Features
Authorization Code Support (v2.0+)
- Authorization Code Flow with PKCE support
- Multi-Service Integration - Issue multiple JWT tokens in single response
- Refresh Token Management - Long-lived token renewal
- Per-Service RSA Keys - Each service gets its own key pair
- Service Repository - Manage service registration and validation
- Rate Limiting - Built-in protection against abuse
- HTTP Resilience - Polly-based retry policies
Configuration Validation
- Startup-time validation with
IValidateOptions<T> - Detailed error messages for missing or invalid configuration
Exception Handling
LinbikException- Base exception classLinbikAuthenticationException- Authentication failuresLinbikConfigurationException- Configuration errorsLinbikTokenException- Token operation failures
π¦ Installation
dotnet add package Linbik.Core
π§ Configuration
Authorization Code Setup (Recommended)
// In Program.cs
builder.Services.AddLinbik(builder.Configuration);
// In appsettings.json
{
"Linbik": {
"LinbikUrl": "https://linbik.com",
"ServiceId": "your-service-guid",
"ClientId": "your-client-guid",
"ApiKey": "your-api-key",
"AuthorizationEndpoint": "/auth",
"TokenEndpoint": "/oauth/token",
"RefreshEndpoint": "/oauth/refresh",
"AccessTokenLifetimeMinutes": 60,
"RefreshTokenLifetimeDays": 14
}
}
Configuration Validation
Options are validated at startup. If configuration is invalid, the application will fail to start with a clear error message:
OptionsValidationException: Linbik:LinbikUrl is required.
OptionsValidationException: Linbik:ApiKey is required and cannot be empty.
π Main Interfaces
IAuthService
Main authentication service interface with full CancellationToken support.
public interface IAuthService
{
Task RedirectToLinbikAsync(HttpContext context, string? returnUrl = null,
string? codeChallenge = null, CancellationToken cancellationToken = default);
Task<LinbikTokenResponse?> ExchangeCodeForTokensAsync(string code,
CancellationToken cancellationToken = default);
Task<UserProfile?> GetUserProfileAsync(HttpContext context,
CancellationToken cancellationToken = default);
Task<List<LinbikIntegrationToken>> GetIntegrationTokensAsync(HttpContext context,
CancellationToken cancellationToken = default);
Task<bool> RefreshTokensAsync(HttpContext context,
CancellationToken cancellationToken = default);
Task LogoutAsync(HttpContext context,
CancellationToken cancellationToken = default);
}
ILinbikAuthClient
HTTP client for communicating with Linbik OAuth endpoints.
public interface ILinbikAuthClient
{
Task<LinbikTokenResponse?> ExchangeCodeAsync(string code,
CancellationToken cancellationToken = default);
Task<LinbikTokenResponse?> RefreshTokensAsync(string refreshToken,
CancellationToken cancellationToken = default);
}
π‘οΈ Exception Handling
The library provides typed exceptions for better error handling:
try
{
var tokens = await authService.ExchangeCodeForTokensAsync(code);
}
catch (LinbikAuthenticationException ex) when (ex.ErrorCode == LinbikAuthenticationException.InvalidCodeError)
{
// Handle invalid authorization code
return RedirectToAction("Login");
}
catch (LinbikTokenException ex) when (ex.ErrorCode == LinbikTokenException.TokenExpiredError)
{
// Handle expired token
await authService.RefreshTokensAsync(context);
}
catch (LinbikConfigurationException ex)
{
// Configuration error - check appsettings.json
logger.LogError(ex, "Configuration error: {Key}", ex.ConfigurationKey);
}
π Models
LinbikTokenResponse
Response format for token exchange endpoint.
public class LinbikTokenResponse
{
public Guid UserId { get; set; }
public string UserName { get; set; }
public string NickName { get; set; }
public List<LinbikIntegrationToken> Integrations { get; set; }
public string RefreshToken { get; set; }
public long? RefreshTokenExpiresAt { get; set; }
public string? CodeChallenge { get; set; } // For PKCE validation
}
LinbikIntegrationToken
Per-service JWT token data.
public class LinbikIntegrationToken
{
public string PackageName { get; set; }
public string ServiceName { get; set; }
public string Token { get; set; } // JWT signed with service's private key
public string ServiceUrl { get; set; }
}
UserProfile
User profile information extracted from JWT.
public class UserProfile
{
public Guid UserId { get; set; }
public string UserName { get; set; }
public string NickName { get; set; }
}
π Rate Limiting
Built-in rate limiting to protect authentication endpoints:
// In Program.cs
builder.Services.AddLinbikRateLimiting(builder.Configuration);
// In middleware pipeline
app.UseLinbikRateLimiting();
// In appsettings.json
{
"Linbik": {
"RateLimiting": {
"PermitLimit": 100,
"WindowSeconds": 60,
"QueueLimit": 2
},
"Resilience": {
"StrictTokenLimit": 10,
"StrictReplenishmentPeriodSeconds": 60,
"StrictTokensPerPeriod": 5,
"StrictQueueLimit": 0
}
}
}
π Documentation
π License
This library is currently a work in progress and is not ready for production use.
Contact: info@linbik.com
Version: 2.1.0
Last Updated: 1 AralΔ±k 2025
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net9.0
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.AspNetCore.Session (>= 2.2.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection (>= 9.0.8)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.8)
- Microsoft.Extensions.Http.Resilience (>= 9.1.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.8)
- System.Diagnostics.DiagnosticSource (>= 9.0.0)
- System.IdentityModel.Tokens.Jwt (>= 8.14.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Linbik.Core:
| Package | Downloads |
|---|---|
|
Linbik.JwtAuthManager
This package is for testing purposes only. Not available for public use. |
|
|
Linbik.YARP
This package is for testing purposes only. Not available for public use. |
|
|
Linbik.Server
This package is for testing purposes only. Not available for public use. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 411 | 12/5/2025 |
| 1.0.1 | 244 | 12/14/2025 |
| 0.45.12 | 382 | 11/30/2025 |
| 0.45.7 | 251 | 8/31/2025 |
| 0.45.6 | 232 | 8/31/2025 |
| 0.45.5 | 260 | 8/27/2025 |
| 0.45.4 | 227 | 8/27/2025 |
| 0.45.3 | 221 | 8/27/2025 |
| 0.45.0 | 228 | 8/27/2025 |
| 0.44.0 | 278 | 8/24/2025 |
| 0.42.0 | 136 | 8/23/2025 |
| 0.41.0 | 150 | 8/15/2025 |
| 0.40.0 | 216 | 8/14/2025 |
| 0.39.0 | 219 | 8/14/2025 |
| 0.38.0 | 218 | 8/14/2025 |
| 0.37.0 | 403 | 7/25/2025 |
| 0.36.0 | 594 | 7/22/2025 |
| 0.35.0 | 572 | 7/22/2025 |