Add networking foundation — 9-project C# solution (compiles clean)

Implements the modular networking layer for SOR Server:
- SOR.Networking.Abstractions: pure interfaces (ITransport, IClientConnection,
  IMessageSerializer, IMessageDispatcher, IMessageHandler, IEventBus, IClientPush)
- SOR.Networking.WebSocket: ITransport + IClientConnection over System.Net.WebSockets
- SOR.Networking.Nats: IEventBus over NATS.Net (INatsConnection)
- SOR.Networking.Redis: IClientPush over Redis Pub/Sub
- SOR.Shared: ServiceResult<T>, RedisKeys, NatsSubjects, ServerMessage, JSON serializer
- SOR.Shared.Proto: auth.proto with gRPC AuthService contract
- SOR.Gateway: accept loop, auth handshake, dispatcher, Redis push subscriber
- SOR.Auth: stub gRPC handler (placeholder responses)
- SOR.Host: multi-service runner via ENABLED_SERVICES env var; wires all DI

All concrete implementations are wired exclusively in SOR.Host — every transport,
broker, and push implementation can be swapped by changing only Program.cs.

dotnet build SOR.slnx → 0 errors, 0 warnings

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-24 21:01:38 -05:00
co-authored by Claude Happy
parent 0f95a0721b
commit d21adbc8d0
52 changed files with 3522 additions and 0 deletions
@@ -0,0 +1,98 @@
namespace SOR.Auth.Handlers;
using Grpc.Core;
using Microsoft.Extensions.Logging;
using SOR.Shared.Proto;
/// <summary>
/// gRPC handler stub for the Auth service.
///
/// STATUS: Foundation stub only. All methods return placeholder responses.
/// Real business logic (database, password hashing, session management)
/// will be implemented when the Auth service is built out.
///
/// This stub is sufficient for the networking foundation phase:
/// - The Gateway calls ValidateToken — this returns Valid=false for all tokens,
/// meaning no connections will authenticate until the real implementation is in place.
/// - The project compiles and the gRPC route is registered correctly.
///
/// When implementing for real:
/// 1. Add IAuthService injection to the constructor
/// 2. Replace each return statement with the actual service call
/// 3. Map ServiceResult{T} to the Protobuf response message
/// </summary>
public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
{
private readonly ILogger<AuthGrpcHandler> _logger;
public AuthGrpcHandler(ILogger<AuthGrpcHandler> logger)
{
_logger = logger;
}
/// <summary>
/// Validates a session token.
/// STUB: always returns Valid=false until real implementation is added.
/// </summary>
public override Task<ValidateTokenResponse> ValidateToken(
ValidateTokenRequest request,
ServerCallContext context)
{
_logger.LogDebug("ValidateToken called (stub) for token length={Length}",
request.SessionToken.Length);
// STUB: return invalid until real Auth business logic is implemented.
return Task.FromResult(new ValidateTokenResponse
{
Valid = false,
UserId = string.Empty,
DisplayName = string.Empty
});
}
/// <summary>
/// Authenticates a user with email + password.
/// STUB: always returns failure.
/// </summary>
public override Task<LoginResponse> Login(
LoginRequest request,
ServerCallContext context)
{
_logger.LogDebug("Login called (stub) for email={Email}", request.Email);
return Task.FromResult(new LoginResponse
{
Success = false,
ErrorCode = "NOT_IMPLEMENTED"
});
}
/// <summary>
/// Registers a new user account.
/// STUB: always returns failure.
/// </summary>
public override Task<RegisterResponse> Register(
RegisterRequest request,
ServerCallContext context)
{
_logger.LogDebug("Register called (stub)");
return Task.FromResult(new RegisterResponse
{
Success = false,
ErrorCode = "NOT_IMPLEMENTED"
});
}
/// <summary>
/// Revokes a session token.
/// STUB: no-op (returns success — revocation of non-existent tokens is idempotent).
/// </summary>
public override Task<LogoutResponse> Logout(
LogoutRequest request,
ServerCallContext context)
{
_logger.LogDebug("Logout called (stub)");
return Task.FromResult(new LogoutResponse());
}
}