SetNet.Auth.OAuth
1.1.0
dotnet add package SetNet.Auth.OAuth --version 1.1.0
NuGet\Install-Package SetNet.Auth.OAuth -Version 1.1.0
<PackageReference Include="SetNet.Auth.OAuth" Version="1.1.0" />
<PackageVersion Include="SetNet.Auth.OAuth" Version="1.1.0" />
<PackageReference Include="SetNet.Auth.OAuth" />
paket add SetNet.Auth.OAuth --version 1.1.0
#r "nuget: SetNet.Auth.OAuth, 1.1.0"
#:package SetNet.Auth.OAuth@1.1.0
#addin nuget:?package=SetNet.Auth.OAuth&version=1.1.0
#tool nuget:?package=SetNet.Auth.OAuth&version=1.1.0
<p align="center"> <img src="https://raw.githubusercontent.com/Povstalez/SetNet/master/assets/icon.png" alt="SetNet" width="96"> </p>
SetNet.Auth.OAuth
OAuth 2.0 / OpenID Connect authenticator for SetNet.Auth.
An IAuthenticator that validates access (JWT) tokens issued by a standards-compliant identity provider — Auth0, Azure AD / Entra ID, Keycloak, Google, Cognito, and friends — against the provider's published signing keys. Keys are discovered from the authority's /.well-known/openid-configuration (JWKS) and refreshed automatically as they rotate, so you never hard-code or manually rotate keys. Use this when your clients already log in through an external provider and hand SetNet the resulting access token.
For tokens you sign yourself with a static key (shared secret or your own RSA key), use SetNet.Auth.Jwt instead.
Install
dotnet add package SetNet
dotnet add package SetNet.Auth
dotnet add package SetNet.Auth.OAuth
Setup
AuthRuntime.Enable(); // once at startup, both ends, before creating client/server
Server
Point the authenticator at your provider's authority and hand it to UseAuth. UseAuth installs the enforced inbound gate from SetNet.Auth: until a peer authenticates, its application frames are dropped and only the auth handshake passes.
using SetNet.Auth;
using SetNet.Auth.OAuth;
var auth = new OpenIdConnectAuthenticator(
authority: "https://my-tenant.auth0.com/", // its /.well-known/openid-configuration is fetched
audience: "my-game-api", // expected `aud`; null to skip audience checks
accountClaim: "sub"); // claim carrying the account id
server.UseAuth(auth, new AuthOptions());
Provider authority examples:
| Provider | Authority |
|---|---|
| Auth0 | https://my-tenant.auth0.com/ |
| Azure AD / Entra | https://login.microsoftonline.com/{tenant}/v2.0 |
| Keycloak | https://kc.example.com/realms/{realm} |
https://accounts.google.com |
|
| AWS Cognito | https://cognito-idp.{region}.amazonaws.com/{poolId} |
Client
Clients present the provider's access token as their auth token — no OAuth-specific code beyond the base SetNet.Auth client hook:
// a provider that returns a fresh access token on every (re)connect:
var auth = client.UseAuth(tokenProvider: () => identityClient.GetAccessTokenAsync());
// or a fixed token you already obtained:
client.UseAuth(accessToken);
API
OpenIdConnectAuthenticator : IAuthenticator
| Member | Purpose |
|---|---|
new OpenIdConnectAuthenticator(authority, audience? = null, accountClaim = "sub") |
build from a provider authority URL |
Task<AuthResult> AuthenticateAsync(string token) |
called by the server per handshake; validates against the cached JWKS |
Validation checks signing key, issuer (the authority's own issuer), audience (when audience is non-null), and lifetime, with a 30-second clock skew. The account id comes from accountClaim, falling back to sub; a missing id fails the token. The discovery document + JWKS are fetched once and cached by a ConfigurationManager, which refreshes them on its own schedule as keys rotate.
Notes
- Use over TLS. The access token is a bearer credential — sniffable and replayable if the connection isn't encrypted. Run SetNet with TLS-over-TCP or
wss://(viaSetNet.WebSockets). - Outbound access required. The server must be able to reach the authority's
/.well-known/openid-configurationand JWKS endpoints to validate tokens. - Audience matters. Validate
audiencein production so tokens minted for a different app of the same tenant can't be replayed against your server; passnullonly if you deliberately accept any audience. - Session resume, multi-session policy, and the session store come from
SetNet.Auth'sAuthOptions— this package only decides whether a token is valid and who it belongs to.
Documentation & source
- 🐙 https://github.com/Povstalez/SetNet — full module catalog in docs/MODULES.md
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.2.1)
- SetNet.Auth (>= 1.1.0)
- System.IdentityModel.Tokens.Jwt (>= 8.2.1)
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.1.0 | 129 | 7/2/2026 |