How rockyroad1827/bookstacks-password-protect-page-hack works
This BookStack theme add-on protects individual pages with custom or master PINs. Administrators configure locks in the permissions UI or manage them from the CLI; browser requests are gated by PIN validation, while API requests require a PIN unless API access is enabled. The add-on also scrubs list previews, marks locked items, and blocks deletion of parents containing protected pages. The excerpts show these mechanisms in one backend file; detailed wiring for some documented BookStack hooks is omitted.
Main entry points: functions.php Protection hooks and routes · ManageLocksCommand.php Lock management CLI · entity-permissions.blade.php Permissions controls · footer.blade.php Lock indicators and modal
Components 14
Access protection
- Protection hooks and routes
themes/theme/functions.php - PIN lock screen
themes/theme/functions.php
Administration
- Permissions controls
themes/theme/form/entity-permissions.blade.php - Lock management CLI
themes/theme/app/Console/Commands/ManageLocksCommand.php
Presentation
- Lock indicators and modal
themes/theme/layouts/parts/footer.blade.php
Protection state
- Page protection tags
- Unlock and error session
- Master PIN configuration
- Environment file
Other components
- Administrator
- Page reader
- API client
- BookStack
- BookStack page lists
Connections 27
- Administrator → Permissions controls: manages locks
- BookStack → Permissions controls: renders
- Permissions controls → Protection hooks and routes: submits lock actions
- Protection hooks and routes → Page protection tags: updates tags
- Permissions controls → Page protection tags: reads status
- Page reader → BookStack: requests page
- BookStack → Protection hooks and routes: dispatches request hook
- Protection hooks and routes → Page protection tags: checks protection
- Protection hooks and routes → Unlock and error session: checks unlock state
- Protection hooks and routes → Master PIN configuration: reads fallback PIN
- Protection hooks and routes → PIN lock screen: renders challenge
- PIN lock screen → Protection hooks and routes: submits PIN
- Protection hooks and routes → Unlock and error session: stores unlock state
- API client → BookStack: requests API page
- BookStack → Protection hooks and routes: dispatches API hook
- Protection hooks and routes → API client: denies invalid PIN
- Protection hooks and routes → Page protection tags: checks API access
- Protection hooks and routes → BookStack page lists: scrubs previews
- BookStack page lists → Lock indicators and modal: renders list items
- Lock indicators and modal → BookStack page lists: hides previews and marks locks
- Protection hooks and routes → Unlock and error session: records blocked deletion
- BookStack → Lock indicators and modal: renders deletion notice
- Administrator → Lock management CLI: runs management command
- Protection hooks and routes → Lock management CLI: registers command
- Lock management CLI → Page protection tags: lists and updates locks
- Lock management CLI → Master PIN configuration: reads and updates PIN
- Lock management CLI → Environment file: writes configuration