FederatedAuthRealm.Sdk
0.4.16
dotnet add package FederatedAuthRealm.Sdk --version 0.4.16
NuGet\Install-Package FederatedAuthRealm.Sdk -Version 0.4.16
<PackageReference Include="FederatedAuthRealm.Sdk" Version="0.4.16" />
<PackageVersion Include="FederatedAuthRealm.Sdk" Version="0.4.16" />
<PackageReference Include="FederatedAuthRealm.Sdk" />
paket add FederatedAuthRealm.Sdk --version 0.4.16
#r "nuget: FederatedAuthRealm.Sdk, 0.4.16"
#:package FederatedAuthRealm.Sdk@0.4.16
#addin nuget:?package=FederatedAuthRealm.Sdk&version=0.4.16
#tool nuget:?package=FederatedAuthRealm.Sdk&version=0.4.16
Federated Auth Realm - SDK (.NET)
A lightweight .NET implementation of the Federated Auth Realm SDK.
It mirrors the TypeScript SDK feature set and provides a strongly typed, task-based API for authenticating users, refreshing sessions, and interacting with the SRWP discovery network.
Project layout
├── FederatedAuthRealm.Sdk.sln # Solution file
└── src
└── FederatedAuthRealm.Sdk
├── FederatedAuthRealmClient.cs # High-level auth client
├── SRWPDiscoveryClient.cs # SRWP discovery helper
├── Models/ # Shared contracts/enums
├── Storage/ # Token storage abstractions
└── Utils/JwtUtils.cs # Minimal JWT helpers
Getting started
Build the library
dotnet buildReference the SDK
Add a project reference to
src/FederatedAuthRealm.Sdk/FederatedAuthRealm.Sdk.csprojor pack it into a NuGet package as needed.
Usage
using SavantRealms.FederatedAuthRealm.Sdk;
using SavantRealms.FederatedAuthRealm.Sdk.Models;
var client = new FederatedAuthRealmClient(new FederatedAuthRealmClientConfig
{
BaseUrl = "https://api.federatedauthrealm.com",
AppKey = "federated-auth-realm",
OnSessionExpired = () => Console.WriteLine("Session expired"),
});
var response = await client.LoginAsync(new LoginRequest
{
Email = "admin@example.com",
Password = "Str0ngPassword!",
});
Console.WriteLine($"Authenticated as {response.User?.Email}");
Managing storage
The SDK uses an in-memory storage provider by default. You can plug in your own implementation (for example, wrapping ASP.NET Core IDistributedCache) by implementing IStorageProvider and supplying it via the FederatedAuthRealmClientConfig.
Discovery client
using SavantRealms.FederatedAuthRealm.Sdk;
using SavantRealms.FederatedAuthRealm.Sdk.Models;
var discovery = new SRWPDiscoveryClient("https://srwp.example.com");
var knownRealms = await discovery.GetKnownRealmsAsync();
await discovery.WhisperAsync(new SRWPWhisperRequest
{
SourceRealm = "federated-auth-realm",
SourceUrl = "https://api.federatedauthrealm.com",
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
KnownRealms = knownRealms,
});
Running tests
Everything (format verification + analyzers + tests):
./scripts/check-all.shFormat sources in-place:
./scripts/format.shRun the test suite:
./scripts/test.sh
Git hooks & workflow automation
The repository contains local git hooks under .githooks. Install them with:
./scripts/install-hooks.sh
This sets core.hooksPath and wires up:
pre-commit→scripts/check-all.shpre-push→scripts/test.sh
Publishing helper
./scripts/publish.sh mirrors the TypeScript/JavaScript SDK publish flow:
- Restores dependencies and runs both style/analyzer formatters.
- Executes the test suite.
- Packs the library into
./dist/*.nupkg. - Optionally pushes the package to NuGet when
NUGET_API_KEY(and optionalNUGET_SOURCE) are provided.
UseDRY_RUN=trueto skip publishing.
Example usage:
# Build/test/pack only
./scripts/publish.sh
# Publish to nuget.org
NUGET_API_KEY=XXXXX ./scripts/publish.sh
# Publish to a custom feed
NUGET_API_KEY=XXXXX NUGET_SOURCE="https://example.com/v3/index.json" ./scripts/publish.sh
| 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
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release 0.4.16 - Fixed enum serialization to use JsonStringEnumMemberName for proper System.Text.Json deserialization