Commit Graph
92 Commits
Author SHA1 Message Date
Safihre 3376cb5143 Escape the server-supplied NNTP message during testing 2026-09-14 22:24:09 +02:00
Safihre ab702860df Refactor color scheme implementation
Moves theme-specific styles into main CSS files for each interface,
leveraging `color-scheme` and `light-dark()` CSS functions. This
consolidates styling, reduces HTTP requests, and improves automatic
dark/light mode detection based on OS preferences.
2026-09-02 22:02:33 +02:00
mnightingale 58c3c13954 Update jQuery to 3.7.1 2026-08-31 16:32:13 +02:00
mnightingale b192a7eca4 Persistent sessions, CSRF tokens, and no apikey in the web interface (#3559)
* Add a session store that keeps web-UI logins in the admin folder

* Authenticate the web interface with session cookies and CSRF tokens

* Stop embedding the apikey in the web interface

* Cover the session, CSRF and apikey changes
2026-08-27 13:05:12 +02:00
coopa11yandcoopa11y 21d639bf5f Announce news server test results to screen readers (#3566)
Co-authored-by: coopa11y <coopa11y@users.noreply.github.com>
2026-08-19 11:31:14 +02:00
mnightingale 35d5355f49 Replace CherryPy with Uvicorn and Starlette (#3550)
* Migrate web interface from CherryPy to Uvicorn/Starlette

Squashed rebase of feature/uvicorn (34 commits) onto develop, reconciled
with ~3 months of intervening develop changes.

Replaces the CherryPy webserver and request handling with Uvicorn/Starlette
across the API, web interface, RSS, config pages and related modules.

Reconciliation with develop during the rebase:
- api.py: kept develop's security/behaviour fixes (orphan path-traversal
  guard, expanded log redaction incl. host_whitelist and
  remote_label_replacement, get_dconfig single-return, get_retryable_jobs,
  connections default, translated NNTP test errors) on top of the Starlette
  request/response rewrite.
- interface.py: ported the RSS route handlers to develop's DB-backed
  RSSRepository API (process_feed, rss_repository / find_job_by_url /
  clear_feed / clear_downloaded / flag_downloaded).
- misc.py: kept develop's hachoir-based get_media_duration.
- requirements.txt: dropped the CherryPy stack, adopted develop's newer pins.

Also applied ruff --fix (PEP 604 unions, builtin generics) to align with
develop's lint config.

Verified: ruff check, black --check, and the affected test suites
(9413 passed, 1 skipped) all pass.

* Update starlette/uvicorn versions

* Fix race issues in global rss state

* Fix test race in server shutdown

The uvicorn migration turned /shutdown (and the shutdown API) into fire-and-forget: it spawned shutdown_program() in a background thread and replied immediately, whereas develop ran it synchronously and only replied once halt() had persisted all state. Because the module-scoped test teardown doesn't wait for the process to exit, the next module's clean_cache_dir wiped the shared cache dir (and reused the fixed port) while the previous instance was still saving state and holding the port — producing the three intermittent failures (deleted sabnzbd.log → "File log disabled or not found"; un-persisted [sorters] → KeyError; stale instance → missing wizard .quoteBlock).

* Fix robots and description, add favicon

* Remove remains of http basic auth

* Setup Starlette once configuration is available, fix static file relative cwd and url_base config

* abort_and_show_error when webserver fails to start

* Guard stopping webserver that never started

* Delegate XFF handling to ProxyHeadersMiddleware

* Merged params at request.state.params instead of modifying private apis

* Both shutdown routes share implementation and do not block event loop

* Run sync handlers via run_in_threadpool and facilitate eventual migration to async

* Pool database connections

* Online backup of database due to WAL changes

* Fix exception on None request.client (test clients or unix sockets)

* Fix flakey tests due to process not fully shutting down

* Restore X-Frame-Options behaviour via middleware

* Fix set_config_default with multiple keywords

* Remove broken logging call

* Restore api logging functionality

* Cache-Control: no-store

* Login only via POST

* Remove 401 (basic-auth) and add 404 handling via redirect

* Fix crash when shutdown not an int

* Use BaseRedirectResponse helper

* Remove trailing slashes from wizard routes

* URL helper, absolute URLs everywhere, fixes issues with nested navigation

* Fix scheduler adding multiple daysofweek

* Restore CherryPy api behaviour merging body with query params (body wins)

* Clearer documentation of get_request_params and request_params

* First stage supporting gradual api async

* Fix rss ajax consuming flash

* Restore access log functionality

* Hostname check in middleware

* Request logging in middleware

* Param parsing in middleware

* Security checks in middleware

* secured_expose is now purely route registration

* Lookup api handler once per request

* Fix flakey alert dialogs

* Trigger restart via BackgroundTask

* Restore CherryPy first param wins and get/post consistency

* Remove dead code

* Secure cookies based on protocol the client used

* Fix various issues with port_is_free

1. port_is_free answered the wrong question. It connect-probed ("is something answering?") rather than bind-probed ("can I bind?"). A port could report free and then kill startup at uvicorn's bind().
2. The bind-all remap crossed address families. :: was mapped to 127.0.0.1, probing IPv4 for an IPv6 bind — a regression against portend, which maps :: → ::1.
3. The call sites passed the wrong host. browserhost is a client-reachable address; the thing that has to be bindable is web_host.
4. Errors were swallowed. A bare except OSError hid gaierror, so an unresolvable host reported "free".
5. find_free_port had a port-0 trap. Under a bind-probe, currentport=0 always succeeds and returned 0 — the old failure sentinel. Now guarded, and None instead of 0.
6. Ports 80/443 were misdiagnosed. EACCES was folded into "occupied", producing ten futile probes and a panic claiming another program held the port. PermissionError now propagates to a dedicated panic explaining the actual remedies.
7. The tests were largely tautological. Three tests covering one branch, an IPv6 test with no IPv6 in it, a timeout test that never engaged the timeout, TOCTOU-prone fixed-range probes, no SO_REUSEADDR on the helper listener, and nothing asserting the property that matters — that "free" implies bindable.
8. A portability bug I introduced, then fixed. I'd baked Linux SO_REUSEADDR overlap semantics into four assertions; macOS differs. Now platform-aware, with the IPv6 regression re-covered by checking the socket family directly.

* Claim the bind address for uvicorn on startup, resolves "49" in err handling from cherrypy

* Rename function BaseRedirectResponse to base_redirect_response

* Restore error response on change web directory

* Add missing typings

* Fix return type of retry job for future types

* A better fix for xdist compatibility - test overwrote db_path

* Secure session cookies (rss flash)

* Inline or remove some functions

* Retry job futuretype behaviour

* Sneak a worksteal fix in

* Test and fix retry_job futuretype behaviour
2026-08-11 13:27:51 +01:00
Safihre fee562d57f Increase default NNTP server connections to 16
Updates the default number of connections from 8 to 16 in the server configuration and wizard UI templates. This change aims to improve performance for users who do not explicitly configure this setting.

Additionally, ensures the API server test function defaults to at least 1 connection when none is specified.

Relates to #3284
2026-06-14 13:34:22 +02:00
Safihre e969276828 Extend custom toggle switch styling to login and wizard 2026-06-11 11:40:11 +02:00
Safihre e3acbdc8c2 Use commit hash for static asset cache busting
Closes #3457
2026-06-11 11:10:43 +02:00
Safihre 08bcddf8d2 Style login and wizard pages after recent changes 2026-06-05 14:32:04 +02:00
Safihre de5abc95f5 Further improvements to styling revamp 2026-05-23 22:05:45 +02:00
Safihre e63648c9c4 Give the Config a little bit more modern feeling 2026-05-21 10:06:01 +02:00
Safihre cd5acde5d2 Set pipeling requests to 2 for new servers (#3362) 2026-03-23 22:51:02 +01:00
Safihre c1417c319d Add tooltip that users need to Test Server before saving/next 2025-10-13 16:24:04 +02:00
Safihre ec18606557 Require correct server test in Wizard
Closes #3148
General refactor.
2025-09-25 13:40:25 +02:00
Safihre d9aa42dc31 Add new Certificate verification setting Medium
Closes #2993
2024-12-18 13:18:50 +01:00
Safihre ee717b679e Set limits to number-input types that were missing them 2024-07-13 19:39:53 +02:00
Safihre cb7c37a836 Remove outdated certificate validation check
It was relevant in Python 2.7-days.
This was we also don't make any external HTTP calls on start-up anymore, so hopefully we upset less virus scanners.
2024-01-03 22:04:42 +01:00
Safihre a5e860a60f Apply correct JS comparisons 2023-10-02 09:51:37 +02:00
Safihre 58cb710d38 Improve Night-mode display of folder selection 2023-09-01 15:34:44 +02:00
thezoggy c3dbd77c17 fixup dark theme handling for config/login with using auto or loading explicit night theme when set, minor dark skin fixes (#2665) 2023-08-26 21:37:43 +02:00
Safihre d0f1574893 Further improvements to dark mode 2023-08-22 12:29:54 +02:00
Andrew LavryshynandSafihre cab5c26e3e Add dark mode for wizard, config, and login (#2621)
* feat: add dark mode for wizard, config, and login

* combine the dark skins

* make the buttons the same as in Glitter

* load the night theme based on config setting

* Changes to darkmode

---------

Co-authored-by: Safihre <safihre@sabnzbd.org>
2023-08-07 11:34:25 +02:00
Safihre 7cbbff727f Remove (almost) all references to unused team@sabnzbd.org 2023-07-21 11:33:51 +02:00
Safihre 53ce88d3d2 Make Config link to wiki dynamic 2023-04-26 22:24:53 +02:00
Safihre 84fc6e7a7a Enable Newsserver SSL by default 2023-02-15 22:52:32 +01:00
Safihre 8597784bc6 Correct tests after server timeout correction 2022-11-03 11:24:36 +01:00
puzzledsabandSafihre 75f6cc7f0f Backup and restore admin data (#2023)
* Backup and restore admin data

* Don't import archives containing subpaths

* Show result after uploading

* Use existing upload system and fixed list of admin files

* Fix confusing order of code lines

* Add translations and link from wizard

* Refactoring, change some names and move some code to sabnzbd.config

* Remove unused imports

* Remove queue and scan databases from backup

* Style changes

* Code changes

* Add tests and don't crash if any admin files are missing

* Cleanup

* Small changes and rebase on develop

Co-authored-by: Safihre <safihre@sabnzbd.org>
2022-01-22 09:51:01 +01:00
Safihre 87da19caa3 Additional cleanup of interface.py functions 2021-05-23 09:53:12 +02:00
Safihre ce29c1f5cb Updata Javascript libraries in the Config 2020-06-07 10:44:34 +02:00
Safihre fbde994106 Replace "session" by "apikey"
Out with the old crap
2020-05-25 12:30:36 +02:00
Safihre 51c9da73fe Remove tapi and replace by api 2020-05-25 12:30:36 +02:00
Safihre d7bea6f134 Merge branch 'develop' into py3 2018-12-25 10:54:56 +01:00
Safihre e8206371e4 Update Wizard example URL 2018-12-14 08:41:00 +01:00
Safihre 579e07adc3 Merge branch 'develop' into py3 2018-10-12 10:10:10 +02:00
Safihre d86fb42d28 Code-style changes 2018-09-05 14:51:16 +02:00
Safihre 43d8283f5b Wizard final page not linking to Folders config page
Closes #1163
2018-07-31 22:07:01 +02:00
Safihre 281acce610 Py3: Fixes after merge of develop 2018-06-09 19:29:40 +02:00
Safihre 20fbea6e31 Rework security flow of webpages
Have 1 wrapper that checks all secuirty checks and exposes the package for CherryPy.
Cleaner code that can then be used to implement global security checks.
Merged wizard.py into interface.py and removed lots of overhead code that is handled by the general system.
2018-03-13 16:03:49 +01:00
Safihre 91a2532c95 Show warning in wizard when language files are not present
Closes #1074
2017-11-25 10:51:31 +01:00
Safihre 8aa57bf406 Update Config jQuery to 3.2.1 and Peity to 3.2.1 2017-08-17 11:00:47 +02:00
Safihre 690731fd79 Update wizard Ad URL 2017-08-16 13:34:01 +02:00
Safihre 91c1ea97fd Update display of Certificate Validation
Unfortunately requires new translations. "Default" is just not correct anymore.
2017-04-03 15:24:58 +02:00
Safihre 89f91e46b7 Add Certificate Validation option to Wizard
Otherwise a user would be stuck.
2017-02-18 22:52:42 +01:00
Safihre df26adfe89 Accidentally removed SSL-choice from Wizard 2017-02-18 22:52:42 +01:00
Safihre 4fb6e3fe7b Remove check for ssl module
Any Python setup has it, it was only introduced to check for PyOpenSSL which is now dropped.
2017-02-18 22:52:42 +01:00
Safihre edc01c3e2b Some cache-busting on version upgrade for JS/CSS 2017-01-18 18:16:06 +01:00
Safihre 15dcb274c3 Remove old jQuery
Closes #766
2017-01-12 12:48:53 +01:00
Safihre 09568274b3 Update jQuery to 3.1.1 for Config
Not yet in Glitter, there it causes some side-effects
2017-01-06 14:36:12 +01:00
Safihre 8855ce9414 Hide non-regular Server settings behind 'Advanced' button 2016-12-24 22:17:27 +01:00