Linbik.YARP 1.2.7

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

Linbik.YARP

YARP (Yet Another Reverse Proxy) integration for Linbik multi-service authentication. Provides automatic token injection, apps token provider, and typed apps HTTP client.

πŸ“¦ Installation

dotnet add package Linbik.YARP

πŸš€ Features

User-Context Proxy

  • Automatic Token Injection β€” Inject service-specific JWT tokens into proxied requests from cookies
  • Cookie-Based Storage β€” Integration tokens stored in HttpOnly cookies
  • Per-Service Routing β€” /{packageName}/{**path} routes to integration service BaseUrl

Apps (Service-to-Service)

  • IApplicationTokenProvider β€” Token caching, auto-refresh, config-based and dynamic targets
  • IApplicationServiceClient β€” Full typed HTTP client (GET, POST, PUT, DELETE, PATCH) with automatic apps token injection
  • LBaseResponse<T> Enforcement β€” Consistent response format
  • Role-Based Tokens β€” Service (service-to-service) and Linbik (platform) roles

πŸ”§ Configuration

// In Program.cs
builder.Services.AddLinbik()
    .AddLinbikJwtAuth()
    .AddLinbikYarp();

var app = builder.Build();
app.EnsureLinbik();

// Map user-context integration proxy: /{packageName}/{**path}
app.UseLinbikYarp();

// Map apps proxy endpoints (optional): /{routePrefix}/{packageName}/{**path}
// routePrefix defaults to "app" (UseLinbikApplication(string routePrefix = "app"))
app.UseLinbikApplication();

appsettings.json

{
  "Linbik": {
    "LinbikUrl": "https://api.linbik.com",
    "ServiceId": "your-service-guid",
    "ApiKey": "lnbk_your_api_key",
    "AppsTargetServices": {
      "payment-gateway": "guid-of-payment-service",
      "courier-service": "guid-of-courier-service"
    },
    "AppsAutoRefresh": true,
    "AppsRefreshThreshold": 0.75
  },
  "YARP": {
    "IntegrationServices": {
      "payment-gateway": {
        "BaseUrl": "https://payment.example.com"
      },
      "survey-service": {
        "BaseUrl": "https://survey.example.com"
      }
    }
  }
}

πŸ’» User-Context Proxy (UseLinbikYarp)

How It Works

1. User authenticates β†’ Integration tokens stored in cookies
   Cookie: integration_payment-gateway = "eyJhbG..."
   Cookie: integration_survey-service = "eyJhbG..."

2. Client request β†’ /payment-gateway/api/charge

3. UseLinbikYarp():
   a. Extract {packageName} from URL β†’ "payment-gateway"
   b. Read cookie: integration_payment-gateway
   c. Lookup BaseUrl from YARP:IntegrationServices config
   d. Proxy request with Authorization: Bearer {token}

4. Target service receives:
   GET /api/charge
   Authorization: Bearer eyJhbG...
Cookie: linbikRefreshToken = "refresh_abc..." (HttpOnly, Secure, 30 days)
Cookie: integration_payment-gateway = "eyJhbGci..." (HttpOnly, Secure, 1 hour)
Cookie: integration_courier-service = "eyJhbGci..." (HttpOnly, Secure, 1 hour)

πŸ’» Application (Apps / Service-to-Service) Communication

ITokenProvider

public interface ITokenProvider
{
    Task<LinbikTokenResponse?> GetMultiServiceTokenAsync(
        string baseUrl, string authorizationCode, string apiKey);
    Task<LinbikTokenResponse?> RefreshTokensAsync(
        string baseUrl, string refreshToken, string apiKey, string serviceId);
    Task<string?> GetIntegrationTokenAsync(string integrationServicePackage);
    void CacheTokenResponse(LinbikTokenResponse tokenResponse);
    void ClearCache();
}

IApplicationTokenProvider

Manages PASETO application token caching, automatic refresh, and thread-safe access:

public interface IApplicationTokenProvider
{
    // Config-based (package name)
    Task<string?> GetApplicationTokenAsync(string integrationPackageName, CancellationToken cancellationToken = default);
    Task<IReadOnlyDictionary<string, string>> GetApplicationTokensAsync(
        IEnumerable<string> integrationPackageNames, CancellationToken cancellationToken = default);
    Task<LinbikApplicationIntegration?> GetApplicationIntegrationAsync(
        string integrationPackageName, CancellationToken cancellationToken = default);

