- Add VerifyPassword RPC to Identity Service - Added to proto file and generated code - Implemented in Identity Service gRPC server - Added to Identity Service client interface and gRPC client - Complete RefreshToken implementation - Store refresh tokens in database using RefreshToken entity - Validate refresh tokens with expiration checking - Revoke refresh tokens on logout and token rotation - Integrate Authz Service for role retrieval - Added AuthzServiceClient to Auth Service - Get user roles during login and token refresh - Gracefully handle Authz Service failures - Require JWT secret in configuration - Removed default secret fallback - Service fails to start if JWT secret is not configured - Fix Consul health checks for Docker - Services now register with Docker service names (e.g., audit-service) - Allows Consul (in Docker) to reach services via Docker DNS - Health checks use gRPC service names instead of localhost This completes all TODOs in auth_service_fx.go and fixes the Consul health check failures in Docker environments.
66 lines
2.2 KiB
Go
66 lines
2.2 KiB
Go
// Package services provides service client interfaces for inter-service communication.
|
|
package services
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// IdentityServiceClient is the interface for communicating with the Identity Service.
|
|
type IdentityServiceClient interface {
|
|
// GetUser retrieves a user by ID.
|
|
GetUser(ctx context.Context, id string) (*User, error)
|
|
|
|
// GetUserByEmail retrieves a user by email address.
|
|
GetUserByEmail(ctx context.Context, email string) (*User, error)
|
|
|
|
// CreateUser creates a new user.
|
|
CreateUser(ctx context.Context, user *CreateUserRequest) (*User, error)
|
|
|
|
// UpdateUser updates an existing user.
|
|
UpdateUser(ctx context.Context, id string, user *UpdateUserRequest) (*User, error)
|
|
|
|
// DeleteUser deletes a user.
|
|
DeleteUser(ctx context.Context, id string) error
|
|
|
|
// VerifyEmail verifies a user's email address using a verification token.
|
|
VerifyEmail(ctx context.Context, token string) error
|
|
|
|
// RequestPasswordReset requests a password reset token.
|
|
RequestPasswordReset(ctx context.Context, email string) error
|
|
|
|
// ResetPassword resets a user's password using a reset token.
|
|
ResetPassword(ctx context.Context, token, newPassword string) error
|
|
|
|
// VerifyPassword verifies a user's password and returns the user if valid.
|
|
VerifyPassword(ctx context.Context, email, password string) (*User, error)
|
|
}
|
|
|
|
// User represents a user in the system.
|
|
type User struct {
|
|
ID string `json:"id"`
|
|
Email string `json:"email"`
|
|
Username string `json:"username"`
|
|
FirstName string `json:"first_name"`
|
|
LastName string `json:"last_name"`
|
|
EmailVerified bool `json:"email_verified"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
// CreateUserRequest contains the data needed to create a new user.
|
|
type CreateUserRequest struct {
|
|
Email string `json:"email"`
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
FirstName string `json:"first_name"`
|
|
LastName string `json:"last_name"`
|
|
}
|
|
|
|
// UpdateUserRequest contains the data needed to update a user.
|
|
type UpdateUserRequest struct {
|
|
Email *string `json:"email,omitempty"`
|
|
Username *string `json:"username,omitempty"`
|
|
FirstName *string `json:"first_name,omitempty"`
|
|
LastName *string `json:"last_name,omitempty"`
|
|
}
|