# rockyroad1827/bookstacks-password-protect-page-hack architecture

> Architecture diagram of the GitHub repository rockyroad1827/bookstacks-password-protect-page-hack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rockyroad1827/bookstacks-password-protect-page-hack
- Repository: https://github.com/rockyroad1827/bookstacks-password-protect-page-hack

## Overview

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: [`themes/theme/functions.php`](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/functions.php) (Protection hooks and routes), [`themes/theme/app/Console/Commands/ManageLocksCommand.php`](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/app/Console/Commands/ManageLocksCommand.php) (Lock management CLI), [`themes/theme/form/entity-permissions.blade.php`](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/form/entity-permissions.blade.php) (Permissions controls), [`themes/theme/layouts/parts/footer.blade.php`](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/layouts/parts/footer.blade.php) (Lock indicators and modal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protection["Access protection"]
  node_backend["Protection hooks and routes<br/>[functions.php]"]
  node_pin_screen["PIN lock screen<br/>[functions.php]"]
end

subgraph group_admin["Administration"]
  node_permissions_ui["Permissions controls"]
  node_cli["Lock management CLI"]
end

subgraph group_presentation["Presentation"]
  node_footer["Lock indicators and modal<br/>[footer.blade.php]"]
end

subgraph group_state["Protection state"]
  node_page_tags[("Page protection tags")]
  node_session[("Unlock and error session")]
  node_master_pin[("Master PIN configuration")]
  node_env_file["Environment file"]
end

node_admin_user(("Administrator"))
node_reader(("Page reader"))
node_api_client(("API client"))
node_bookstack["BookStack"]
node_page_lists["BookStack page lists"]

node_admin_user -->|"manages locks"| node_permissions_ui
node_bookstack -->|"renders"| node_permissions_ui
node_permissions_ui -->|"submits lock actions"| node_backend
node_backend -->|"updates tags"| node_page_tags
node_permissions_ui -->|"reads status"| node_page_tags
node_reader -->|"requests page"| node_bookstack
node_bookstack -->|"dispatches request hook"| node_backend
node_backend -->|"checks protection"| node_page_tags
node_backend -->|"checks unlock state"| node_session
node_backend -->|"reads fallback PIN"| node_master_pin
node_backend -->|"renders challenge"| node_pin_screen
node_pin_screen -->|"submits PIN"| node_backend
node_backend -->|"stores unlock state"| node_session
node_api_client -->|"requests API page"| node_bookstack
node_bookstack -->|"dispatches API hook"| node_backend
node_backend -->|"denies invalid PIN"| node_api_client
node_backend -->|"checks API access"| node_page_tags
node_backend -->|"scrubs previews"| node_page_lists
node_page_lists -->|"renders list items"| node_footer
node_footer -->|"hides previews and marks locks"| node_page_lists
node_backend -->|"records blocked deletion"| node_session
node_bookstack -->|"renders deletion notice"| node_footer
node_admin_user -->|"runs management command"| node_cli
node_backend -->|"registers command"| node_cli
node_cli -->|"lists and updates locks"| node_page_tags
node_cli -->|"reads and updates PIN"| node_master_pin
node_cli -->|"writes configuration"| node_env_file

click node_backend "https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/functions.php"
click node_pin_screen "https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/functions.php"
click node_permissions_ui "https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/form/entity-permissions.blade.php"
click node_cli "https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/app/Console/Commands/ManageLocksCommand.php"
click node_footer "https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/layouts/parts/footer.blade.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_backend,node_pin_screen,node_api_client toneBlue
class node_permissions_ui,node_cli toneAmber
class node_footer toneMint
class node_page_tags,node_session,node_master_pin,node_env_file toneRose
class node_admin_user,node_reader,node_bookstack,node_page_lists toneIndigo
```

## Components

### Access protection

- [Protection hooks and routes](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/functions.php): `themes/theme/functions.php`
- [PIN lock screen](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/functions.php): `themes/theme/functions.php`

### Administration

- [Permissions controls](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/form/entity-permissions.blade.php): `themes/theme/form/entity-permissions.blade.php`
- [Lock management CLI](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/app/Console/Commands/ManageLocksCommand.php): `themes/theme/app/Console/Commands/ManageLocksCommand.php`

### Presentation

- [Lock indicators and modal](https://github.com/rockyroad1827/bookstacks-password-protect-page-hack/blob/main/themes/theme/layouts/parts/footer.blade.php): `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

- 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
