hooks

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const MFASessionKey = "mfa_session"

MFASessionKey is the key used to store MFA session info in the request context

Variables

This section is empty.

Functions

func CheckRebootCompletions added in v0.0.4

func CheckRebootCompletions(app core.App)

CheckRebootCompletions checks for agents with pending_reboot_id that have reconnected Exported for testing

func LoadAuthContext

func LoadAuthContext(app core.App) func(next func(*core.RequestEvent) error) func(*core.RequestEvent) error

LoadAuthContext returns a middleware that loads the auth record from the Authorization header

func OnAuthFailed

func OnAuthFailed(app App) func(*core.RecordAuthRequestEvent) error

OnAuthFailed tracks failed auth attempts and locks account after 5 failures

func OnAuthRequest

func OnAuthRequest(app App) func(*core.RecordAuthRequestEvent) error

OnAuthRequest checks account lockout before allowing auth

func OnAuthWithPasswordRequest

func OnAuthWithPasswordRequest(app App) func(*core.RecordAuthWithPasswordRequestEvent) error

OnAuthWithPasswordRequest checks account lockout and tracks failures

func OnUserCreate

func OnUserCreate(app App) func(*core.RecordEvent) error

OnUserCreate validates password when creating a new user

func OnUserUpdate

func OnUserUpdate(app App) func(*core.RecordEvent) error

OnUserUpdate validates password and checks security constraints when updating user

func RegisterAgentHooks

func RegisterAgentHooks(app core.App)

RegisterAgentHooks registers all agent-related functionality

func RegisterInvestigationHooks

func RegisterInvestigationHooks(app core.App)

RegisterInvestigationHooks registers all investigation management endpoints

func RegisterPackageExceptionHooks added in v0.0.2

func RegisterPackageExceptionHooks(app core.App)

RegisterPackageExceptionHooks registers hooks for package_exceptions collection

func RegisterPatchHooks

func RegisterPatchHooks(app core.App)

RegisterPatchHooks registers all patch management endpoints and hooks

func RegisterProxmoxHooks added in v0.0.2

func RegisterProxmoxHooks(app core.App)

RegisterProxmoxHooks registers the Proxmox related hooks and routes

func RegisterRebootHooks added in v0.0.4

func RegisterRebootHooks(app core.App)

RegisterRebootHooks registers all reboot management endpoints and hooks Note: Reboot schedule cron management is handled by schedules.RegisterRebootScheduler

func RequireAuth

func RequireAuth() func(next func(*core.RequestEvent) error) func(*core.RequestEvent) error

RequireAuth returns a middleware that requires authentication

func RequireAuthCollection added in v0.0.2

func RequireAuthCollection(collectionName string) func(next func(*core.RequestEvent) error) func(*core.RequestEvent) error

RequireAuthCollection returns a middleware that requires authentication for a specific collection

Types

type App

type App interface {
	FindCollectionByNameOrId(collectionNameOrId string) (*core.Collection, error)
	FindRecordsByFilter(collection any, filter string, sort string, limit int, offset int, params ...dbx.Params) ([]*core.Record, error)
	Save(record core.Model) error
}

App interface for PocketBase operations

type MFAHooks added in v0.0.5

type MFAHooks struct {
	// contains filtered or unexported fields
}

MFAHooks provides MFA-related hooks for the authentication system

func NewMFAHooks added in v0.0.5

func NewMFAHooks(app core.App) *MFAHooks

NewMFAHooks creates a new MFA hooks instance

func (*MFAHooks) CheckMFARequired added in v0.0.5

func (h *MFAHooks) CheckMFARequired(userID string) (bool, string, error)

CheckMFARequired checks if the user has MFA enabled and needs to verify

func (*MFAHooks) OnAuthSuccess added in v0.0.5

func (h *MFAHooks) OnAuthSuccess(e *core.RecordAuthRequestEvent) error

OnAuthSuccess is called after successful primary authentication It checks if the user has MFA enabled and returns appropriate response

func (*MFAHooks) RequireMFAMiddleware added in v0.0.5

func (h *MFAHooks) RequireMFAMiddleware(next http.Handler) http.Handler

RequireMFAMiddleware is a middleware that requires MFA verification for certain routes

func (*MFAHooks) VerifyMFAForLogin added in v0.0.5

func (h *MFAHooks) VerifyMFAForLogin(userID, factorID, challengeID, code string) error

VerifyMFAForLogin verifies MFA during the login process

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL