FerrisKey is built using modern software architectures principles to ensure maintainability, testability, and scalability. This section provides a comprehensive understanding of how the system is structured and how its components work together.
FerrisKey follows the Hexagonal Architecture pattern (also known as Ports and Adapters), which provides clean separation of concerns makes the codebase highly modular and adaptable to change.
The hexagonale architectures organizes code into distinct layers with clear boundaries:
┌─────────────────────────────────────────────────────────┐
│ Infrastructure │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Application │ │
│ │ ┌─────────────────────────────────────────┐ │ │
│ │ │ Domain │ │ │
│ │ │ ┌─────────────────────────────────┐ │ │ │
│ │ │ │ Entities │ │ │ │
│ │ │ └─────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
/core/src/domain)The innermost layer containing pure business logic with no external dependencies.
Key Components:
Example DOmain Modules:
domain/
├── authentication/ # Authentication flows & logic
├── client/ # OAuth2/OIDC client management
├── credential/ # Password, TOTP, WebAuthn handling
├── realm/ # Multi-tenant realm isolation
├── role/ # Role-based access control
├── user/ # User lifecycle management
├── trident/ # MFA & security scopes
├── seawatch/ # Audit logging & observability
├── webhook/ # Event-driven extensibility
└── jwt/ # Token generation & validation
/core/src/application)Orchestrates domain services and defines use cases. Acts as a bridge between the domain and infrastructure.
Key Responsibilities:
type RealmRepo = PostgresRealmRepository;
type ClientRepo = PostgresClientRepository;
type UserRepo = PostgresUserRepository;
type UserRoleRepo = PostgresUserRoleRepository;
type SecurityEventRepo = PostgresSecurityEventRepository;
type CredentialRepo = PostgresCredentialRepository;
type WebhookRepo = PostgresWebhookRepository;
type RedirectUriRepo = PostgresRedirectUriRepository;
type RoleRepo = PostgresRoleRepository;
type HealthCheckRepo = PostgresHealthCheckRepository;
type RecoveryCodeRepo = RandBytesRecoveryCodeRepository<10, Argon2HasherRepository>;
type AuthSessionRepo = PostgresAuthSessionRepository;
type HasherRepo = Argon2HasherRepository;
type UserRequiredActionRepo = PostgresUserRequiredActionRepository;
type KeystoreRepo = PostgresKeyStoreRepository;
type RefreshTokenRepo = PostgresRefreshTokenRepository;
#[derive(Clone)]
pub struct ApplicationService {
pub(crate) security_event_service:
SecurityEventServiceImpl<RealmRepo, UserRepo, ClientRepo, UserRoleRepo, SecurityEventRepo>,
pub(crate) credential_service:
CredentialServiceImpl<RealmRepo, UserRepo, ClientRepo, UserRoleRepo, CredentialRepo>,
pub(crate) client_service: ClientServiceImpl<
RealmRepo,
UserRepo,
ClientRepo,
UserRoleRepo,
WebhookRepo,
RedirectUriRepo,
RoleRepo,
SecurityEventRepo,
>,
pub(crate) realm_service:
RealmServiceImpl<RealmRepo, UserRepo, ClientRepo, UserRoleRepo, RoleRepo, WebhookRepo>,
}
/core/src/infrastructure)Implements the ports defined by the domain layer, providing concrete adapters for external systems.
Key Components:
FerrisKey consists of several interconnected components that work together to provide a complete IAM solution:
/core)The heart of FerrisKey containing all business logic
Technologies:
/api)HTTP REST API exposing FerrisKey functionalities to clients.
Technologies:
Key Features:
/front)Modern React application providing the administrative UI for FerrisKey.
Technologies:
Key Features:
/operator)CLoud-native deployment automation for Kubernetes environments.
Technologies:
Key Features:
All data access goes through repository interfaces, making the system database-agnostic and easily testable.
Domain Layer: trait UserRepository
↓
Infrastructure: PostgresUserRepository
↓
Database: PostgreSQL with SeaORM
Business logic is encapsulated in service classes that orchestrate multiple repositories and domain objects.
Services receive their dependencies through constructor injection, enabling easy testing and loose coupling.
Webhook system allows external systems to react to FerrisKey events without tight coupling.