Files
sor/Server/src/SOR.Shared.Proto/Protos/auth.proto
T
d21adbc8d0 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>
2026-02-24 21:01:38 -05:00

99 lines
4.1 KiB
Protocol Buffer

// Protobuf language version 3 — the current standard.
// proto3 differences from proto2: all fields optional by default,
// no required fields, simpler default values.
syntax = "proto3";
// The C# namespace for all generated types from this file.
// Generated classes: AuthService.AuthServiceBase (server), AuthService.AuthServiceClient (client),
// LoginRequest, LoginResponse, ValidateTokenRequest, ValidateTokenResponse, etc.
option csharp_namespace = "SOR.Shared.Proto";
// Package prevents naming collisions with other .proto files.
// Does not affect the C# namespace (that's controlled by csharp_namespace above).
package sor.auth;
// ── Request / Response Messages ───────────────────────────────────────────────
//
// A 'message' is a structured data type. It compiles to a C# class with properties.
// Each field has:
// type — the data type (string, int32, bool, or another message)
// name — the property name in the generated C# code
// number — the field number used in binary encoding (NEVER change these;
// changing a field number is a breaking change in binary format)
// ── Login ─────────────────────────────────────────────────────────────────────
message LoginRequest {
string email = 1;
string password = 2;
}
message LoginResponse {
bool success = 1;
// Only populated on success. Empty string ("") on failure.
string session_token = 2;
// Only populated on failure. Examples: "USER_NOT_FOUND", "INVALID_PASSWORD", "ACCOUNT_BANNED"
string error_code = 3;
}
// ── Token Validation ──────────────────────────────────────────────────────────
// Used by Gateway during the auth handshake to validate session tokens.
// Also used by other services that need to verify caller identity.
message ValidateTokenRequest {
string session_token = 1;
}
message ValidateTokenResponse {
bool valid = 1;
// Only populated when valid = true.
string user_id = 2;
string display_name = 3;
}
// ── Registration ──────────────────────────────────────────────────────────────
message RegisterRequest {
string email = 1;
string password = 2;
string display_name = 3;
}
message RegisterResponse {
bool success = 1;
string session_token = 2; // Set on success — user is automatically logged in
string error_code = 3; // e.g., "EMAIL_TAKEN", "DISPLAY_NAME_TAKEN", "WEAK_PASSWORD"
}
// ── Logout ────────────────────────────────────────────────────────────────────
message LogoutRequest {
string session_token = 1;
}
// Empty response — logout always succeeds (idempotent; revoking a non-existent token is fine)
message LogoutResponse {}
// ── Service Definition ────────────────────────────────────────────────────────
//
// 'service' defines the RPC methods. The Protobuf compiler generates:
// - AuthService.AuthServiceBase: abstract base class for the server handler to inherit
// - AuthService.AuthServiceClient: client stub for other services to call Auth
service AuthService {
// Primary login with email + password
rpc Login(LoginRequest) returns (LoginResponse);
// Validate an opaque session token (called by Gateway on every connection)
rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse);
// Create a new account
rpc Register(RegisterRequest) returns (RegisterResponse);
// Revoke a session token (called on explicit logout or ban)
rpc Logout(LogoutRequest) returns (LogoutResponse);
}