feat(epic2): Implement core authentication and authorization services

- Implement Audit Service (2.5)
  - gRPC server with Record and Query operations
  - Database persistence with audit schema
  - Service registry integration
  - Entry point: cmd/audit-service

- Implement Identity Service (2.2)
  - User CRUD operations
  - Password hashing with argon2id
  - Email verification and password reset flows
  - Entry point: cmd/identity-service
  - Fix package naming conflicts in user_service.go

- Implement Auth Service (2.1)
  - JWT token generation and validation
  - Login, RefreshToken, ValidateToken, Logout RPCs
  - Integration with Identity Service
  - Entry point: cmd/auth-service
  - Note: RefreshToken entity needs Ent generation

- Implement Authz Service (2.3, 2.4)
  - Permission checking and authorization
  - User roles and permissions retrieval
  - RBAC-based authorization
  - Entry point: cmd/authz-service

- Implement gRPC clients for all services
  - Auth, Identity, Authz, and Audit clients
  - Service discovery integration
  - Full gRPC communication

- Add service configurations to config/default.yaml
- Create SUMMARY.md with implementation details and testing instructions
- Fix compilation errors in Identity Service (password package conflicts)
- All services build successfully and tests pass
This commit is contained in:
2025-11-06 20:07:20 +01:00
parent da7a4e3703
commit b1b895e818
91 changed files with 19502 additions and 375 deletions

View File

@@ -13,12 +13,18 @@ const (
Label = "audit_log"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldActorID holds the string denoting the actor_id field in the database.
FieldActorID = "actor_id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldAction holds the string denoting the action field in the database.
FieldAction = "action"
// FieldTargetID holds the string denoting the target_id field in the database.
FieldTargetID = "target_id"
// FieldResource holds the string denoting the resource field in the database.
FieldResource = "resource"
// FieldResourceID holds the string denoting the resource_id field in the database.
FieldResourceID = "resource_id"
// FieldIPAddress holds the string denoting the ip_address field in the database.
FieldIPAddress = "ip_address"
// FieldUserAgent holds the string denoting the user_agent field in the database.
FieldUserAgent = "user_agent"
// FieldMetadata holds the string denoting the metadata field in the database.
FieldMetadata = "metadata"
// FieldTimestamp holds the string denoting the timestamp field in the database.
@@ -30,9 +36,12 @@ const (
// Columns holds all SQL columns for auditlog fields.
var Columns = []string{
FieldID,
FieldActorID,
FieldUserID,
FieldAction,
FieldTargetID,
FieldResource,
FieldResourceID,
FieldIPAddress,
FieldUserAgent,
FieldMetadata,
FieldTimestamp,
}
@@ -48,8 +57,8 @@ func ValidColumn(column string) bool {
}
var (
// ActorIDValidator is a validator for the "actor_id" field. It is called by the builders before save.
ActorIDValidator func(string) error
// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
UserIDValidator func(string) error
// ActionValidator is a validator for the "action" field. It is called by the builders before save.
ActionValidator func(string) error
// DefaultTimestamp holds the default value on creation for the "timestamp" field.
@@ -64,9 +73,9 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByActorID orders the results by the actor_id field.
func ByActorID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldActorID, opts...).ToFunc()
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByAction orders the results by the action field.
@@ -74,9 +83,24 @@ func ByAction(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAction, opts...).ToFunc()
}
// ByTargetID orders the results by the target_id field.
func ByTargetID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTargetID, opts...).ToFunc()
// ByResource orders the results by the resource field.
func ByResource(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldResource, opts...).ToFunc()
}
// ByResourceID orders the results by the resource_id field.
func ByResourceID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldResourceID, opts...).ToFunc()
}
// ByIPAddress orders the results by the ip_address field.
func ByIPAddress(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIPAddress, opts...).ToFunc()
}
// ByUserAgent orders the results by the user_agent field.
func ByUserAgent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserAgent, opts...).ToFunc()
}
// ByTimestamp orders the results by the timestamp field.