Documentation
¶
Overview ¶
Package handlers — admin.go
Gère les endpoints JSON du tableau de bord administrateur. Toutes les routes sont protégées par le middleware RequireAuth.
Endpoints :
- GET /admin/api/users → Liste des utilisateurs (fusion SQLite + Jellyfin)
- POST /admin/api/users/{id}/toggle → Active/désactive un compte (AD + Jellyfin)
- DELETE /admin/api/users/{id} → Suppression totale (AD + Jellyfin + SQLite)
Les erreurs partielles sont loggées mais ne bloquent pas les opérations restantes (ex: si l'utilisateur est déjà supprimé de l'AD, on continue avec Jellyfin et SQLite).
Package handlers contains JellyGate HTTP handlers.
Package handlers — invitations.go ¶
Gère le système d'invitations de JellyGate. La route POST /invite/{code} implémente un flux de création atomique :
- Validation SQLite (code, expiration, quota)
- Création LDAP (Active Directory)
- Création Jellyfin + application du profil → Rollback LDAP si échec
- Enregistrement SQLite (user + incrément used_count) → Rollback Jellyfin + LDAP si échec
- Notifications (email + webhooks) — pas de rollback
Package handlers — password_reset.go
Gère le flux complet de réinitialisation de mot de passe :
Demande (POST /reset/request) : - Recherche l'utilisateur par email ou username dans SQLite - Génère un token sécurisé (crypto/rand, 32 bytes, hex) - Insère dans la table password_resets (expiration 15 min) - Envoie l'email avec le lien de réinitialisation
Exécution (POST /reset/{code}) : - Vérifie le token (existence, expiration, non-utilisé) - Applique le nouveau mot de passe simultanément : • ldap.ResetPassword() — Active Directory • jellyfin.ResetPassword() — Jellyfin - Marque le token comme used = true
Package handlers â€â€� settings.go ¶
API REST pour la gestion des paramètres stockés en base (table settings). Permet de lire et sauvegarder la configuration générale, LDAP, SMTP et Webhooks depuis l'interface d'administration.
Routes :
- GET /admin/api/settings → Récupérer toute la configuration
- POST /admin/api/settings/general → Sauvegarder les paramètres généraux (langue)
- POST /admin/api/settings/ldap → Sauvegarder la config LDAP
- POST /admin/api/settings/smtp → Sauvegarder la config SMTP
- POST /admin/api/settings/webhooks → Sauvegarder la config Webhooks
- POST /admin/api/settings/backup → Sauvegarder la config de sauvegarde planifiée
Index ¶
- type APIResponse
- type AdminHandler
- func (h *AdminHandler) BanUser(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) BulkUsersAction(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) CreateInvitation(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) CreateMyInvitation(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) CreateUser(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) DashboardPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) DashboardStats(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) DeleteInvitation(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) EmailTemplatesPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ExtendAccess(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) GetMyAccount(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) GetMyInvitations(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) InvitationSecurityConfig(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) InvitationStats(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) InvitationsPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) LDAPPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ListInvitations(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ListUsers(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) LogsAPI(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) LogsPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) MyAccountPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) PendingActions(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) PendingActionsPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) PreviewInvitation(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ProfilesPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ResendEmailVerification(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ResendMyEmailVerification(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) SaveInvitationSecurityConfig(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) SecurityEvents(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) SecurityOverview(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) SecurityPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) SendUserPasswordReset(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) SetLDAPClient(ld *jgldap.Client)
- func (h *AdminHandler) SetMailer(m *mail.Mailer)
- func (h *AdminHandler) SettingsPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) StartExpirationJob(ctx context.Context)
- func (h *AdminHandler) SyncJellyfinUsers(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ToggleUser(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ToggleUserInvite(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UpdateMyAccount(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UpdateMyAccountAvatar(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UpdateMyPassword(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UpdateUser(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UserAvatar(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UserTimeline(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UsersPage(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) VerifyEmailPage(w http.ResponseWriter, r *http.Request)
- type AuditLogResponse
- type AuthHandler
- type AutomationHandler
- func (h *AutomationHandler) AutomationPage(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) CreateTask(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) DeleteTask(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) GetPresetByID(id string) (*config.JellyfinPolicyPreset, error)
- func (h *AutomationHandler) ListGroupMappings(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) ListLibraries(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) ListPresets(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) ListTasks(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) RunTaskNow(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) SaveGroupMappings(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) SavePresets(w http.ResponseWriter, r *http.Request)
- func (h *AutomationHandler) UpdateTask(w http.ResponseWriter, r *http.Request)
- type BackupHandler
- func (h *BackupHandler) CreateBackup(w http.ResponseWriter, r *http.Request)
- func (h *BackupHandler) DeleteBackup(w http.ResponseWriter, r *http.Request)
- func (h *BackupHandler) DownloadBackup(w http.ResponseWriter, r *http.Request)
- func (h *BackupHandler) ImportBackup(w http.ResponseWriter, r *http.Request)
- func (h *BackupHandler) ListBackups(w http.ResponseWriter, r *http.Request)
- func (h *BackupHandler) RestoreBackup(w http.ResponseWriter, r *http.Request)
- type BulkJellyfinPolicyPatch
- type BulkUsersActionRequest
- type CreateAdminUserRequest
- type CreateInvitationRequest
- type DashboardStatsResponse
- type InvitationHandler
- func (h *InvitationHandler) InvitePage(w http.ResponseWriter, r *http.Request)
- func (h *InvitationHandler) InviteSubmit(w http.ResponseWriter, r *http.Request)
- func (h *InvitationHandler) SetLDAPClient(ld *jgldap.Client)
- func (h *InvitationHandler) SetMailer(m *mail.Mailer)
- func (h *InvitationHandler) SetNotifier(n *notify.Notifier)
- func (h *InvitationHandler) VerifyEmailPage(w http.ResponseWriter, r *http.Request)
- func (h *InvitationHandler) VerifyEmailSubmit(w http.ResponseWriter, r *http.Request)
- type InvitationResponse
- type InvitationSponsorStats
- type PasswordResetHandler
- func (h *PasswordResetHandler) RequestPage(w http.ResponseWriter, r *http.Request)
- func (h *PasswordResetHandler) ResetPage(w http.ResponseWriter, r *http.Request)
- func (h *PasswordResetHandler) SetLDAPClient(ld *jgldap.Client)
- func (h *PasswordResetHandler) SetMailer(m *mail.Mailer)
- func (h *PasswordResetHandler) SubmitRequest(w http.ResponseWriter, r *http.Request)
- func (h *PasswordResetHandler) SubmitReset(w http.ResponseWriter, r *http.Request)
- type SettingsHandler
- func (h *SettingsHandler) ExportEmailTemplates(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) FetchJellyfinServerName(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) GetAll(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) ImportEmailTemplates(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) LDAPDryRun(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) PreviewEmailTemplate(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) RevokeAuthSessions(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) SaveAuthSession(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) SaveBackup(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) SaveEmailTemplates(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) SaveGeneral(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) SaveInvitationProfile(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) SaveLDAP(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) SaveSMTP(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) SaveWebhooks(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) TestJellyfinLDAPAuth(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) TestLDAPConnection(w http.ResponseWriter, r *http.Request)
- func (h *SettingsHandler) TestLDAPUserLookup(w http.ResponseWriter, r *http.Request)
- type UpdateMyAccountRequest
- type UpdateUserRequest
- type UserResponse
- type UserTimelineEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type APIResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
Errors []string `json:"errors,omitempty"`
}
APIResponse est l'enveloppe standard pour toutes les réponses JSON.
type AdminHandler ¶
type AdminHandler struct {
// contains filtered or unexported fields
}
AdminHandler gère les endpoints d'administration.
func NewAdminHandler ¶
func NewAdminHandler(cfg *config.Config, db *database.DB, jf *jellyfin.Client, ld *jgldap.Client, m *mail.Mailer, renderer *render.Engine) *AdminHandler
NewAdminHandler crée un nouveau handler d'administration.
func (*AdminHandler) BanUser ¶
func (h *AdminHandler) BanUser(w http.ResponseWriter, r *http.Request)
BanUser banni définitvement un utilisateur (désactivation + flag banni).
func (*AdminHandler) BulkUsersAction ¶
func (h *AdminHandler) BulkUsersAction(w http.ResponseWriter, r *http.Request)
BulkUsersAction applique une action de masse sur les utilisateurs sélectionnés.
func (*AdminHandler) CreateInvitation ¶
func (h *AdminHandler) CreateInvitation(w http.ResponseWriter, r *http.Request)
CreateInvitation crée un nouveau lien d'invitation avec un jeton robuste et logiques complexes (JFA-GO).
func (*AdminHandler) CreateMyInvitation ¶
func (h *AdminHandler) CreateMyInvitation(w http.ResponseWriter, r *http.Request)
CreateMyInvitation génère une invitation automatique (parrainage) basée sur le preset de l'utilisateur.
func (*AdminHandler) CreateUser ¶
func (h *AdminHandler) CreateUser(w http.ResponseWriter, r *http.Request)
CreateUser cree directement un compte utilisateur depuis l'admin.
func (*AdminHandler) DashboardPage ¶
func (h *AdminHandler) DashboardPage(w http.ResponseWriter, r *http.Request)
DashboardPage affiche la page principale du tableau de bord.
func (*AdminHandler) DashboardStats ¶
func (h *AdminHandler) DashboardStats(w http.ResponseWriter, r *http.Request)
DashboardStats retourne les données pour les graphiques du dashboard (AJAX).
func (*AdminHandler) DeleteInvitation ¶
func (h *AdminHandler) DeleteInvitation(w http.ResponseWriter, r *http.Request)
DeleteInvitation supprime brutalement l'invitation SQLite
func (*AdminHandler) DeleteUser ¶
func (h *AdminHandler) DeleteUser(w http.ResponseWriter, r *http.Request)
DeleteUser supprime un utilisateur de l'AD, de Jellyfin, puis de SQLite. Les erreurs partielles (ex: utilisateur déjà supprimé de l'AD) ne bloquent pas les suppressions restantes — tout est loggé.
func (*AdminHandler) EmailTemplatesPage ¶
func (h *AdminHandler) EmailTemplatesPage(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) ExtendAccess ¶
func (h *AdminHandler) ExtendAccess(w http.ResponseWriter, r *http.Request)
ExtendAccess ajoute une durée d'accès par défaut (30 jours) à l'utilisateur.
func (*AdminHandler) GetMyAccount ¶
func (h *AdminHandler) GetMyAccount(w http.ResponseWriter, r *http.Request)
GetMyAccount retourne les infos de l'utilisateur connecté.
func (*AdminHandler) GetMyInvitations ¶
func (h *AdminHandler) GetMyInvitations(w http.ResponseWriter, r *http.Request)
GetMyInvitations retourne les invitations créées par l'utilisateur connecté.
func (*AdminHandler) InvitationSecurityConfig ¶
func (h *AdminHandler) InvitationSecurityConfig(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) InvitationStats ¶
func (h *AdminHandler) InvitationStats(w http.ResponseWriter, r *http.Request)
InvitationStats retourne des statistiques de parrainage par createur d'invitations.
func (*AdminHandler) InvitationsPage ¶
func (h *AdminHandler) InvitationsPage(w http.ResponseWriter, r *http.Request)
InvitationsPage affiche la page de gestion des invitations.
func (*AdminHandler) LDAPPage ¶
func (h *AdminHandler) LDAPPage(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) ListInvitations ¶
func (h *AdminHandler) ListInvitations(w http.ResponseWriter, r *http.Request)
ListInvitations retourne les invitations SQLite avec pagination et recherche.
func (*AdminHandler) ListUsers ¶
func (h *AdminHandler) ListUsers(w http.ResponseWriter, r *http.Request)
ListUsers retourne la liste des utilisateurs avec pagination et recherche.
func (*AdminHandler) LogsAPI ¶
func (h *AdminHandler) LogsAPI(w http.ResponseWriter, r *http.Request)
LogsAPI retourne le journal d'audit en JSON avec filtres avances et export CSV/JSON.
func (*AdminHandler) LogsPage ¶
func (h *AdminHandler) LogsPage(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) MyAccountPage ¶
func (h *AdminHandler) MyAccountPage(w http.ResponseWriter, r *http.Request)
MyAccountPage affiche la page "Mon compte" pour l'utilisateur connecté.
func (*AdminHandler) PendingActions ¶
func (h *AdminHandler) PendingActions(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) PendingActionsPage ¶
func (h *AdminHandler) PendingActionsPage(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) PreviewInvitation ¶
func (h *AdminHandler) PreviewInvitation(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) ProfilesPage ¶
func (h *AdminHandler) ProfilesPage(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) ResendEmailVerification ¶
func (h *AdminHandler) ResendEmailVerification(w http.ResponseWriter, r *http.Request)
ResendEmailVerification renvoie un code de vérification à l'utilisateur connecté.
func (*AdminHandler) ResendMyEmailVerification ¶
func (h *AdminHandler) ResendMyEmailVerification(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) SaveInvitationSecurityConfig ¶
func (h *AdminHandler) SaveInvitationSecurityConfig(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) SecurityEvents ¶
func (h *AdminHandler) SecurityEvents(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) SecurityOverview ¶
func (h *AdminHandler) SecurityOverview(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) SecurityPage ¶
func (h *AdminHandler) SecurityPage(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) SendUserPasswordReset ¶
func (h *AdminHandler) SendUserPasswordReset(w http.ResponseWriter, r *http.Request)
SendUserPasswordReset crée et envoie un lien de réinitialisation à l'utilisateur ciblé.
func (*AdminHandler) SetLDAPClient ¶
func (h *AdminHandler) SetLDAPClient(ld *jgldap.Client)
SetLDAPClient remplace le client LDAP (rechargement à chaud).
func (*AdminHandler) SetMailer ¶
func (h *AdminHandler) SetMailer(m *mail.Mailer)
SetMailer remplace le Mailer SMTP (rechargement à chaud).
func (*AdminHandler) SettingsPage ¶
func (h *AdminHandler) SettingsPage(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) StartExpirationJob ¶
func (h *AdminHandler) StartExpirationJob(ctx context.Context)
StartExpirationJob lance une routine en arrière-plan qui vérifie périodiquement si des comptes utilisateurs ont expiré, afin de les désactiver automatiquement.
func (*AdminHandler) SyncJellyfinUsers ¶
func (h *AdminHandler) SyncJellyfinUsers(w http.ResponseWriter, r *http.Request)
SyncJellyfinUsers synchronise manuellement les utilisateurs Jellyfin dans la base locale.
func (*AdminHandler) ToggleUser ¶
func (h *AdminHandler) ToggleUser(w http.ResponseWriter, r *http.Request)
ToggleUser active ou désactive un utilisateur simultanément dans l'AD et dans Jellyfin, puis met à jour le statut SQLite.
func (*AdminHandler) ToggleUserInvite ¶
func (h *AdminHandler) ToggleUserInvite(w http.ResponseWriter, r *http.Request)
ToggleUserInvite active ou désactive le droit de créer des invitations pour un utilisateur.
func (*AdminHandler) UpdateMyAccount ¶
func (h *AdminHandler) UpdateMyAccount(w http.ResponseWriter, r *http.Request)
UpdateMyAccount met à jour les préférences et l'email de l'utilisateur connecté.
func (*AdminHandler) UpdateMyAccountAvatar ¶
func (h *AdminHandler) UpdateMyAccountAvatar(w http.ResponseWriter, r *http.Request)
UpdateMyAccountAvatar change la photo de profil Jellyfin de l'utilisateur connecté.
func (*AdminHandler) UpdateMyPassword ¶
func (h *AdminHandler) UpdateMyPassword(w http.ResponseWriter, r *http.Request)
UpdateMyPassword change le mot de passe de l'utilisateur sur Jellyfin.
func (*AdminHandler) UpdateUser ¶
func (h *AdminHandler) UpdateUser(w http.ResponseWriter, r *http.Request)
UpdateUser met à jour les informations éditables d'un utilisateur (email, parrainage, expiration).
func (*AdminHandler) UserAvatar ¶
func (h *AdminHandler) UserAvatar(w http.ResponseWriter, r *http.Request)
UserAvatar sert l'image de profil d'un utilisateur Jellyfin.
func (*AdminHandler) UserTimeline ¶
func (h *AdminHandler) UserTimeline(w http.ResponseWriter, r *http.Request)
UserTimeline retourne l'historique principal d'un utilisateur (audit + jalons internes).
func (*AdminHandler) UsersPage ¶
func (h *AdminHandler) UsersPage(w http.ResponseWriter, r *http.Request)
func (*AdminHandler) VerifyEmailPage ¶
func (h *AdminHandler) VerifyEmailPage(w http.ResponseWriter, r *http.Request)
type AuditLogResponse ¶
type AuditLogResponse struct {
ID int64 `json:"id"`
Action string `json:"action"`
Actor string `json:"actor"`
Target string `json:"target"`
RequestID string `json:"request_id,omitempty"`
Details string `json:"details"`
CreatedAt string `json:"created_at"`
}
AuditLogResponse représente une ligne formatée du journal d'audit JSON.
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
AuthHandler gere les routes d'authentification admin.
func NewAuthHandler ¶
func NewAuthHandler(cfg *config.Config, db *database.DB, jf *jellyfin.Client, renderer *render.Engine) *AuthHandler
NewAuthHandler cree un nouveau AuthHandler.
func (*AuthHandler) LoginPage ¶
func (h *AuthHandler) LoginPage(w http.ResponseWriter, r *http.Request)
LoginPage affiche la page de connexion admin (GET /admin/login).
func (*AuthHandler) LoginSubmit ¶
func (h *AuthHandler) LoginSubmit(w http.ResponseWriter, r *http.Request)
LoginSubmit traite la soumission du formulaire de connexion (POST /admin/login).
func (*AuthHandler) Logout ¶
func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request)
Logout deconnecte l'utilisateur en supprimant le cookie de session.
type AutomationHandler ¶
type AutomationHandler struct {
// contains filtered or unexported fields
}
func NewAutomationHandler ¶
func (*AutomationHandler) AutomationPage ¶
func (h *AutomationHandler) AutomationPage(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) CreateTask ¶
func (h *AutomationHandler) CreateTask(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) DeleteTask ¶
func (h *AutomationHandler) DeleteTask(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) GetPresetByID ¶
func (h *AutomationHandler) GetPresetByID(id string) (*config.JellyfinPolicyPreset, error)
func (*AutomationHandler) ListGroupMappings ¶
func (h *AutomationHandler) ListGroupMappings(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) ListLibraries ¶
func (h *AutomationHandler) ListLibraries(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) ListPresets ¶
func (h *AutomationHandler) ListPresets(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) ListTasks ¶
func (h *AutomationHandler) ListTasks(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) RunTaskNow ¶
func (h *AutomationHandler) RunTaskNow(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) SaveGroupMappings ¶
func (h *AutomationHandler) SaveGroupMappings(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) SavePresets ¶
func (h *AutomationHandler) SavePresets(w http.ResponseWriter, r *http.Request)
func (*AutomationHandler) UpdateTask ¶
func (h *AutomationHandler) UpdateTask(w http.ResponseWriter, r *http.Request)
type BackupHandler ¶
type BackupHandler struct {
// contains filtered or unexported fields
}
func NewBackupHandler ¶
func (*BackupHandler) CreateBackup ¶
func (h *BackupHandler) CreateBackup(w http.ResponseWriter, r *http.Request)
func (*BackupHandler) DeleteBackup ¶
func (h *BackupHandler) DeleteBackup(w http.ResponseWriter, r *http.Request)
func (*BackupHandler) DownloadBackup ¶
func (h *BackupHandler) DownloadBackup(w http.ResponseWriter, r *http.Request)
func (*BackupHandler) ImportBackup ¶
func (h *BackupHandler) ImportBackup(w http.ResponseWriter, r *http.Request)
func (*BackupHandler) ListBackups ¶
func (h *BackupHandler) ListBackups(w http.ResponseWriter, r *http.Request)
func (*BackupHandler) RestoreBackup ¶
func (h *BackupHandler) RestoreBackup(w http.ResponseWriter, r *http.Request)
type BulkJellyfinPolicyPatch ¶
type BulkUsersActionRequest ¶
type BulkUsersActionRequest struct {
UserIDs []int64 `json:"user_ids"`
Action string `json:"action"`
Preview bool `json:"preview"`
PolicyPresetID string `json:"policy_preset_id"`
EmailSubject string `json:"email_subject"`
EmailBody string `json:"email_body"`
CanInvite *bool `json:"can_invite"`
AccessExpiresAt *string `json:"access_expires_at"`
ClearExpiry bool `json:"clear_expiry"`
JellyfinPolicy *BulkJellyfinPolicyPatch `json:"jellyfin_policy"`
}
type CreateAdminUserRequest ¶
type CreateAdminUserRequest struct {
Username string `json:"username"`
Email string `json:"email"`
Password string `json:"password"`
PolicyPresetID string `json:"policy_preset_id"`
DisableAfterDays int `json:"disable_after_days"`
AccessExpiresAt string `json:"access_expires_at"`
CanInvite bool `json:"can_invite"`
SendWelcomeEmail bool `json:"send_welcome_email"`
}
type CreateInvitationRequest ¶
type CreateInvitationRequest struct {
Label string `json:"label"`
PreferredLang string `json:"preferred_lang"`
MaxUses int `json:"max_uses"` // 0 = illimité
ExpiresAt string `json:"expires_at"` // Legacy: date précise, exemple "2026-10-05T12:00"
ExpiresInDays int `json:"expires_in_days"`
IgnorePresetLinkExpiry bool `json:"ignore_preset_link_expiry"`
ApplyUserExpiry *bool `json:"apply_user_expiry"`
UserExpiryDays int `json:"user_expiry_days"` // Expiration finale du compte client (jours)
UserExpiresAt string `json:"user_expires_at"`
IgnorePresetUserExpiry bool `json:"ignore_preset_user_expiry"`
DisableAfterDays int `json:"disable_after_days"`
IsTemporary bool `json:"is_temporary"`
AccountDurationDays int `json:"account_duration_days"`
NewUserCanInvite bool `json:"new_user_can_invite"`
SendToEmail string `json:"send_to_email"` // Si renseigné, un e-mail partira par SMTP
Email string `json:"email"` // Legacy frontend key
EmailMessage string `json:"email_message"`
Libraries []string `json:"libraries"` // ID des bibliothèques Jellyfin
EnableDownloads bool `json:"enable_downloads"`
PolicyPresetID string `json:"policy_preset_id"`
GroupName string `json:"group_name"`
ForcedUsername string `json:"forced_username"`
TemplateUserID string `json:"template_user_id"`
UsernameMinLen *int `json:"username_min_length"`
UsernameMaxLen *int `json:"username_max_length"`
PasswordMinLen *int `json:"password_min_length"`
PasswordMaxLen *int `json:"password_max_length"`
RequireUpper *bool `json:"password_require_upper"`
RequireLower *bool `json:"password_require_lower"`
RequireDigit *bool `json:"password_require_digit"`
RequireSpecial *bool `json:"password_require_special"`
ExpiryAction string `json:"expiry_action"`
DeleteAfterDays *int `json:"delete_after_days"`
}
CreateInvitationRequest payload pour la création d'invitation
type DashboardStatsResponse ¶
type DashboardStatsResponse struct {
Registrations []database.RegistrationDay `json:"registrations"`
Invitations database.InvitationStats `json:"invitations"`
Health map[string]bool `json:"health"`
}
type InvitationHandler ¶
type InvitationHandler struct {
// contains filtered or unexported fields
}
InvitationHandler gère les routes liées aux invitations.
func NewInvitationHandler ¶
func NewInvitationHandler(cfg *config.Config, db *database.DB, jf *jellyfin.Client, ld *jgldap.Client, provisioner *integrations.Client, m *mail.Mailer, n *notify.Notifier, renderer *render.Engine) *InvitationHandler
NewInvitationHandler crée un nouveau handler d'invitations.
func (*InvitationHandler) InvitePage ¶
func (h *InvitationHandler) InvitePage(w http.ResponseWriter, r *http.Request)
InvitePage affiche le formulaire d'inscription pour un code d'invitation donné.
func (*InvitationHandler) InviteSubmit ¶
func (h *InvitationHandler) InviteSubmit(w http.ResponseWriter, r *http.Request)
InviteSubmit traite la soumission du formulaire d'inscription.
Flux atomique avec rollback strict :
Étape 1 : Validation SQLite → erreur = stop (rien ànettoyer) Étape 2 : Création LDAP → erreur = stop (rien ànettoyer) Étape 3 : Création Jellyfin → erreur = rollback LDAP Étape 4 : Enregistrement SQLite → erreur = rollback Jellyfin + LDAP Étape 5 : Notifications → erreur = log seulement (pas de rollback)
func (*InvitationHandler) SetLDAPClient ¶
func (h *InvitationHandler) SetLDAPClient(ld *jgldap.Client)
SetLDAPClient remplace le client LDAP (rechargement àchaud).
func (*InvitationHandler) SetMailer ¶
func (h *InvitationHandler) SetMailer(m *mail.Mailer)
SetMailer remplace le mailer SMTP (rechargement àchaud).
func (*InvitationHandler) SetNotifier ¶
func (h *InvitationHandler) SetNotifier(n *notify.Notifier)
SetNotifier remplace le notifier (rechargement àchaud).
func (*InvitationHandler) VerifyEmailPage ¶
func (h *InvitationHandler) VerifyEmailPage(w http.ResponseWriter, r *http.Request)
func (*InvitationHandler) VerifyEmailSubmit ¶
func (h *InvitationHandler) VerifyEmailSubmit(w http.ResponseWriter, r *http.Request)
type InvitationResponse ¶
type InvitationResponse struct {
ID int64 `json:"id"`
Code string `json:"code"`
Label string `json:"label"`
PreferredLang string `json:"preferred_lang"`
MaxUses int `json:"max_uses"`
UsedCount int `json:"used_count"`
JellyfinProfile map[string]interface{} `json:"jellyfin_profile"`
ProfileID string `json:"profile_id"`
ProfileSnapshot map[string]interface{} `json:"profile_snapshot,omitempty"`
IsTemporary bool `json:"is_temporary"`
AccountDurationDays int `json:"account_duration_days"`
ExpiresAt string `json:"expires_at,omitempty"`
CreatedBy string `json:"created_by"`
CreatedAt string `json:"created_at"`
}
InvitationResponse représente une invitation formatée pour l'API JSON.
type InvitationSponsorStats ¶
type InvitationSponsorStats struct {
Sponsor string `json:"sponsor"`
CreatedLinks int `json:"created_links"`
ActiveLinks int `json:"active_links"`
ClosedLinks int `json:"closed_links"`
TotalUses int `json:"total_uses"`
Conversions int `json:"conversions"`
ConversionRate float64 `json:"conversion_rate"`
}
type PasswordResetHandler ¶
type PasswordResetHandler struct {
// contains filtered or unexported fields
}
PasswordResetHandler gère les routes de réinitialisation de mot de passe.
func NewPasswordResetHandler ¶
func NewPasswordResetHandler(cfg *config.Config, db *database.DB, jf *jellyfin.Client, ld *jgldap.Client, m *mail.Mailer, renderer *render.Engine) *PasswordResetHandler
NewPasswordResetHandler crée un nouveau handler de réinitialisation.
func (*PasswordResetHandler) RequestPage ¶
func (h *PasswordResetHandler) RequestPage(w http.ResponseWriter, r *http.Request)
func (*PasswordResetHandler) ResetPage ¶
func (h *PasswordResetHandler) ResetPage(w http.ResponseWriter, r *http.Request)
func (*PasswordResetHandler) SetLDAPClient ¶
func (h *PasswordResetHandler) SetLDAPClient(ld *jgldap.Client)
SetLDAPClient remplace le client LDAP (rechargement à chaud).
func (*PasswordResetHandler) SetMailer ¶
func (h *PasswordResetHandler) SetMailer(m *mail.Mailer)
SetMailer remplace le mailer (rechargement à chaud).
func (*PasswordResetHandler) SubmitRequest ¶
func (h *PasswordResetHandler) SubmitRequest(w http.ResponseWriter, r *http.Request)
SubmitRequest traite la demande de réinitialisation.
func (*PasswordResetHandler) SubmitReset ¶
func (h *PasswordResetHandler) SubmitReset(w http.ResponseWriter, r *http.Request)
SubmitReset traite la soumission du nouveau mot de passe.
type SettingsHandler ¶
type SettingsHandler struct {
// Callbacks de rechargement à chaud
OnLDAPReload func(config.LDAPConfig)
OnSMTPReload func(config.SMTPConfig)
OnWebhooksReload func(config.WebhooksConfig)
// contains filtered or unexported fields
}
SettingsHandler gère les routes de configuration.
func NewSettingsHandler ¶
func NewSettingsHandler(db *database.DB, jf *jellyfin.Client, renderer *render.Engine) *SettingsHandler
NewSettingsHandler crée un nouveau handler de paramètres.
func (*SettingsHandler) ExportEmailTemplates ¶
func (h *SettingsHandler) ExportEmailTemplates(w http.ResponseWriter, r *http.Request)
ExportEmailTemplates exporte les modeles e-mail dans un ZIP lisible par langue.
func (*SettingsHandler) FetchJellyfinServerName ¶
func (h *SettingsHandler) FetchJellyfinServerName(w http.ResponseWriter, r *http.Request)
FetchJellyfinServerName recupere le nom du serveur depuis l'API Jellyfin.
func (*SettingsHandler) GetAll ¶
func (h *SettingsHandler) GetAll(w http.ResponseWriter, r *http.Request)
GetAll retourne toute la configuration stockée en base.
func (*SettingsHandler) ImportEmailTemplates ¶
func (h *SettingsHandler) ImportEmailTemplates(w http.ResponseWriter, r *http.Request)
ImportEmailTemplates importe un ZIP au format lang/template/subject.txt|body.txt.
func (*SettingsHandler) LDAPDryRun ¶
func (h *SettingsHandler) LDAPDryRun(w http.ResponseWriter, r *http.Request)
LDAPDryRun simule les mappings LDAP sans ecriture LDAP, Jellyfin ou base locale.
func (*SettingsHandler) PreviewEmailTemplate ¶
func (h *SettingsHandler) PreviewEmailTemplate(w http.ResponseWriter, r *http.Request)
PreviewEmailTemplate rend un modele d'email avec des donnees de demonstration.
func (*SettingsHandler) RevokeAuthSessions ¶
func (h *SettingsHandler) RevokeAuthSessions(w http.ResponseWriter, r *http.Request)
RevokeAuthSessions invalide toutes les sessions admin actives.
func (*SettingsHandler) SaveAuthSession ¶
func (h *SettingsHandler) SaveAuthSession(w http.ResponseWriter, r *http.Request)
SaveAuthSession sauvegarde la politique de sessions persistantes.
func (*SettingsHandler) SaveBackup ¶
func (h *SettingsHandler) SaveBackup(w http.ResponseWriter, r *http.Request)
SaveBackup sauvegarde la configuration des sauvegardes planifiées.
func (*SettingsHandler) SaveEmailTemplates ¶
func (h *SettingsHandler) SaveEmailTemplates(w http.ResponseWriter, r *http.Request)
SaveEmailTemplates sauvegarde les modeles e-mail (mono-langue ou multi-langue).
func (*SettingsHandler) SaveGeneral ¶
func (h *SettingsHandler) SaveGeneral(w http.ResponseWriter, r *http.Request)
SaveGeneral sauvegarde les paramètres généraux (langue par défaut).
func (*SettingsHandler) SaveInvitationProfile ¶
func (h *SettingsHandler) SaveInvitationProfile(w http.ResponseWriter, r *http.Request)
SaveInvitationProfile sauvegarde la politique globale appliquee aux invitations.
func (*SettingsHandler) SaveLDAP ¶
func (h *SettingsHandler) SaveLDAP(w http.ResponseWriter, r *http.Request)
SaveLDAP sauvegarde la configuration LDAP.
func (*SettingsHandler) SaveSMTP ¶
func (h *SettingsHandler) SaveSMTP(w http.ResponseWriter, r *http.Request)
SaveSMTP sauvegarde la configuration SMTP.
func (*SettingsHandler) SaveWebhooks ¶
func (h *SettingsHandler) SaveWebhooks(w http.ResponseWriter, r *http.Request)
SaveWebhooks sauvegarde la configuration Webhooks.
func (*SettingsHandler) TestJellyfinLDAPAuth ¶
func (h *SettingsHandler) TestJellyfinLDAPAuth(w http.ResponseWriter, r *http.Request)
TestJellyfinLDAPAuth vérifie que l'authentification LDAP via le plugin Jellyfin fonctionne.
func (*SettingsHandler) TestLDAPConnection ¶
func (h *SettingsHandler) TestLDAPConnection(w http.ResponseWriter, r *http.Request)
TestLDAPConnection teste la connexion et le bind LDAP sans sauvegarder la configuration.
func (*SettingsHandler) TestLDAPUserLookup ¶
func (h *SettingsHandler) TestLDAPUserLookup(w http.ResponseWriter, r *http.Request)
TestLDAPUserLookup teste la recherche d'un utilisateur LDAP via l'attribut de login configure (ex: sAMAccountName, uid).
type UpdateMyAccountRequest ¶
type UpdateMyAccountRequest struct {
Email *string `json:"email"`
ContactDiscord *string `json:"contact_discord"`
ContactTelegram *string `json:"contact_telegram"`
ContactMatrix *string `json:"contact_matrix"`
PreferredLang *string `json:"preferred_lang"`
NotifyExpiryReminder *bool `json:"notify_expiry_reminder"`
NotifyAccountEvents *bool `json:"notify_account_events"`
OptInEmail *bool `json:"opt_in_email"`
OptInDiscord *bool `json:"opt_in_discord"`
OptInTelegram *bool `json:"opt_in_telegram"`
OptInMatrix *bool `json:"opt_in_matrix"`
}
type UpdateUserRequest ¶
type UserResponse ¶
type UserResponse struct {
ID int64 `json:"id"`
JellyfinID string `json:"jellyfin_id"`
Username string `json:"username"`
Email string `json:"email"`
LDAPDN string `json:"ldap_dn"`
GroupName string `json:"group_name"`
PresetID string `json:"preset_id"` // NEW
InvitedBy string `json:"invited_by"`
IsActive bool `json:"is_active"`
IsBanned bool `json:"is_banned"`
CanInvite bool `json:"can_invite"`
AccessExpiresAt string `json:"access_expires_at,omitempty"` // ISO 8601
DeleteAt string `json:"delete_at,omitempty"`
ExpiryAction string `json:"expiry_action"`
DeleteAfterDays int `json:"expiry_delete_after_days"`
ExpiredAt string `json:"expired_at,omitempty"`
ProfileApplyStatus string `json:"profile_apply_status"`
ProfileApplyError string `json:"profile_apply_error,omitempty"`
ProfileAppliedAt string `json:"profile_applied_at,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
// Statuts temps réel depuis Jellyfin (enrichissement)
JellyfinDisabled bool `json:"jellyfin_disabled"`
JellyfinExists bool `json:"jellyfin_exists"`
JellyfinPrimaryImageTag string `json:"jellyfin_primary_image_tag,omitempty"`
}
UserResponse est la représentation JSON d'un utilisateur pour l'API admin.
type UserTimelineEvent ¶
type UserTimelineEvent struct {
At string `json:"at"`
Action string `json:"action"`
Category string `json:"category"`
Severity string `json:"severity"`
Actor string `json:"actor,omitempty"`
Target string `json:"target,omitempty"`
Details string `json:"details,omitempty"`
Message string `json:"message"`
}
Source Files
¶
- admin.go
- admin_data_studio.go
- admin_my_account.go
- admin_my_invitations.go
- admin_users_api.go
- auth.go
- automation.go
- backup.go
- email_language.go
- email_utils.go
- email_verification.go
- invitation_cleanup.go
- invitation_security.go
- invitations.go
- invite_abuse.go
- invite_verification.go
- password_reset.go
- product.go
- security_events.go
- security_logging.go
- settings.go
- settings_ldap_dry_run.go
- template_data.go