feat: add time parameter type and HTTP security headers#1
Merged
Conversation
**`time` parameter type** - Backend (`parameter_config.py`): `time_format` config field (default `%H:%M`), validation against `%H:%M`, and format conversion in `map_to_script()` so scripts receive the time in the configured strftime format. - Frontend: new `TimeField.vue` component wrapping `<input type="time">`, wired into `script-parameters-view.vue`; admin form shows a `time_format` field when the type is `time` (via `parameter-fields.js` and `ParameterConfigForm.vue`). - Tests: 10 new assertions in `parameter_config_test.py` covering validation (valid times, midnight, end-of-day, invalid format, non-time string, out-of-range hour) and format conversion (default, compact `%H%M`, with-seconds). **HTTP security headers** - Added `_set_security_headers()` helper in `server.py`, called by both `BaseRequestHandler` and `BaseStaticHandler`. - New headers on every response: `X-Content-Type-Options: nosniff`, `Referrer-Policy: strict-origin-when-cross-origin`, and a `Content-Security-Policy` that allows `'self'` sources, inline styles, data-URI fonts/images, WebSocket connections (`ws: wss:`), and blocks frame embedding (`frame-ancestors 'none'`) and object embeds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The background userinfo call (which updates groups after a token refresh) was racing against a 0.1 s access-token TTL. On a loaded Python 3.10 CI runner the coroutine sometimes started after the fresh token had already expired, producing a 401 and leaving groups empty. Fix: raise access_expiration_duration 0.1 → 0.5 s and refresh_expiration_duration 0.6 → 2.0 s so issued tokens outlive any realistic event-loop scheduling delay. The hardcoded sleep in test_success_validate_after_refresh is changed from the magic number 0.5 s to `access_expiration_duration + 0.2` so it stays valid as the constant changes. All other tests already reference the module-level constants directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduce auth_info_ttl=1.0s constant so the test_read_tokens_from_request sleep (0.6s) stays below the TTL threshold and test_success_validate_after_refresh sleep (1.5s) stays above it, giving sufficient margin on both sides for CI jitter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
knep
pushed a commit
that referenced
this pull request
May 28, 2026
- HTTP security headers: add Permissions-Policy and HSTS to the table, note that WebSocket responses are now also covered - date/time types: mention startup validation of date_format/time_format - CI: update matrix to 3.10/3.11/3.12/3.13 - Python 3.13: add breaking-change note on DES-crypt htpasswd passwords Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
timeparameter type — shows a native time picker in the UI; the script receives the time in a configurable Python strftime format (default%H:%M).X-Content-Type-Options,Referrer-Policy, and aContent-Security-Policyheader alongside the existingX-Frame-Options: DENY.Changes
timeparameter typeBackend (
src/model/parameter_config.py)time_formatconfig field (default%H:%M, 24-hour clock).validate_value(): parses the browser wire format (HH:MM), rejects seconds, invalid hours, non-time strings.map_to_script(): parses%H:%Mand re-formats totime_formatbefore passing to the script.Configuration example:
{ "name": "start_time", "type": "time", "time_format": "%H:%M" }time_formatis a Python strftime format string. Examples:%H:%M(default),%H%M,%I:%M %p.Frontend
web-src/src/common/components/inputs/TimeField.vue—<input type="time">with required/error handling, mirrorsDateField.vue.script-parameters-view.vueroutestype === 'time'toTimeField.ParameterConfigForm.vue+parameter-fields.js) addstimeto the type dropdown and shows aTime formatfield when selected.Tests (
src/tests/parameter_config_test.py) — 10 new assertions:%H%M, with-seconds%H:%M:%S.HTTP security headers (
src/web/server.py)Added a shared
_set_security_headers()helper called by bothBaseRequestHandlerandBaseStaticHandler:X-Frame-OptionsDENY(was already present, now centralised)X-Content-Type-OptionsnosniffReferrer-Policystrict-origin-when-cross-originContent-Security-Policydefault-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' ws: wss:; frame-ancestors 'none'; object-src 'none'CSP rationale:
style-src 'unsafe-inline'— Materialize CSS injects inline styles.connect-src ws: wss:— WebSocket used for live script output streaming.frame-ancestors 'none'— equivalent toX-Frame-Options: DENYfor modern browsers.object-src 'none'— blocks Flash/plugin embeds.Test plan
src/tests/parameter_config_test.py— 188 tests pass (10 new time tests included)htpasswd.cryptremoved in Python 3.13+, unrelated)🤖 Generated with Claude Code