- proto/mcias/v1/: AdminService, AuthService, TokenService, AccountService, CredentialService; generated Go stubs in gen/ - internal/grpcserver: full handler implementations sharing all business logic (auth, token, db, crypto) with REST server; interceptor chain: logging -> auth (JWT alg-first + revocation) -> rate-limit (token bucket, 10 req/s, burst 10, per-IP) - internal/config: optional grpc_addr field in [server] section - cmd/mciassrv: dual-stack startup; gRPC/TLS listener on grpc_addr when configured; graceful shutdown of both servers in 15s window - cmd/mciasgrpcctl: companion gRPC CLI mirroring mciasctl commands (health, pubkey, account, role, token, pgcreds) using TLS with optional custom CA cert - internal/grpcserver/grpcserver_test.go: 20 tests via bufconn covering public RPCs, auth interceptor (no token, invalid, revoked -> 401), non-admin -> 403, Login/Logout/RenewToken/ValidateToken flows, AccountService CRUD, SetPGCreds/GetPGCreds AES-GCM round-trip, credential fields absent from all responses Security: JWT validation path identical to REST: alg header checked before signature, alg:none rejected, revocation table checked after sig. Authorization metadata value never logged by any interceptor. Credential fields (PasswordHash, TOTPSecret*, PGPassword) absent from all proto response messages — enforced by proto design and confirmed by test TestCredentialFieldsAbsentFromAccountResponse. Login dummy-Argon2 timing guard preserves timing uniformity for unknown users (same as REST handleLogin). TLS required at listener level; cmd/mciassrv uses credentials.NewServerTLSFromFile; no h2c offered. 137 tests pass, zero race conditions (go test -race ./...)
39 lines
1.2 KiB
Protocol Buffer
39 lines
1.2 KiB
Protocol Buffer
// AdminService: health check and public-key retrieval.
|
|
// These RPCs are public — no authentication is required.
|
|
syntax = "proto3";
|
|
|
|
package mcias.v1;
|
|
|
|
option go_package = "git.wntrmute.dev/kyle/mcias/gen/mcias/v1;mciasv1";
|
|
|
|
// HealthRequest carries no parameters.
|
|
message HealthRequest {}
|
|
|
|
// HealthResponse confirms the server is operational.
|
|
message HealthResponse {
|
|
string status = 1; // "ok"
|
|
}
|
|
|
|
// GetPublicKeyRequest carries no parameters.
|
|
message GetPublicKeyRequest {}
|
|
|
|
// GetPublicKeyResponse returns the Ed25519 public key in JWK format fields.
|
|
// The "x" field is the base64url-encoded 32-byte public key.
|
|
message GetPublicKeyResponse {
|
|
string kty = 1; // "OKP"
|
|
string crv = 2; // "Ed25519"
|
|
string use = 3; // "sig"
|
|
string alg = 4; // "EdDSA"
|
|
string x = 5; // base64url-encoded public key bytes
|
|
}
|
|
|
|
// AdminService exposes health and key-material endpoints.
|
|
// All RPCs bypass the auth interceptor.
|
|
service AdminService {
|
|
// Health returns OK when the server is operational.
|
|
rpc Health(HealthRequest) returns (HealthResponse);
|
|
|
|
// GetPublicKey returns the Ed25519 public key used to verify JWTs.
|
|
rpc GetPublicKey(GetPublicKeyRequest) returns (GetPublicKeyResponse);
|
|
}
|