Implement Auth service — login, register, sessions, account properties, OAuth stubs

- auth.proto: add account property CRUD messages + OAuthProvider enum + LoginWithOAuth
  (all OAuth providers disabled via Redis feature flags: oauth_<provider>_enabled)
- SOR.Auth: full AuthGrpcHandler — password auth, session tokens (32-byte random,
  SHA-256 hash in Postgres, raw token in Redis with TTL), ValidateToken with
  Redis fast-path + Postgres slow-path fallback, Logout with dual revocation
- AccountProperty entity: flexible key-value bag per account (snake_case keys,
  string values); upsert semantics; indexed on (AccountId, Key)
- SOR.Auth/ServiceRegistration: registers Identity DbContext + UserManager + roles
- SOR.Host/appsettings.json: add Postgres Default connection string
- AddAccountProperties migration applied to pg-forge-01

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-02-25 08:07:19 -05:00
co-authored by Claude Happy
parent 6f9ed0668f
commit 1974dffdb6
10 changed files with 923 additions and 122 deletions
@@ -0,0 +1,27 @@
namespace SOR.Database.Entities.Identity;
/// <summary>
/// A flexible key-value property bag attached to an account.
/// Use for lightweight per-player flags, preferences, and metadata that do not
/// warrant a dedicated column — e.g. tutorial progress, notification prefs,
/// experimental feature opt-ins, admin notes.
///
/// Cross-cutting conventions:
/// - Key: lowercase, snake_case (e.g. "tutorial_completed", "beta_tester")
/// - Value: stored as string; caller interprets type (bool → "true"/"false",
/// int → decimal string, JSON → serialized object)
/// - Unique index on (AccountId, Key) enforced at DB + EF level.
/// </summary>
public sealed class AccountProperty
{
public Guid Id { get; set; }
/// <summary>Bare Guid reference — no EF navigation to Account (same schema, but simpler).</summary>
public Guid AccountId { get; set; }
public string Key { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
public DateTimeOffset CreatedAt { get; set; }
public DateTimeOffset UpdatedAt { get; set; }
}