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
                    
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="PolyhydraGames.Identity.Contracts" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PolyhydraGames.Identity.Contracts" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="PolyhydraGames.Identity.Contracts" />
                    
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 PolyhydraGames.Identity.Contracts --version 0.1.0
                    
#r "nuget: PolyhydraGames.Identity.Contracts, 0.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 PolyhydraGames.Identity.Contracts@0.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=PolyhydraGames.Identity.Contracts&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=PolyhydraGames.Identity.Contracts&version=0.1.0
                    
Install as a Cake Tool

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 ChannelCheevos UserId/IdentityId pattern.
  • ExternalIdentityDefinition — provider claim/attribute metadata.
  • LinkedExternalIdentity — normalized provider + provider user id + canonical key value.
  • IdentityExternalIdentityLink — links an internal IdentityId to an external provider identity.
  • ExternalIdentityClaimNormalizer — extracts linked identities from a ClaimsPrincipal.
  • 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 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.
  • 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