Add Ping backend

.NET 10 solution for Ping, a Discord style chat app: Domain, Application
and Infrastructure projects plus the Api host. SignalR for chat and
presence, LiveKit for call tokens, EF Core on Postgres, S3 compatible
storage for attachments, and OIDC auth shared with the Musify Zitadel
instance. Includes the Compose stack for local development.
This commit is contained in:
2026-09-21 19:32:55 +02:00
commit 0623875dfa
126 changed files with 5048 additions and 0 deletions
@@ -0,0 +1,32 @@
using System.Reflection;
using System.Security.Claims;
namespace Ping.Api.Authentication;
public sealed class CurrentUser : IBindableFromHttpContext<CurrentUser>
{
private CurrentUser(ClaimsPrincipal principal)
{
Principal = principal;
IsAuthenticated = principal.Identity?.IsAuthenticated ?? false;
var rawId = principal.FindFirstValue(ClaimTypes.NameIdentifier);
if (long.TryParse(rawId, out var id) && id != 0)
Id = id;
Username = principal.FindFirstValue(ClaimTypes.Name);
}
public ClaimsPrincipal Principal { get; }
public bool IsAuthenticated { get; }
public long? Id { get; }
public string? Username { get; }
public long RequiredId => Id ?? throw new InvalidOperationException("User Id claim is missing or invalid.");
public static ValueTask<CurrentUser?> BindAsync(HttpContext context, ParameterInfo parameter) =>
ValueTask.FromResult<CurrentUser?>(new CurrentUser(context.User));
}