flshbd 0.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flshbd-0.0.9/.gitignore +52 -0
- flshbd-0.0.9/AGENTS.md +232 -0
- flshbd-0.0.9/CHANGELOG.md +90 -0
- flshbd-0.0.9/LICENSE.txt +10 -0
- flshbd-0.0.9/PKG-INFO +106 -0
- flshbd-0.0.9/README.md +77 -0
- flshbd-0.0.9/docs/index.html +189 -0
- flshbd-0.0.9/docs/nginx_auth.md +126 -0
- flshbd-0.0.9/docs/pamconfig.md +153 -0
- flshbd-0.0.9/docs/validation.md +16 -0
- flshbd-0.0.9/pyproject.toml +104 -0
- flshbd-0.0.9/src/flshbd/__about__.py +4 -0
- flshbd-0.0.9/src/flshbd/__init__.py +10 -0
- flshbd-0.0.9/src/flshbd/__main__.py +9 -0
- flshbd-0.0.9/src/flshbd/cli/__init__.py +66 -0
- flshbd-0.0.9/src/flshbd/cli/access.py +153 -0
- flshbd-0.0.9/src/flshbd/cli/dash.py +192 -0
- flshbd-0.0.9/src/flshbd/cli/db.py +195 -0
- flshbd-0.0.9/src/flshbd/cli/groups.py +225 -0
- flshbd-0.0.9/src/flshbd/cli/process.py +332 -0
- flshbd-0.0.9/src/flshbd/cli/site_groups.py +225 -0
- flshbd-0.0.9/src/flshbd/cli/sites.py +325 -0
- flshbd-0.0.9/src/flshbd/cli/users.py +317 -0
- flshbd-0.0.9/src/flshbd/cli/utils.py +71 -0
- flshbd-0.0.9/src/flshbd/core/.env +58 -0
- flshbd-0.0.9/src/flshbd/core/__init__.py +8 -0
- flshbd-0.0.9/src/flshbd/core/config.py +331 -0
- flshbd-0.0.9/src/flshbd/core/env.py +211 -0
- flshbd-0.0.9/src/flshbd/core/security.py +108 -0
- flshbd-0.0.9/src/flshbd/data/__init__.py +8 -0
- flshbd-0.0.9/src/flshbd/data/database.py +366 -0
- flshbd-0.0.9/src/flshbd/data/models.py +1250 -0
- flshbd-0.0.9/src/flshbd/web/__init__.py +8 -0
- flshbd-0.0.9/src/flshbd/web/app.py +101 -0
- flshbd-0.0.9/src/flshbd/web/auth.py +188 -0
- flshbd-0.0.9/src/flshbd/web/auth_pam.py +62 -0
- flshbd-0.0.9/src/flshbd/web/routes.py +208 -0
- flshbd-0.0.9/src/flshbd/web/static/css/style.css +636 -0
- flshbd-0.0.9/src/flshbd/web/static/images/FlashBoard-Logo.png +0 -0
- flshbd-0.0.9/src/flshbd/web/templates/base.html +14 -0
- flshbd-0.0.9/src/flshbd/web/templates/dash.html +20 -0
- flshbd-0.0.9/src/flshbd/web/templates/login.html +56 -0
- flshbd-0.0.9/src/flshbd/web/templates/partials/demo_site.html +33 -0
- flshbd-0.0.9/src/flshbd/web/templates/partials/footer.html +3 -0
- flshbd-0.0.9/src/flshbd/web/templates/partials/header.html +23 -0
- flshbd-0.0.9/src/flshbd/web/templates/partials/help_site.html +46 -0
- flshbd-0.0.9/src/flshbd/web/templates/partials/info_site.html +37 -0
- flshbd-0.0.9/src/flshbd/web/templates/partials/main.html +25 -0
- flshbd-0.0.9/src/flshbd/web/templates/partials/sidebar.html +23 -0
- flshbd-0.0.9/src/flshbd/web/templates/partials/template_site.html +26 -0
- flshbd-0.0.9/tests/__init__.py +3 -0
- flshbd-0.0.9/tests/conftest.py +11 -0
- flshbd-0.0.9/tests/test_dash/__init__.py +6 -0
- flshbd-0.0.9/tests/test_dash/test_auth.py +174 -0
- flshbd-0.0.9/tests/test_dash/test_auth_pam.py +113 -0
- flshbd-0.0.9/tests/test_dash/test_cli_process.py +330 -0
- flshbd-0.0.9/tests/test_dash/test_config.py +75 -0
- flshbd-0.0.9/tests/test_dash/test_env_file.py +232 -0
- flshbd-0.0.9/tests/test_dash/test_models.py +293 -0
- flshbd-0.0.9/tests/test_dash/test_routes.py +391 -0
- flshbd-0.0.9/tests/test_dash/test_secret_key.py +167 -0
- flshbd-0.0.9/tests/test_dash/test_security.py +218 -0
flshbd-0.0.9/.gitignore
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# ---> Python
|
|
2
|
+
# Byte-compiled / optimized / DLL files
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
*$py.class
|
|
6
|
+
|
|
7
|
+
# C extensions
|
|
8
|
+
*.so
|
|
9
|
+
|
|
10
|
+
# data for development
|
|
11
|
+
flshbd-data/
|
|
12
|
+
|
|
13
|
+
# dotenv files with local settings/secrets (the bundled copy shipped with the
|
|
14
|
+
# package is committed on purpose)
|
|
15
|
+
.env
|
|
16
|
+
!src/flshbd/core/.env
|
|
17
|
+
|
|
18
|
+
# Opencode & AI
|
|
19
|
+
.opencode/
|
|
20
|
+
|
|
21
|
+
# Distribution / packaging
|
|
22
|
+
build/
|
|
23
|
+
dist/
|
|
24
|
+
.hatch/
|
|
25
|
+
sdist/
|
|
26
|
+
.temp/
|
|
27
|
+
.vscode/
|
|
28
|
+
wheels/
|
|
29
|
+
.zed/
|
|
30
|
+
|
|
31
|
+
# Jupyter
|
|
32
|
+
jupyter/
|
|
33
|
+
*.ipynb
|
|
34
|
+
.ipynb_checkpoints/
|
|
35
|
+
|
|
36
|
+
# MkDocs documentation
|
|
37
|
+
pages/
|
|
38
|
+
|
|
39
|
+
# PyBuilder
|
|
40
|
+
.pybuilder/
|
|
41
|
+
target/
|
|
42
|
+
|
|
43
|
+
# mypy
|
|
44
|
+
.mypy_cache/
|
|
45
|
+
.dmypy.json
|
|
46
|
+
dmypy.json
|
|
47
|
+
|
|
48
|
+
# Pyre type checker
|
|
49
|
+
.pyre/
|
|
50
|
+
|
|
51
|
+
# pytype static type analyzer
|
|
52
|
+
.pytype/
|
flshbd-0.0.9/AGENTS.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This document provides guidance for AI agents and assistants working with the **flshbd** (FlashBoard) project.
|
|
4
|
+
|
|
5
|
+
_v0.0.8_ Last updated: November 2026
|
|
6
|
+
|
|
7
|
+
## 📋 Project Overview
|
|
8
|
+
|
|
9
|
+
**FlashBoard (flshbd)** is a Flask-based dashboard application that provides centralized access to various tools and services through a clean, role-based interface with user authentication. Users are organized in groups, and sites are collected in site groups. The sidebar dynamically displays only accessible site groups based on user group memberships.
|
|
10
|
+
|
|
11
|
+
The project supports both iframe-based external services and Jinja2-based template content. Session management uses client-side cookies with configurable inactivity timeout. Data is stored in SQLite3 databases.
|
|
12
|
+
|
|
13
|
+
## 🏗️ Project Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
/home/robert/Python/flshbd/
|
|
17
|
+
├── src/flshbd/
|
|
18
|
+
│ ├── __init__.py # Package initialization
|
|
19
|
+
│ ├── __main__.py # CLI entry point
|
|
20
|
+
│ ├── __about__.py # Version information
|
|
21
|
+
│ ├── core/ # Core utilities
|
|
22
|
+
│ │ ├── __init__.py
|
|
23
|
+
│ │ ├── .env # Bundled env file (docs for all FLSHBD_* vars; copied to DATA_DIR on first start)
|
|
24
|
+
│ │ ├── config.py # Configuration management
|
|
25
|
+
│ │ ├── env.py # .env bootstrap: loaded from __init__.py before config is imported
|
|
26
|
+
│ │ └── security.py # Security utilities
|
|
27
|
+
│ ├── data/ # Data layer
|
|
28
|
+
│ │ ├── __init__.py
|
|
29
|
+
│ │ ├── database.py # Database operations
|
|
30
|
+
│ │ └── models.py # Data models
|
|
31
|
+
│ ├── web/ # Web application
|
|
32
|
+
│ │ ├── __init__.py
|
|
33
|
+
│ │ ├── app.py # Flask application factory
|
|
34
|
+
│ │ ├── auth.py # Authentication (standard)
|
|
35
|
+
│ │ ├── auth_pam.py # PAM authentication
|
|
36
|
+
│ │ ├── routes.py # Route definitions
|
|
37
|
+
│ │ ├── static/ # Static files (CSS, JS, images) — bundled defaults, copied to DATA_DIR on first start
|
|
38
|
+
│ │ └── templates/ # Jinja2 templates — bundled defaults, copied to DATA_DIR on first start
|
|
39
|
+
│ └── cli/ # CLI commands
|
|
40
|
+
│ ├── __init__.py # Main CLI entry point (fld)
|
|
41
|
+
│ ├── access.py # Access control commands
|
|
42
|
+
│ ├── dash.py # Server management commands
|
|
43
|
+
│ ├── db.py # Database management commands
|
|
44
|
+
│ ├── groups.py # User group management
|
|
45
|
+
│ ├── process.py # Process manager (PID files, Flask/Gunicorn start)
|
|
46
|
+
│ ├── site_groups.py # Site group management
|
|
47
|
+
│ ├── sites.py # Site management
|
|
48
|
+
│ ├── users.py # User management
|
|
49
|
+
│ └── utils.py # CLI utilities
|
|
50
|
+
├── tests/ # Test suite
|
|
51
|
+
│ ├── conftest.py # Pytest fixtures
|
|
52
|
+
│ └── test_dash/ # Dashboard tests
|
|
53
|
+
│ ├── test_auth.py
|
|
54
|
+
│ ├── test_auth_pam.py
|
|
55
|
+
│ ├── test_cli_process.py
|
|
56
|
+
│ ├── test_models.py
|
|
57
|
+
│ ├── test_routes.py
|
|
58
|
+
│ ├── test_secret_key.py
|
|
59
|
+
│ └── test_security.py
|
|
60
|
+
├── docs/ # Documentation
|
|
61
|
+
│ ├── index.html # Self-contained demo site (to be iframed)
|
|
62
|
+
│ ├── nginx_auth.md # Nginx auth_request setup for protected subdomains
|
|
63
|
+
│ ├── pamconfig.md # PAM configuration notes
|
|
64
|
+
│ └── validation.md # Validation notes
|
|
65
|
+
├── pyproject.toml # Project configuration (Hatch)
|
|
66
|
+
├── README.md # User documentation
|
|
67
|
+
├── CHANGELOG.md # Project changelog
|
|
68
|
+
└── AGENTS.md # This file
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 🔧 Development Setup
|
|
72
|
+
|
|
73
|
+
### Prerequisites
|
|
74
|
+
- Python 3.13+
|
|
75
|
+
- [Hatch](https://hatch.pypa.io/) (recommended)
|
|
76
|
+
|
|
77
|
+
### Installation
|
|
78
|
+
```bash
|
|
79
|
+
# Install in development mode
|
|
80
|
+
hatch run pip install -e .
|
|
81
|
+
|
|
82
|
+
# Or install from PyPI (not published yet)
|
|
83
|
+
pip install flshbd
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Verify installation
|
|
87
|
+
```bash
|
|
88
|
+
fld --help
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Running Tests
|
|
92
|
+
```bash
|
|
93
|
+
# Run all tests
|
|
94
|
+
hatch run pytest
|
|
95
|
+
|
|
96
|
+
# Run specific test file
|
|
97
|
+
hatch run pytest tests/test_dash/test_auth.py -v
|
|
98
|
+
|
|
99
|
+
# Run with coverage
|
|
100
|
+
hatch run pytest --cov=flshbd --cov=tests
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 🚀 CLI Commands
|
|
104
|
+
|
|
105
|
+
The project uses the `fld` CLI (installed via `project.scripts` in pyproject.toml).
|
|
106
|
+
|
|
107
|
+
**Structure:** `fld [--env|-e <production|development|testing|default>] <command> [options]` (`default` resolves to production; short flags `-e`/`-h` available)
|
|
108
|
+
|
|
109
|
+
**Main commands:**
|
|
110
|
+
- `fld dash <start/stop/status/generate-secret-key>` - Manage Flask server
|
|
111
|
+
- `fld db <init/migrate/backup/restore>` - Database management
|
|
112
|
+
- `fld db config <get/set/list>` - Key/value `config` table (e.g. `title`, `info`, `important`)
|
|
113
|
+
- `fld user <list/add/modify/delete>` - User management (usernames are always lowercase)
|
|
114
|
+
- `fld group <list/add/modify/delete>` - User group management
|
|
115
|
+
- `fld site <list/add/modify/delete>` - Site management (`-v` shows URLs, `--sort-order` for ordering)
|
|
116
|
+
- `fld site-group <list/add/modify/delete>` - Site group management
|
|
117
|
+
- `fld access <list/grant/revoke>` - Access control management
|
|
118
|
+
|
|
119
|
+
Use `-h`/`--help` at any level for detailed options.
|
|
120
|
+
|
|
121
|
+
## 📚 Key Modules
|
|
122
|
+
|
|
123
|
+
### Core Modules
|
|
124
|
+
- **`core/config.py`** - Configuration classes for different environments
|
|
125
|
+
- **`core/env.py`** - `.env` bootstrap (`get_data_dir`, `ensure_env_file`, `load_env_file`, `bootstrap`); must not import `core/config.py`
|
|
126
|
+
- **`core/security.py`** - Security utilities and password hashing
|
|
127
|
+
|
|
128
|
+
### Data Layer
|
|
129
|
+
- **`data/database.py`** - Database initialization, connection, and operations
|
|
130
|
+
- **`data/models.py`** - SQLAlchemy models (User, UserGroup, Site, SiteGroup, Access, ConfigEntry) plus the `user_can_access_site()` helper
|
|
131
|
+
|
|
132
|
+
### Web Application
|
|
133
|
+
- **`web/app.py`** - Flask application factory with CSP and session configuration
|
|
134
|
+
- **`web/auth.py`** - Session-based authentication with login/logout
|
|
135
|
+
- **`web/auth_pam.py`** - Optional PAM authentication integration
|
|
136
|
+
- **`web/routes.py`** - All web routes (login, dashboard, site access, logout, `/auth/verify[/<site_id>]` for Nginx `auth_request`)
|
|
137
|
+
|
|
138
|
+
### CLI Modules
|
|
139
|
+
- **`cli/__init__.py`** - Main CLI group (`fld`) with environment handling (`--env`/`-e`)
|
|
140
|
+
- **`cli/dash.py`** - Server start/stop/status plus `generate-secret-key`
|
|
141
|
+
- **`cli/process.py`** - ProcessManager: PID-file handling, Flask dev server / Gunicorn (`--preload`, shared secret key) start
|
|
142
|
+
- **`cli/db.py`** - Database init/migrate/backup/restore and the `db config` key/value commands
|
|
143
|
+
- **`cli/users.py`**, **`cli/groups.py`**, **`cli/sites.py`**, **`cli/site_groups.py`** - Entity management
|
|
144
|
+
- **`cli/access.py`** - Access control between user groups and site groups
|
|
145
|
+
|
|
146
|
+
## 🎯 Important Considerations
|
|
147
|
+
|
|
148
|
+
### Security
|
|
149
|
+
- Passwords are **hashed** (bcrypt); usernames are always lowercase
|
|
150
|
+
- Session cookies are HTTP-only, `SameSite=Lax`, and `Secure` in production. Signing uses an ephemeral secret key per server start unless `FLSHBD_SECRET_KEY` is set (see `fld dash generate-secret-key`); Gunicorn runs with `--preload` so all workers share the key
|
|
151
|
+
- Response delay on unsuccessful DB login attempts
|
|
152
|
+
- CSP headers configured per environment (more permissive in development)
|
|
153
|
+
- PAM authentication available as optional dependency (`FLSHBD_PAM_ENABLED`, `FLSHBD_PAM_SERVICE`; see `docs/pamconfig.md`)
|
|
154
|
+
|
|
155
|
+
### Configuration
|
|
156
|
+
- **Environments:** production (default; `default` maps to production), development, testing — selected via `fld --env/-e ...`
|
|
157
|
+
- Env-enabled config vars start with `FLSHBD_`: `FLSHBD_SECRET_KEY`, `FLSHBD_COOKIE_DOMAIN`, `FLSHBD_SESSION_LIFETIME`, `FLSHBD_PAM_ENABLED`, `FLSHBD_PAM_SERVICE`, `FLSHBD_TEMPLATE_FOLDER`, `FLSHBD_STATIC_FOLDER`
|
|
158
|
+
- **`.env` file:** all `FLSHBD_*` vars can also be set in `<DATA_DIR>/.env` (`flshbd-data/.env` in development/testing, `~/.config/flshbd/.env` in production); on first start a documented copy of the bundled `src/flshbd/core/.env` is placed there by `ensure_env_file()` (never overwritten, mode 0600, since it may hold `FLSHBD_SECRET_KEY`). It is loaded by `flshbd.core.env.bootstrap()`, called from `flshbd/__init__.py` — before any submodule, in particular before `flshbd.core.config` is imported (whose `FLSHBD_*` reads happen at import time) — via `python-dotenv`'s `load_dotenv(..., override=False)` (optional extra `flshbd[dotenv]`). Precedence: exported env var > `.env` value > built-in default. The env for locating the data dir is detected from `sys.argv` (`--env/-e`, or `create_app('...')` in server command lines; `default` → production data dir); server subprocesses spawned by the CLI inherit the loaded values via `os.environ`. No-op under pytest. Without `python-dotenv`, the file is ignored (stderr hint if it contains active assignments). `core/env.py` must not import `core/config.py` (chicken-and-egg). The long per-variable explanations live in the bundled `.env`; `config.py` only keeps one-liners pointing to `<DATA_DIR>/.env`
|
|
159
|
+
- **Templates & static files:** served from `<DATA_DIR>/templates` and `<DATA_DIR>/static` (`flshbd-data/` in development/testing, `~/.config/flshbd/` in production); on first server start (`create_app()` → `ensure_web_folders()`) they are auto-populated with the bundled copies from `src/flshbd/web/`, and can then be adapted per environment. `FLSHBD_TEMPLATE_FOLDER` / `FLSHBD_STATIC_FOLDER` override both locations (used as-is, never copied into); without them, the bundled folders are the fallback if the `DATA_DIR` folders don't exist. `fld site add/modify --type template` validates against the resolved template folder. Templates under `DATA_DIR` are Jinja2-rendered with the privileges of the server process
|
|
160
|
+
- **Reload semantics of the web folders** (verified against Flask/Jinja2 behavior):
|
|
161
|
+
- *Which folder is used* is resolved once per process — the config class attributes at import time plus `ensure_web_folders()` in `create_app()` — so changing `FLSHBD_TEMPLATE_FOLDER`/`FLSHBD_STATIC_FOLDER` or the existence of the `DATA_DIR` folders requires a **server restart**. This applies to the Flask development server and to Gunicorn alike; with `--preload` (enforced by the CLI), `create_app()` runs once in the Gunicorn master and all workers inherit the same folders via fork, so a full Gunicorn restart is needed to pick up folder changes
|
|
162
|
+
- *Template content*: in development `DEBUG=True` makes Jinja2's `auto_reload=True`, so edits to template files are picked up **live, without restart**. In production (and the testing config) `auto_reload=False`: templates are cached in the app's Jinja environment, so content changes require a **restart** (same for Gunicorn workers, which share the preloaded master's environment)
|
|
163
|
+
- *Static content*: `send_static_file` reads from disk on every request, so edits are **live immediately** in all environments and servers. Responses carry `Cache-Control: no-cache` by default (`SEND_FILE_MAX_AGE_DEFAULT` unset), so browsers revalidate instead of serving stale files (see also the "Caching/Lifetime" item under *Cleanups* in CHANGELOG.md)
|
|
164
|
+
- **Development:** Debug mode, data in `flshbd-data/`, server on `localhost:5000`
|
|
165
|
+
- **Production:** Gunicorn (or Flask) server, data in `~/.config/flshbd/` (XDG compliant), secure cookies
|
|
166
|
+
- **Session timeout:** `FLSHBD_SESSION_LIFETIME` env var in seconds (default 1800 = 30 min, sliding inactivity timeout), mapped to Flask's `PERMANENT_SESSION_LIFETIME` and read once at process start like the other env-backed `FLSHBD_*` vars; unset or invalid values fall back to 1800 s. Via the `.env` file (see above) it is loaded automatically at package import, before `flshbd.core.config`
|
|
167
|
+
- **Config table:** key/value pairs in the DB (`fld db config ...`), e.g. `title` (dashboard title) and `info`/`important` (admin messages above the login area; plain text only, `important` overwrites `info`)
|
|
168
|
+
- **Reverse proxy:** `/auth/verify[/<site_id>]` returns plain status codes (204/401/403, never redirects) for Nginx `auth_request` on subdomains; set `FLSHBD_COOKIE_DOMAIN` (e.g. `.example.com`) to share the session cookie across subdomains. See `docs/nginx_auth.md` for prerequisites and Nginx config examples
|
|
169
|
+
|
|
170
|
+
### Database
|
|
171
|
+
- SQLite3 databases per environment
|
|
172
|
+
- Schema auto-initialization at first server start (`create_app()` → `ensure_database_initialized()` in `data/database.py`), if not there — parallel to `ensure_web_folders()` for the web folders; idempotent, so safe on every start (Flask debug reloader, Gunicorn `--preload`). The lazy init in `get_database()` remains as a safety net for CLI-only usage (`fld user add` etc. on a fresh data dir)
|
|
173
|
+
- Static demo data is NOT auto-populated anymore (the `FLSHBD_MIGRATE_DATA` env var is removed); seed explicitly with `fld db migrate` (`seed_static_data()` in `data/models.py`, only if the DB has no users yet); backups via `fld db backup` / `fld db restore`
|
|
174
|
+
- Key/value `config` table for the dashboard title and admin messages (`fld db config ...`; run `fld db init --force` after schema changes)
|
|
175
|
+
- **Warning:** Default static users (admin/admin123, user1/user123, user2/user223) must be deleted or have passwords changed in production!
|
|
176
|
+
|
|
177
|
+
### Current State
|
|
178
|
+
- Database-backed user, group, site, site-group and access management (active/inactive flags; `name`/`username` plus ids for the CLI, `description`/`full-name` for display)
|
|
179
|
+
- Dynamic sidebar based on user permissions; site groups sorted alphabetically, sites sorted within groups (overridable via `--sort-order`)
|
|
180
|
+
- Sidebar is collapsible via a hamburger button in the header, implemented with pure HTML/CSS (checkbox hack in `dash.html` + `partials/header.html`, rules in `style.css`) -- no JavaScript; hidden by default on screens up to 768px (`@media (max-width: 768px)`)
|
|
181
|
+
- Both iframe-based and Jinja2-template-based sites supported; tooltips on the dashboard
|
|
182
|
+
- Configurable dashboard title and admin messages (`info`/`important`) via the `config` table; `[DEV]`/`[TEST]` markers in titles
|
|
183
|
+
- Subdomain services can be protected via Nginx `auth_request` against `/auth/verify[/<site_id>]` (per-site access check via `user_can_access_site()`, read-only session check — the inactivity timeout does not slide on subdomain requests)
|
|
184
|
+
|
|
185
|
+
## 🤖 AI Assistant Guidelines
|
|
186
|
+
|
|
187
|
+
### Working with the Codebase
|
|
188
|
+
1. **Update documentation first** - Check AGENTS.md, README.md, and CHANGELOG.md for current state
|
|
189
|
+
2. **Test your changes** - Keep test suite up to date, run tests after changes
|
|
190
|
+
3. **Follow existing patterns** - Maintain code style, structure, and naming conventions
|
|
191
|
+
4. **If in doubt, ask** - Clarify requirements before making significant changes
|
|
192
|
+
|
|
193
|
+
### Development Workflow
|
|
194
|
+
```bash
|
|
195
|
+
# Lint code
|
|
196
|
+
hatch run lint
|
|
197
|
+
|
|
198
|
+
# Format code
|
|
199
|
+
hatch run format
|
|
200
|
+
|
|
201
|
+
# Run tests
|
|
202
|
+
hatch run pytest
|
|
203
|
+
|
|
204
|
+
# Build package
|
|
205
|
+
hatch build
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## 📖 Additional Resources
|
|
209
|
+
|
|
210
|
+
- **README.md** - User documentation, installation, and usage
|
|
211
|
+
- **CHANGELOG.md** - Recent changes and TODO items
|
|
212
|
+
- **docs/** - `nginx_auth.md` (subdomain protection via Nginx), `pamconfig.md`, `validation.md`, demo `index.html`
|
|
213
|
+
- **pyproject.toml** - Project configuration, dependencies, and Hatch scripts
|
|
214
|
+
- **Tests** - Comprehensive test suite in `tests/`
|
|
215
|
+
- **Source** - https://codeberg.org/rokor/flshbd
|
|
216
|
+
- **Issues** - https://codeberg.org/rokor/flshbd/issues
|
|
217
|
+
|
|
218
|
+
## 🙏 Contribution Guidelines
|
|
219
|
+
|
|
220
|
+
When contributing to this project:
|
|
221
|
+
|
|
222
|
+
1. Follow existing code style (ruff configuration in pyproject.toml)
|
|
223
|
+
2. Update tests for any new functionality
|
|
224
|
+
3. Add documentation for new features
|
|
225
|
+
4. Maintain backward compatibility where possible
|
|
226
|
+
5. Run lint, format, and test suite before submitting changes
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
**Project Status**: ✅ Active development (v0.0.8)
|
|
231
|
+
**Last Updated**: November 2026
|
|
232
|
+
**Maintainer**: Robert Kormann, assisted by [Opencode](https://opencode.ai) and [Mistral](https://mistral.ai)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Cleanups
|
|
4
|
+
|
|
5
|
+
- Check CSP definitions
|
|
6
|
+
|
|
7
|
+
## TODO
|
|
8
|
+
|
|
9
|
+
- Implementation of MD-based static sites within a Jinja2 template
|
|
10
|
+
- Implement better logging
|
|
11
|
+
- Enter password always via corresponding field, not CLI, esp. for `modify`
|
|
12
|
+
- Howto empty values like email for users?
|
|
13
|
+
- The CLI command `fld db migrate` might hit the wrong environment. It might be useful to trigger a DB backup before changes are made there.
|
|
14
|
+
|
|
15
|
+
## v0.0.9
|
|
16
|
+
|
|
17
|
+
- New optional dependency `python-dotenv` (`pip install flshbd[dotenv]`): all `FLSHBD_*` env vars can also be set in `<DATA_DIR>/.env` (`flshbd-data/.env` in development/testing, `~/.config/flshbd/.env` in production).
|
|
18
|
+
- New `FLSHBD_SESSION_LIFETIME` env var to adjust the session inactivity timeout in seconds (default 1800 = 30 min, sliding); it is mapped to Flask's `PERMANENT_SESSION_LIFETIME`.
|
|
19
|
+
- Database schema is now auto-initialized at first server start (`create_app()` → `ensure_database_initialized()`), if not there. The lazy init in `get_database()` remains as a safety net for CLI-only usage
|
|
20
|
+
- Removed the `FLSHBD_MIGRATE_DATA` env var
|
|
21
|
+
- Update of `AGENTS.md`, adaption of the sites Info & Help to describe _FlashBoard_, style tweaks
|
|
22
|
+
- Collapsible sidebar via hamburger button in the header, pure HTML/CSS (checkbox hack, no JS); hidden by default on small screens (max. 768px)
|
|
23
|
+
- New `FLSHBD_TEMPLATE_FOLDER` / `FLSHBD_STATIC_FOLDER` env vars. For details see `Readme.md` and `Agents.md`.
|
|
24
|
+
- Fixed stale coverage omit paths in `pyproject.toml`
|
|
25
|
+
|
|
26
|
+
## v0.0.8
|
|
27
|
+
|
|
28
|
+
- New `/auth/verify[/<site_id>]` route for Nginx `ngx_http_auth_request_module`. It returns plain status codes (204/401/403).
|
|
29
|
+
- Per-site authorization via the existing group-based access control
|
|
30
|
+
- Important: Session check for type iframe is read-only (no sliding on subdomain requests). Adapt the inactivity timeout via `FLSHBD_SESSION_LIFETIME`, if necessary
|
|
31
|
+
- New `FLSHBD_COOKIE_DOMAIN` env var / `SESSION_COOKIE_DOMAIN` config to share the session cookie across subdomains (e.g. `.example.com`)
|
|
32
|
+
- New `user_can_access_site()` helper in `flshbd.data.models`
|
|
33
|
+
- Update of README.md and AGENTS.md
|
|
34
|
+
- Explanation of the method in `docs/nginx_auth.md`, incl. "Prerequisites" (cookie domain, HTTPS, stable secret key, SameSite) and "Testing with curl" sections, and self-contained demo site `index.html` to be iframed in _FlashBoard_
|
|
35
|
+
- Removed unused `GUNICORN_BIND` config
|
|
36
|
+
|
|
37
|
+
## v0.0.7 "Bond"
|
|
38
|
+
|
|
39
|
+
- Replace `0.0.0.0` by `localhost`
|
|
40
|
+
- Replace `main_view.html` by `main.html` (readability)
|
|
41
|
+
- Smaller footer & header
|
|
42
|
+
- URL added to `fld site list -v`
|
|
43
|
+
- Users are always lowercase
|
|
44
|
+
- Formatting & linting
|
|
45
|
+
- Short 1-letter flags for important options
|
|
46
|
+
|
|
47
|
+
## v0.0.6
|
|
48
|
+
|
|
49
|
+
- Improvement of the DB structure (ids for machine, name for humans, breaking change)
|
|
50
|
+
- New `sites` and `site-groups` now possible
|
|
51
|
+
- Tooltips for the dashboard page
|
|
52
|
+
|
|
53
|
+
## v0.0.5
|
|
54
|
+
|
|
55
|
+
- `[DEV]` / `[TEST]` mark near the titles for clarity
|
|
56
|
+
- FlashBoard's `title` (login, header) adjustable in the db's config table
|
|
57
|
+
- FlashBoard Admin Messages implemented
|
|
58
|
+
- Copyleft remarks, improvement of docs
|
|
59
|
+
- Switch default env to `production`
|
|
60
|
+
- Env-enabled config vars start with `FLSHBD_`
|
|
61
|
+
- Response delay for unsuccessful db login attempts for security
|
|
62
|
+
|
|
63
|
+
## v0.0.4
|
|
64
|
+
|
|
65
|
+
- Hatch version corrected
|
|
66
|
+
- Extend the auth logic with `use_dba`.
|
|
67
|
+
- Incomplete isolation of environments fixed
|
|
68
|
+
- Consistent tests with PAM active or inactive
|
|
69
|
+
- Ephemeral or env-driven `FLSHBD_SECRET_KEY`.
|
|
70
|
+
|
|
71
|
+
## v0.0.3
|
|
72
|
+
|
|
73
|
+
- Adding a "What is this?" dropdown below the login form.
|
|
74
|
+
- Improving CSS for screen and print
|
|
75
|
+
- `fld --env production db migrate` now working
|
|
76
|
+
- `fld dash status`/`fld dash stop` are aware of the enviroment
|
|
77
|
+
- Config `USE_DB` and deprecated env variable `FLASK_ENV` removed
|
|
78
|
+
|
|
79
|
+
## v0.0.2
|
|
80
|
+
|
|
81
|
+
- Refactoring of the data model
|
|
82
|
+
- Code reorganisation and cleanup, recheck of consistent imports
|
|
83
|
+
- New database table `config` with CLI commands (`fld db init --force` necessary!)
|
|
84
|
+
- Reorganisation of data directories
|
|
85
|
+
- CLI: `None` values resented as `---`
|
|
86
|
+
- Updated `README.md` and `AGENTS.md`
|
|
87
|
+
|
|
88
|
+
## v0.0.1
|
|
89
|
+
|
|
90
|
+
- Initial release, based on unpublished `aimd`
|
flshbd-0.0.9/LICENSE.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
|
|
4
|
+
|
|
5
|
+
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and
|
|
6
|
+
successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
9
|
+
|
|
10
|
+
For more information, please refer to <http://unlicense.org/>
|
flshbd-0.0.9/PKG-INFO
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: flshbd
|
|
3
|
+
Version: 0.0.9
|
|
4
|
+
Summary: FlashBoard
|
|
5
|
+
Project-URL: Documentation, https://codeberg.org/rokor/flshbd#readme
|
|
6
|
+
Project-URL: Issues, https://codeberg.org/rokor/flshbd/issues
|
|
7
|
+
Project-URL: Source, https://codeberg.org/rokor/flshbd
|
|
8
|
+
Author-email: Robert Kormann <rokor@kormann.info>
|
|
9
|
+
License-Expression: Unlicense
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Keywords: dashboard,flask
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Requires-Dist: click>=8.0.0
|
|
20
|
+
Requires-Dist: flask>=3.0.0
|
|
21
|
+
Requires-Dist: werkzeug>=3.0.0
|
|
22
|
+
Provides-Extra: dotenv
|
|
23
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == 'dotenv'
|
|
24
|
+
Provides-Extra: gunicorn
|
|
25
|
+
Requires-Dist: gunicorn>=21.0.0; extra == 'gunicorn'
|
|
26
|
+
Provides-Extra: pam
|
|
27
|
+
Requires-Dist: python-pam>=2.0.0; extra == 'pam'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# flshbd
|
|
31
|
+
|
|
32
|
+
**A simple, Flask-based dashboard**
|
|
33
|
+
|
|
34
|
+
[](https://pypi.org/project/flshbd)
|
|
35
|
+
[](https://pypi.org/project/flshbd)
|
|
36
|
+
|
|
37
|
+
-----
|
|
38
|
+
|
|
39
|
+
## Table of Contents
|
|
40
|
+
|
|
41
|
+
- [Installation](#installation)
|
|
42
|
+
- [FlashBoard](#flashboard)
|
|
43
|
+
- [Administration](#administration)
|
|
44
|
+
- [Protecting services on subdomains](#protecting-services-on-subdomains)
|
|
45
|
+
- [License](#license)
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
_**Remark**_ _FlashBoard_ is not published yet on PyPI.
|
|
50
|
+
|
|
51
|
+
```console
|
|
52
|
+
pip install flshbd
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Optional installs are `pam` for Linux's [Pluggable Authentication Module](https://github.com/linux-pam/linux-pam) and `gunicorn` ([Gunicorn](https://gunicorn.org/)) as [WSGI server](https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface).
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
_**Alpha** Software_
|
|
60
|
+
|
|
61
|
+
This software is in **Alpha** State. Check the [changelog](CHANGELOG.md) for information on potential changes in the upcoming versions. Furthermore, as long as we are in *Alpha* (micro versions), there might be breaking changes.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## FlashBoard
|
|
66
|
+
|
|
67
|
+
_FlashBoard_ is a small Flask-based web application that provides an interface to organize and access -- mainly local -- tools or services. The dashboard features a clean header/sidebar/main/footer layout with user authentication, and access control based on user groups.
|
|
68
|
+
|
|
69
|
+
Users are organized in (user) groups, and sites are collected in site groups. The sidebar dynamically displays only these site groups a user has access to, based on her or his (user) group memberships. This allows for a personalized dashboard experience. The information about users and sites, their groups and the access table are stored in a SQLite3 database. The user and site groups can be changed on-the-fly during normal operation of _FlashBoard_, and is backed by a static model for testing and development.
|
|
70
|
+
|
|
71
|
+
The sidebar can be hidden and shown via the hamburger button in the header. On small screens (max. 768px width) the sidebar is hidden by default, and can be toggled open the same way.
|
|
72
|
+
|
|
73
|
+
_FlashBoard_ supports for its sites both, iframe-based content (_FlashBoard_-external services, typically on the same machine, or within the same LAN, and shown as site) in the main (view), and Jinja2-based template content (_FlashBoard_-internal sites). Session management is handled through client-side cookies with a configurable inactivity timeout.
|
|
74
|
+
|
|
75
|
+
## Administration
|
|
76
|
+
|
|
77
|
+
The dashboard includes a CLI for managing it, `fld dash <start/stop/status>`, and can operate in the environments _development_ (Flask-internal server in debug mode), or _production_ (Gunicorn- or Flask server-based, default).
|
|
78
|
+
The SQLite3 databases, one for _development_ within the current (typ. project) folder `flshbd-data`, and a user-based folder `~/.config/flshbd` (XDG compliant) for _production_, are administered also via the same command `fld` on CLI. The structure of `fld` is `fld [--env <production/development>] command [command options] subcommand [subcommand options] [parameter]`. Most commands should be obvious, e.g., the command for _production_ user management reads `fld user <list/add/modify/delete>`. Use `--help` (short `-h`) at each command level for the available options.
|
|
79
|
+
|
|
80
|
+
On the first server start, the database is auto-initialized with an empty schema, if not there (parallel to the templates and static files, see below). It can be populated by hand (e.g., `fld user add ...`), or from the static model running `fld db migrate`. The latter copies the static three `user/password` pairs, `admin/admin123`, `user1/user123`, and `user2/user223` (of course, salted and hashed in the databases), and contents for user groups, site and site groups. Check it, using the CLI commands, e.g., `fld user list -v`. Of course, now you can login using the static user credentials, and inspect the default sites and site groups, which are accessible for the user groups.
|
|
81
|
+
|
|
82
|
+
**Warning** These static users MUST be deleted (or at least their password changed) in a _production_ environment for obvious reasons!
|
|
83
|
+
|
|
84
|
+
Users and sites can be active or inactive. Site goups are sorted alphabetically within the sidebar, as well as sites within site groups. This can be overruled, e.g., for sites via `fld site modify <site> --sort-order <integer>` (defaults to 0, smaller is earlier in the list). Misaligned sites or site groups might lead to non-existing links within _FlashBoard_. In this case, the top-most site is shown. It is therefore useful to place an informative site there. All objects have a `name` (`username` for users) used internally and for the CLI, and a `description` (`full-name` for users) used for the dashboards.
|
|
85
|
+
|
|
86
|
+
The title of _FlashBoard_ can be set, e.g., to "My Dashboard" via `fld db config set title "My Dashboard"`, or reset by `fld db config set title ""`. The title keyword and its value is stored within the database in a (string-based) key/value table `config`. Using the same key/value scheme, the keys `info` and `important` create messages above the login area. Important messages overwrite info messages. Values of these keys can only be text messages, HTML is not allowed.
|
|
87
|
+
|
|
88
|
+
Templates and static files are taken from the environment's data directory (`flshbd-data/` in _development_, `~/.config/flshbd/` in _production_): on the first start they are populated automatically with the bundled copies shipped with _FlashBoard_, and can then be customized per environment (e.g., additional partials for template sites, which `fld site add --type template` validates against the resolved template folder). Set the environment variables `FLSHBD_TEMPLATE_FOLDER` and `FLSHBD_STATIC_FOLDER` to use custom locations instead. Note that template sites are Jinja2-rendered with the privileges of the _FlashBoard_ process.
|
|
89
|
+
|
|
90
|
+
The folders are resolved once when the server process starts, so changing them requires a restart (Flask and Gunicorn alike); edits to template files are picked up live only in _development_, while static files are always read from disk per request. Details in `AGENTS.md`.
|
|
91
|
+
|
|
92
|
+
All `FLSHBD_*` environment variables can alternatively be set in a `.env` file within the environment's data directory (`flshbd-data/.env` in _development_, `~/.config/flshbd/.env` in _production_): on the first start, a documented copy of the bundled defaults is placed there (never overwritten), and can then be edited per environment. Loading the file requires the optional dependency `python-dotenv` (`pip install flshbd[dotenv]`). The precedence is: exported environment variable first, `.env` value second, built-in default third. The values are read once at process start, so changes require a restart.
|
|
93
|
+
|
|
94
|
+
The signing of the session cookie is performed by an ephemeral secret key, which is created when starting a _FlashBoard_ session via `fld dash start`. As a consequence, all existing sessions become invalid, when _FlashBoard_ is (re)started. To avoid this, create an environment variable `FLSHBD_SECRET_KEY` (`fld dash generate-secret-key` might help).
|
|
95
|
+
|
|
96
|
+
The session inactivity timeout (a sliding timeout, default 1800 s = 30 min) can be adjusted via the `FLSHBD_SESSION_LIFETIME` environment variable, whose value is the timeout in seconds (e.g. `FLSHBD_SESSION_LIFETIME=3600`). Unset or invalid values fall back to the default.
|
|
97
|
+
|
|
98
|
+
## Protecting services on subdomains
|
|
99
|
+
|
|
100
|
+
_FlashBoard_ can also guard iframe-type services running on subdomains (e.g. `service.example.com`) while _FlashBoard_ itself runs behind a reverse proxy at `example.com`. This uses Nginx's [`ngx_http_auth_request_module`](https://nginx.org/en/docs/http/ngx_http_auth_request_module.html): for every request to the subdomain, Nginx first makes an internal subrequest to _FlashBoard_'s `/auth/verify` endpoint, which checks the session cookie and — if a site is given — whether the user has access to that site.
|
|
101
|
+
|
|
102
|
+
Please see [Nginx auth](docs/nginx_auth.md) for more details on this functionality.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
`flshbd` is distributed under the terms of the [Unlicense](https://unlicense.org) license.
|
flshbd-0.0.9/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# flshbd
|
|
2
|
+
|
|
3
|
+
**A simple, Flask-based dashboard**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/flshbd)
|
|
6
|
+
[](https://pypi.org/project/flshbd)
|
|
7
|
+
|
|
8
|
+
-----
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [FlashBoard](#flashboard)
|
|
14
|
+
- [Administration](#administration)
|
|
15
|
+
- [Protecting services on subdomains](#protecting-services-on-subdomains)
|
|
16
|
+
- [License](#license)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
_**Remark**_ _FlashBoard_ is not published yet on PyPI.
|
|
21
|
+
|
|
22
|
+
```console
|
|
23
|
+
pip install flshbd
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Optional installs are `pam` for Linux's [Pluggable Authentication Module](https://github.com/linux-pam/linux-pam) and `gunicorn` ([Gunicorn](https://gunicorn.org/)) as [WSGI server](https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface).
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
_**Alpha** Software_
|
|
31
|
+
|
|
32
|
+
This software is in **Alpha** State. Check the [changelog](CHANGELOG.md) for information on potential changes in the upcoming versions. Furthermore, as long as we are in *Alpha* (micro versions), there might be breaking changes.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## FlashBoard
|
|
37
|
+
|
|
38
|
+
_FlashBoard_ is a small Flask-based web application that provides an interface to organize and access -- mainly local -- tools or services. The dashboard features a clean header/sidebar/main/footer layout with user authentication, and access control based on user groups.
|
|
39
|
+
|
|
40
|
+
Users are organized in (user) groups, and sites are collected in site groups. The sidebar dynamically displays only these site groups a user has access to, based on her or his (user) group memberships. This allows for a personalized dashboard experience. The information about users and sites, their groups and the access table are stored in a SQLite3 database. The user and site groups can be changed on-the-fly during normal operation of _FlashBoard_, and is backed by a static model for testing and development.
|
|
41
|
+
|
|
42
|
+
The sidebar can be hidden and shown via the hamburger button in the header. On small screens (max. 768px width) the sidebar is hidden by default, and can be toggled open the same way.
|
|
43
|
+
|
|
44
|
+
_FlashBoard_ supports for its sites both, iframe-based content (_FlashBoard_-external services, typically on the same machine, or within the same LAN, and shown as site) in the main (view), and Jinja2-based template content (_FlashBoard_-internal sites). Session management is handled through client-side cookies with a configurable inactivity timeout.
|
|
45
|
+
|
|
46
|
+
## Administration
|
|
47
|
+
|
|
48
|
+
The dashboard includes a CLI for managing it, `fld dash <start/stop/status>`, and can operate in the environments _development_ (Flask-internal server in debug mode), or _production_ (Gunicorn- or Flask server-based, default).
|
|
49
|
+
The SQLite3 databases, one for _development_ within the current (typ. project) folder `flshbd-data`, and a user-based folder `~/.config/flshbd` (XDG compliant) for _production_, are administered also via the same command `fld` on CLI. The structure of `fld` is `fld [--env <production/development>] command [command options] subcommand [subcommand options] [parameter]`. Most commands should be obvious, e.g., the command for _production_ user management reads `fld user <list/add/modify/delete>`. Use `--help` (short `-h`) at each command level for the available options.
|
|
50
|
+
|
|
51
|
+
On the first server start, the database is auto-initialized with an empty schema, if not there (parallel to the templates and static files, see below). It can be populated by hand (e.g., `fld user add ...`), or from the static model running `fld db migrate`. The latter copies the static three `user/password` pairs, `admin/admin123`, `user1/user123`, and `user2/user223` (of course, salted and hashed in the databases), and contents for user groups, site and site groups. Check it, using the CLI commands, e.g., `fld user list -v`. Of course, now you can login using the static user credentials, and inspect the default sites and site groups, which are accessible for the user groups.
|
|
52
|
+
|
|
53
|
+
**Warning** These static users MUST be deleted (or at least their password changed) in a _production_ environment for obvious reasons!
|
|
54
|
+
|
|
55
|
+
Users and sites can be active or inactive. Site goups are sorted alphabetically within the sidebar, as well as sites within site groups. This can be overruled, e.g., for sites via `fld site modify <site> --sort-order <integer>` (defaults to 0, smaller is earlier in the list). Misaligned sites or site groups might lead to non-existing links within _FlashBoard_. In this case, the top-most site is shown. It is therefore useful to place an informative site there. All objects have a `name` (`username` for users) used internally and for the CLI, and a `description` (`full-name` for users) used for the dashboards.
|
|
56
|
+
|
|
57
|
+
The title of _FlashBoard_ can be set, e.g., to "My Dashboard" via `fld db config set title "My Dashboard"`, or reset by `fld db config set title ""`. The title keyword and its value is stored within the database in a (string-based) key/value table `config`. Using the same key/value scheme, the keys `info` and `important` create messages above the login area. Important messages overwrite info messages. Values of these keys can only be text messages, HTML is not allowed.
|
|
58
|
+
|
|
59
|
+
Templates and static files are taken from the environment's data directory (`flshbd-data/` in _development_, `~/.config/flshbd/` in _production_): on the first start they are populated automatically with the bundled copies shipped with _FlashBoard_, and can then be customized per environment (e.g., additional partials for template sites, which `fld site add --type template` validates against the resolved template folder). Set the environment variables `FLSHBD_TEMPLATE_FOLDER` and `FLSHBD_STATIC_FOLDER` to use custom locations instead. Note that template sites are Jinja2-rendered with the privileges of the _FlashBoard_ process.
|
|
60
|
+
|
|
61
|
+
The folders are resolved once when the server process starts, so changing them requires a restart (Flask and Gunicorn alike); edits to template files are picked up live only in _development_, while static files are always read from disk per request. Details in `AGENTS.md`.
|
|
62
|
+
|
|
63
|
+
All `FLSHBD_*` environment variables can alternatively be set in a `.env` file within the environment's data directory (`flshbd-data/.env` in _development_, `~/.config/flshbd/.env` in _production_): on the first start, a documented copy of the bundled defaults is placed there (never overwritten), and can then be edited per environment. Loading the file requires the optional dependency `python-dotenv` (`pip install flshbd[dotenv]`). The precedence is: exported environment variable first, `.env` value second, built-in default third. The values are read once at process start, so changes require a restart.
|
|
64
|
+
|
|
65
|
+
The signing of the session cookie is performed by an ephemeral secret key, which is created when starting a _FlashBoard_ session via `fld dash start`. As a consequence, all existing sessions become invalid, when _FlashBoard_ is (re)started. To avoid this, create an environment variable `FLSHBD_SECRET_KEY` (`fld dash generate-secret-key` might help).
|
|
66
|
+
|
|
67
|
+
The session inactivity timeout (a sliding timeout, default 1800 s = 30 min) can be adjusted via the `FLSHBD_SESSION_LIFETIME` environment variable, whose value is the timeout in seconds (e.g. `FLSHBD_SESSION_LIFETIME=3600`). Unset or invalid values fall back to the default.
|
|
68
|
+
|
|
69
|
+
## Protecting services on subdomains
|
|
70
|
+
|
|
71
|
+
_FlashBoard_ can also guard iframe-type services running on subdomains (e.g. `service.example.com`) while _FlashBoard_ itself runs behind a reverse proxy at `example.com`. This uses Nginx's [`ngx_http_auth_request_module`](https://nginx.org/en/docs/http/ngx_http_auth_request_module.html): for every request to the subdomain, Nginx first makes an internal subrequest to _FlashBoard_'s `/auth/verify` endpoint, which checks the session cookie and — if a site is given — whether the user has access to that site.
|
|
72
|
+
|
|
73
|
+
Please see [Nginx auth](docs/nginx_auth.md) for more details on this functionality.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
`flshbd` is distributed under the terms of the [Unlicense](https://unlicense.org) license.
|