PolyhydraGames.Identity.Contracts
0.1.0
dotnet add package PolyhydraGames.Identity.Contracts --version 0.1.0
NuGet\Install-Package PolyhydraGames.Identity.Contracts -Version 0.1.0
<PackageReference Include="PolyhydraGames.Identity.Contracts" Version="0.1.0" />
<PackageVersion Include="PolyhydraGames.Identity.Contracts" Version="0.1.0" />
<PackageReference Include="PolyhydraGames.Identity.Contracts" />
paket add PolyhydraGames.Identity.Contracts --version 0.1.0
#r "nuget: PolyhydraGames.Identity.Contracts, 0.1.0"
#:package PolyhydraGames.Identity.Contracts@0.1.0
#addin nuget:?package=PolyhydraGames.Identity.Contracts&version=0.1.0
#tool nuget:?package=PolyhydraGames.Identity.Contracts&version=0.1.0
PolyhydraGames.Identity.Contracts
Shared identity contracts for Polyhydra projects that use Keycloak as the broker for Twitch, Steam, YouTube, Discord, Spotify, GitHub, Patreon, Reddit, Microsoft, Apple, and other external login providers.
The package standardizes three identity layers:
Internal identity ID: IdentityId {guid}
Keycloak subject: keycloak:{sub}
External identity: {provider}:{provider_user_id}
What is included
IdentityId— strongly typed GUID wrapper matching the ChannelCheevosUserId/IdentityIdpattern.ExternalIdentityDefinition— provider claim/attribute metadata.LinkedExternalIdentity— normalizedprovider + provider user id + canonical keyvalue.IdentityExternalIdentityLink— links an internalIdentityIdto an external provider identity.ExternalIdentityClaimNormalizer— extracts linked identities from aClaimsPrincipal.ExternalIdentityInteropExtensions— extension helpers for claims, canonical keys, links, and round-trip interop.
Common usage
using PolyhydraGames.Identity.Contracts;
var linkedIdentities = principal.GetLinkedExternalIdentities();
var canonicalKeys = principal.GetExternalIdentityCanonicalKeys();
var identityId = IdentityId.New();
var twitch = LinkedExternalIdentity.Create("twitch", "123456789", "twitch_id");
var link = twitch.ToIdentityExternalIdentityLink(identityId);
var claim = twitch.ToClaim();
Keycloak claim convention
For Twitch, configure Keycloak to import the upstream sub into user attribute twitch.id, then map that user attribute into a scalar OIDC claim named twitch_id.
The normalizer reads both token-style claim names (twitch_id) and Keycloak user-attribute aliases (twitch.id) so token and mapper tests can share the same contract.
Treat Provider and ProviderUserId as the authoritative storage fields. CanonicalKey is a display/deduplication helper and is not intended to replace the separate unique index on Provider + ProviderUserId.
Pass only trusted Keycloak-issued principals into the normalizer. Raw upstream provider principals should be brokered or translated first so their subject is not confused with the Keycloak sub.
| 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
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PolyhydraGames.Identity.Contracts:
| Package | Downloads |
|---|---|
|
PolyhydraGames.Core.AspNet
Shared ASP.NET Core helpers for PolyhydraGames services, including identity, controller, and logging helpers. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 4,085 | 7/15/2026 |