Linbik.Core 1.1.0

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

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 class
  • LinbikAuthenticationException - Authentication failures
  • LinbikConfigurationException - Configuration errors
  • LinbikTokenException - Token operation failures

πŸ“¦ Installation

dotnet add package Linbik.Core

πŸ”§ Configuration

// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed