Rystem.Authentication.Social.Abstractions
10.0.4
dotnet add package Rystem.Authentication.Social.Abstractions --version 10.0.4
NuGet\Install-Package Rystem.Authentication.Social.Abstractions -Version 10.0.4
<PackageReference Include="Rystem.Authentication.Social.Abstractions" Version="10.0.4" />
<PackageVersion Include="Rystem.Authentication.Social.Abstractions" Version="10.0.4" />
<PackageReference Include="Rystem.Authentication.Social.Abstractions" />
paket add Rystem.Authentication.Social.Abstractions --version 10.0.4
#r "nuget: Rystem.Authentication.Social.Abstractions, 10.0.4"
#:package Rystem.Authentication.Social.Abstractions@10.0.4
#addin nuget:?package=Rystem.Authentication.Social.Abstractions&version=10.0.4
#tool nuget:?package=Rystem.Authentication.Social.Abstractions&version=10.0.4
What is Rystem?
Rystem.Authentication.Social.Abstractions
Shared models, interfaces, and abstractions for Rystem social authentication libraries.
📦 Installation
dotnet add package Rystem.Authentication.Social.Abstractions
🔑 Core Interfaces
ISocialUser
Base interface for social user models:
public interface ISocialUser
{
string? Username { get; set; }
}
DefaultSocialUser
Default implementation provided by the library:
internal sealed class DefaultSocialUser : ISocialUser
{
public string? Username { get; set; }
}
Custom Social User
Extend with your application-specific properties:
public sealed class CustomSocialUser : ISocialUser
{
public string? Username { get; set; }
public string DisplayName { get; set; }
public string Email { get; set; }
public Guid UserId { get; set; }
public string Avatar { get; set; }
public List<string> Roles { get; set; } = new();
public DateTime CreatedAt { get; set; }
public DateTime LastLogin { get; set; }
}
🔐 TokenCheckerSettings
Unified settings class for OAuth token validation (with PKCE support):
public sealed class TokenCheckerSettings
{
/// <summary>
/// Domain for OAuth redirect (e.g., https://yourdomain.com)
/// </summary>
public string? Domain { get; set; }
/// <summary>
/// Redirect path after OAuth callback (default: /)
/// Used to construct full redirect_uri: {Domain}{RedirectPath}
/// </summary>
public string RedirectPath { get; set; } = "/";
/// <summary>
/// Additional parameters for token exchange
/// Example: { "code_verifier": "abc123..." } for PKCE
/// </summary>
public Dictionary<string, string>? AdditionalParameters { get; set; }
/// <summary>
/// Get full redirect URI by combining Domain and RedirectPath
/// </summary>
public string GetRedirectUri()
{
if (string.IsNullOrWhiteSpace(Domain))
return RedirectPath;
return $"{Domain.TrimEnd('/')}{RedirectPath}";
}
/// <summary>
/// Get additional parameter by key (e.g., "code_verifier")
/// </summary>
public string? GetParameter(string key)
{
if (AdditionalParameters == null || string.IsNullOrWhiteSpace(key))
return null;
return AdditionalParameters.TryGetValue(key, out var value) ? value : null;
}
/// <summary>
/// Set additional parameter (fluent API)
/// </summary>
public TokenCheckerSettings WithParameter(string key, string value)
{
AdditionalParameters ??= new Dictionary<string, string>();
AdditionalParameters[key] = value;
return this;
}
}
Usage Examples
Basic Usage
var settings = new TokenCheckerSettings
{
Domain = "https://yourdomain.com",
RedirectPath = "/account/login"
};
var fullUri = settings.GetRedirectUri(); // "https://yourdomain.com/account/login"
With PKCE (Microsoft OAuth)
var settings = new TokenCheckerSettings
{
Domain = "https://yourdomain.com",
RedirectPath = "/account/login",
AdditionalParameters = new Dictionary<string, string>
{
{ "code_verifier", "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk" }
}
};
var codeVerifier = settings.GetParameter("code_verifier");
Fluent API
var settings = new TokenCheckerSettings
.WithParameter("code_verifier", codeVerifier)
.WithParameter("custom_param", "value");
📝 TokenResponse
Response from OAuth token validation:
public sealed class TokenResponse
{
/// <summary>
/// Username/email from OAuth provider
/// </summary>
public required string Username { get; init; }
/// <summary>
/// Claims extracted from OAuth provider
/// </summary>
public required List<Claim> Claims { get; init; }
/// <summary>
/// Empty response for failed validations
/// </summary>
public static TokenResponse Empty => new TokenResponse
{
Username = string.Empty,
Claims = new List<Claim>()
};
}
🌐 ProviderType Enum
Supported OAuth providers:
public enum ProviderType
{
DotNet = 0, // Internal .NET bearer token
Microsoft = 1, // Microsoft Entra ID (Azure AD)
Google = 2, // Google OAuth
Facebook = 3, // Facebook Login
GitHub = 4, // GitHub OAuth
Amazon = 5, // Amazon Login
Linkedin = 6, // LinkedIn OAuth
X = 7, // X (Twitter) OAuth
TikTok = 8, // TikTok Login
Instagram = 9, // Instagram Basic Display
Pinterest = 10 // Pinterest OAuth
}
🔧 ITokenChecker Interface
Core interface for OAuth token validation:
public interface ITokenChecker
{
/// <summary>
/// Validate OAuth authorization code and exchange for user information
/// </summary>
/// <param name="code">Authorization code from OAuth provider</param>
/// <param name="settings">Token checker settings (domain, redirectPath, code_verifier, etc.)</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>TokenResponse with username and claims, or error message</returns>
Task<AnyOf<TokenResponse?, string>> CheckTokenAndGetUsernameAsync(
string code,
TokenCheckerSettings settings,
CancellationToken cancellationToken = default);
}
Implementation Example
public class CustomTokenChecker : ITokenChecker
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly CustomOAuthSettings _settings;
public CustomTokenChecker(
IHttpClientFactory httpClientFactory,
CustomOAuthSettings settings)
{
_httpClientFactory = httpClientFactory;
_settings = settings;
}
public async Task<AnyOf<TokenResponse?, string>> CheckTokenAndGetUsernameAsync(
string code,
TokenCheckerSettings settings,
CancellationToken cancellationToken)
{
var codeVerifier = settings.GetParameter("code_verifier");
var redirectUri = settings.GetRedirectUri();
var client = _httpClientFactory.CreateClient("CustomOAuth");
var tokenRequest = new Dictionary<string, string>
{
["code"] = code,
["client_id"] = _settings.ClientId,
["client_secret"] = _settings.ClientSecret,
["redirect_uri"] = redirectUri,
["grant_type"] = "authorization_code"
};
// Add PKCE if provided
if (!string.IsNullOrWhiteSpace(codeVerifier))
{
tokenRequest["code_verifier"] = codeVerifier;
}
var response = await client.PostAsync(
"https://oauth.provider.com/token",
new FormUrlEncodedContent(tokenRequest),
cancellationToken);
if (!response.IsSuccessStatusCode)
{
var error = await response.Content.ReadAsStringAsync(cancellationToken);
return error;
}
var tokenData = await response.Content.ReadFromJsonAsync<OAuthTokenResponse>(cancellationToken);
// Validate ID token and extract claims
var claims = ExtractClaims(tokenData.IdToken);
var username = claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value;
return new TokenResponse
{
Username = username ?? string.Empty,
Claims = claims
};
}
}
🔗 Related Packages
- Server Implementation:
Rystem.Authentication.Social- ASP.NET Core OAuth endpoints - Blazor Client:
Rystem.Authentication.Social.Blazor- Blazor UI components - React Client:
rystem.authentication.social.react- React/TypeScript hooks
📚 More Information
- Authentication Flow: https://rystem.net/mcp/prompts/auth-flow.md
- PKCE RFC 7636: https://tools.ietf.org/html/rfc7636
| 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
- Google.Apis.Auth (>= 1.73.0)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.15.0)
- Microsoft.IdentityModel.Tokens (>= 8.15.0)
- Rystem.DependencyInjection (>= 10.0.4)
- System.IdentityModel.Tokens.Jwt (>= 8.15.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Rystem.Authentication.Social.Abstractions:
| Package | Downloads |
|---|---|
|
Rystem.Authentication.Social
Rystem.Authentication.Social helps you to integrate with new .Net Identity system and social logins. |
|
|
Rystem.Authentication.Social.Blazor
Rystem.Authentication.Social helps you to integrate with new .Net Identity system and social logins. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.4 | 152 | 2/9/2026 |
| 10.0.3 | 48,811 | 1/28/2026 |
| 10.0.1 | 209,089 | 11/12/2025 |
| 9.1.3 | 408 | 9/2/2025 |
| 9.1.2 | 764,581 | 5/29/2025 |
| 9.1.1 | 97,850 | 5/2/2025 |
| 9.0.32 | 186,614 | 4/15/2025 |
| 9.0.31 | 5,869 | 4/2/2025 |
| 9.0.30 | 88,805 | 3/26/2025 |
| 9.0.29 | 9,042 | 3/18/2025 |
| 9.0.28 | 256 | 3/17/2025 |
| 9.0.27 | 253 | 3/16/2025 |
| 9.0.26 | 296 | 3/13/2025 |
| 9.0.25 | 52,173 | 3/9/2025 |
| 9.0.23 | 200 | 3/9/2025 |
| 9.0.21 | 380 | 3/6/2025 |
| 9.0.20 | 19,558 | 3/6/2025 |
| 9.0.19 | 335 | 3/6/2025 |
| 9.0.18 | 335 | 3/4/2025 |
| 9.0.17 | 212 | 3/1/2025 |