Contribute to rustwarden¶
This document describes the interactions between gitrust and the rustwarden-core framework, and explains how to extend the framework on the gitrust side without modifying its sources.
Framework services used¶
| Service | Usage dans gitrust |
|---|---|
UserService |
CRUD users, roles, delete_user, admin_reset_password, change_password_direct, unassign_role_from_user |
RoleService |
Liste/création/suppression roles, get_role_by_name |
PasswordService |
hash_password (async), verify_password (async), generate_secure_password |
ResourceService |
register/unregister repos, set_public, effective_permission, find_by_type_and_id |
AuthService |
authenticate_user (login) |
JwtService |
generate_token (login) |
EmailValidationService |
Vérification email |
PasswordResetService |
Flux "mot de passe oublié" |
AppSettingsService |
get_bool pour registration_enabled |
Hook on_user_deleted implemented¶
The on_user_deleted hook in gitrust-hooks deletes the user directory on the filesystem (repos_base_path/username/) before the DB cascade. Called automatically by UserService::delete_user.
Fundamental rule¶
Never modify crates/rustwarden-core/. This crate is the shared framework. Any extension goes through:
- wrappers on the
gitrust-coreside (services that delegate to the framework) - Impls traits (
RustwardenHooksingitrust-hooks) - Extensions via Axum injection mechanisms (
Extension,State)
No bypass in progress¶
All old workarounds (direct entities, manual hashes) have been replaced by framework services following the 2026-03-26 update.
Add a feature requiring a missing framework service¶
If a necessary service does not exist in rustwarden-core:
- Implement the service on the
gitrust-coreside by reusing the framework primitives (ex:PasswordService::hash_passwordfor hashing) - If the functionality is generic and would benefit the framework itself, open an issue or an upstream PR on the rustwarden-core repository
- Do not duplicate auth, session, or JWT logic — these areas belong exclusively to the framework
Extension pattern via hooks¶
The hooks (gitrust-hooks/src/lib.rs) implement RustwardenHooks and are injected into the Axum router on startup:
// Dans main.rs
let hooks = Arc::new(GitrustHooks::new(config.clone()));
// Passé via .merge_routes(app_routes(hooks))
// Puis disponible via axum::Extension dans les handlers
To react to a new framework event, add the corresponding method in the RustwardenHooks impl of gitrust-hooks, without touching the framework code that emits the event.