Linbik.YARP
1.2.8
dotnet add package Linbik.YARP --version 1.2.8
NuGet\Install-Package Linbik.YARP -Version 1.2.8
<PackageReference Include="Linbik.YARP" Version="1.2.8" />
<PackageVersion Include="Linbik.YARP" Version="1.2.8" />
<PackageReference Include="Linbik.YARP" />
paket add Linbik.YARP --version 1.2.8
#r "nuget: Linbik.YARP, 1.2.8"
#:package Linbik.YARP@1.2.8
#addin nuget:?package=Linbik.YARP&version=1.2.8
#tool nuget:?package=Linbik.YARP&version=1.2.8
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.
Delegated OpenAPI aggregation, proxy path migration and refresh/cache setup: OPENAPI.md.
π¦ 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) andLinbik(platform) roles
π§ Configuration
Fluent Builder (Recommended)
// 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": {
"SourcePath": "/payment-gateway",
"TargetBaseUrl": "https://payment.example.com"
},
"survey-service": {
"SourcePath": "/survey-service",
"TargetBaseUrl": "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 Storage
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 application PASETO token as Authorization: Bearer {token} (no user context/cookie required). An unavailable token means a 503 service_unavailable response. TargetPath is the optional downstream prefix; do not repeat it in the incoming request path.
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
- Full Documentation
- YARP Documentation
- Examples
- Linbik.Core
- Linbik.JwtAuthManager
- Linbik.PasetoAuthManager
- Linbik.Server
- Linbik.Slices
π 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 | Versions 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. |
-
net10.0
- Linbik.Core (>= 1.2.8)
- NSwag.CodeGeneration.CSharp (>= 14.7.1)
- Yarp.ReverseProxy (>= 2.3.0)
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 | 108 | 9/20/2026 |
| 1.2.7 | 110 | 9/10/2026 |
| 1.2.5 | 105 | 9/7/2026 |
| 1.2.3 | 97 | 9/1/2026 |
| 1.2.1 | 149 | 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 | 122 | 4/2/2026 |
| 1.1.0 | 425 | 12/5/2025 |
| 1.1.0-beta0007 | 122 | 3/6/2026 |
| 1.0.7 | 175 | 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 |