Refactor core kernel and infrastructure to support true microservices architecture where services are independently deployable. Phase 1: Core Kernel Cleanup - Remove database provider from CoreModule (services create their own) - Update ProvideHealthRegistry to not depend on database - Add schema support to database client (NewClientWithSchema) - Update main entry point to remove database dependency - Core kernel now provides only: config, logger, error bus, health, metrics, tracer, service registry Phase 2: Service Registry Implementation - Create ServiceRegistry interface (pkg/registry/registry.go) - Implement Consul registry (internal/registry/consul/consul.go) - Add Consul dependency (github.com/hashicorp/consul/api) - Add registry configuration to config/default.yaml - Add ProvideServiceRegistry() to DI container Phase 3: Service Client Interfaces - Create service client interfaces: - pkg/services/auth.go - AuthServiceClient - pkg/services/identity.go - IdentityServiceClient - pkg/services/authz.go - AuthzServiceClient - pkg/services/audit.go - AuditServiceClient - Create ServiceClientFactory (internal/client/factory.go) - Create stub gRPC client implementations (internal/client/grpc/) - Add ProvideServiceClientFactory() to DI container Phase 4: gRPC Service Definitions - Create proto files for all core services: - api/proto/auth.proto - api/proto/identity.proto - api/proto/authz.proto - api/proto/audit.proto - Add generate-proto target to Makefile Phase 5: API Gateway Implementation - Create API Gateway service entry point (cmd/api-gateway/main.go) - Create Gateway implementation (services/gateway/gateway.go) - Add gateway configuration to config/default.yaml - Gateway registers with Consul and routes requests to backend services All code compiles successfully. Core services (Auth, Identity, Authz, Audit) will be implemented in Epic 2 using these foundations.
72 lines
1.8 KiB
Protocol Buffer
72 lines
1.8 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package auth.v1;
|
|
|
|
option go_package = "git.dcentral.systems/toolz/goplt/api/proto/generated/auth/v1;authv1";
|
|
|
|
// AuthService provides authentication operations.
|
|
service AuthService {
|
|
// Login authenticates a user and returns access and refresh tokens.
|
|
rpc Login(LoginRequest) returns (LoginResponse);
|
|
|
|
// RefreshToken refreshes an access token using a refresh token.
|
|
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse);
|
|
|
|
// ValidateToken validates a JWT token and returns the token claims.
|
|
rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse);
|
|
|
|
// Logout invalidates a refresh token.
|
|
rpc Logout(LogoutRequest) returns (LogoutResponse);
|
|
}
|
|
|
|
// LoginRequest contains login credentials.
|
|
message LoginRequest {
|
|
string email = 1;
|
|
string password = 2;
|
|
}
|
|
|
|
// LoginResponse contains authentication tokens.
|
|
message LoginResponse {
|
|
string access_token = 1;
|
|
string refresh_token = 2;
|
|
int64 expires_in = 3; // seconds
|
|
string token_type = 4; // "Bearer"
|
|
}
|
|
|
|
// RefreshTokenRequest contains a refresh token.
|
|
message RefreshTokenRequest {
|
|
string refresh_token = 1;
|
|
}
|
|
|
|
// RefreshTokenResponse contains new authentication tokens.
|
|
message RefreshTokenResponse {
|
|
string access_token = 1;
|
|
string refresh_token = 2;
|
|
int64 expires_in = 3; // seconds
|
|
string token_type = 4; // "Bearer"
|
|
}
|
|
|
|
// ValidateTokenRequest contains a JWT token to validate.
|
|
message ValidateTokenRequest {
|
|
string token = 1;
|
|
}
|
|
|
|
// ValidateTokenResponse contains token claims.
|
|
message ValidateTokenResponse {
|
|
string user_id = 1;
|
|
string email = 2;
|
|
repeated string roles = 3;
|
|
int64 expires_at = 4;
|
|
}
|
|
|
|
// LogoutRequest contains a refresh token to invalidate.
|
|
message LogoutRequest {
|
|
string refresh_token = 1;
|
|
}
|
|
|
|
// LogoutResponse indicates success.
|
|
message LogoutResponse {
|
|
bool success = 1;
|
|
}
|
|
|