    // Dynamic (service ID) β€” for callbacks/webhooks, no config entry required
    Task<LinbikApplicationIntegration?> GetApplicationIntegrationByIdAsync(
        Guid targetServiceId, CancellationToken cancellationToken = default);
    Task<IReadOnlyDictionary<Guid, LinbikApplicationIntegration>> GetApplicationIntegrationsByIdAsync(
        IEnumerable<Guid> targetServiceIds, CancellationToken cancellationToken = default);

    // Cache management
    Task RefreshApplicationTokensAsync(CancellationToken cancellationToken = default);
    void ClearCache();
    TimeSpan? GetTimeUntilExpiry();
}

IApplicationServiceClient

Typed HTTP client with automatic application-token injection and LBaseResponse<T> format:

Config-Based Targets (Package Name)
public class MyController : ControllerBase
{
    private readonly IApplicationServiceClient _applicationClient;

    public async Task<IActionResult> SyncWithPayment()
    {
        var result = await _applicationClient.PostAsync<SyncRequest, SyncResponse>(
            "payment-gateway",           // package name from config
            "/api/integration/app/sync",
            new SyncRequest { EntityType = "order", EntityId = "123" }
        );

        return result.IsSuccess ? Ok(result.Data) : BadRequest(result.FriendlyMessage);
    }
}
Dynamic Targets (Service ID) β€” Callbacks/Webhooks
public class PaymentController : ControllerBase
{
    private readonly IApplicationServiceClient _applicationClient;

    public async Task<IActionResult> NotifyMerchant(Order order)
    {
        var result = await _applicationClient.PostByIdAsync<PaymentNotification, NotifyResponse>(
            order.MerchantLinbikServiceId,   // dynamic service ID
            "/api/webhooks/payment",
            new PaymentNotification
            {
                OrderId = order.Id.ToString(),
                Status = "completed",
                Amount = order.Amount
            }
        );

        return result.IsSuccess ? Ok() : StatusCode(500);
    }
}

Available HTTP Methods

Method Config-Based Dynamic (by ID)
GET GetAsync<TResponse> GetByIdAsync<TResponse>
POST PostAsync<TReq, TRes> (+ PostAsync<TReq> without response) PostByIdAsync<TReq, TRes> (+ PostByIdAsync<TReq> without response)
PUT PutAsync<TReq, TRes> PutByIdAsync<TReq, TRes>
DELETE DeleteAsync<TRes> (+ DeleteAsync without response) DeleteByIdAsync<TRes> (+ DeleteByIdAsync without response)
PATCH PatchAsync<TReq, TRes> PatchByIdAsync<TReq, TRes>

Application Proxy Endpoints (UseLinbikApplication)

UseLinbikApplication(string routePrefix = "app") maps one route per configured IntegrationServices entry: /{routePrefix}/{packageName}/{**path} β†’ {TargetBaseUrl}{TargetPath}/{path}, injecting the cached application PASETO token as Authorization: Bearer {token} (no user context/cookie required). No local cache hit means a 503 service_unavailable response.

YARPOptions.ApplicationTimeoutSeconds configures the IApplicationServiceClient's HTTP timeout.

YARP Route Configuration (Advanced)

For fine-grained control with YARP reverse proxy routes (user-context token injection via ITokenProvider):

// Add Linbik token transform to YARP
builder.Services.AddReverseProxy()
    .LoadFromConfig()
    .AddLinbikTokenTransform();

πŸ“– Documentation

πŸ“„ License

MIT License

Contact: info@linbik.com


Version: 1.2.0
Platform: ASP.NET Core 10.0 (net10.0)
Last Updated: 9 EylΓΌl 2026

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
1.2.8 107 9/20/2026
1.2.7 110 9/10/2026
1.2.5 103 9/7/2026
1.2.3 97 9/1/2026
1.2.1 148 7/16/2026
1.2.0-preview.3 71 5/30/2026
1.2.0-preview.2 99 4/26/2026
1.2.0-preview.1 121 4/2/2026
1.1.0 425 12/5/2025
1.1.0-beta0007 121 3/6/2026
1.0.7 173 3/6/2026
1.0.1 248 12/14/2025
1.0.0 131 3/6/2026
0.60.1 127 3/6/2026
0.46.0 381 11/30/2025
0.45.12 390 11/30/2025
0.45.7 258 8/31/2025
0.45.6 226 8/31/2025
0.45.5 261 8/27/2025
0.44.0 286 8/24/2025
Loading failed