feat(auth): Complete Auth Service implementation and fix Consul health checks

- 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.
This commit is contained in:
2025-11-06 21:26:34 +01:00
parent b02c1d44c8
commit 04022b835e
34 changed files with 6775 additions and 90 deletions

View File

@@ -64,6 +64,37 @@ var (
Columns: PermissionsColumns,
PrimaryKey: []*schema.Column{PermissionsColumns[0]},
}
// RefreshTokensColumns holds the columns for the "refresh_tokens" table.
RefreshTokensColumns = []*schema.Column{
{Name: "id", Type: field.TypeString, Unique: true},
{Name: "user_id", Type: field.TypeString},
{Name: "token_hash", Type: field.TypeString},
{Name: "expires_at", Type: field.TypeTime},
{Name: "created_at", Type: field.TypeTime},
}
// RefreshTokensTable holds the schema information for the "refresh_tokens" table.
RefreshTokensTable = &schema.Table{
Name: "refresh_tokens",
Columns: RefreshTokensColumns,
PrimaryKey: []*schema.Column{RefreshTokensColumns[0]},
Indexes: []*schema.Index{
{
Name: "refreshtoken_user_id",
Unique: false,
Columns: []*schema.Column{RefreshTokensColumns[1]},
},
{
Name: "refreshtoken_token_hash",
Unique: false,
Columns: []*schema.Column{RefreshTokensColumns[2]},
},
{
Name: "refreshtoken_expires_at",
Unique: false,
Columns: []*schema.Column{RefreshTokensColumns[3]},
},
},
}
// RolesColumns holds the columns for the "roles" table.
RolesColumns = []*schema.Column{
{Name: "id", Type: field.TypeString, Unique: true},
@@ -182,6 +213,7 @@ var (
Tables = []*schema.Table{
AuditLogsTable,
PermissionsTable,
RefreshTokensTable,
RolesTable,
RolePermissionsTable,
UsersTable,