Skip to content

Replica: feat(make-user): non-interactive mode via POSTAL_INITIAL_USER_* env vars#72

Open
lucaforni wants to merge 10 commits into
main-modalsourcefrom
maxlevine-mhi-postal-feat/non-interactive-make-user
Open

Replica: feat(make-user): non-interactive mode via POSTAL_INITIAL_USER_* env vars#72
lucaforni wants to merge 10 commits into
main-modalsourcefrom
maxlevine-mhi-postal-feat/non-interactive-make-user

Conversation

@lucaforni
Copy link
Copy Markdown

Questa PR replica la PR originale: postalserver#3574

Autore originale: @maxlevine-mhi
Branch originale: feat/non-interactive-make-user
Repository originale: maxlevine-mhi/postal


Adds non-interactive support to postal make-user. When POSTAL_INITIAL_USER_EMAIL is set, make-user skips HighLine prompts and reads all four fields from env: POSTAL_INITIAL_USER_EMAIL, POSTAL_INITIAL_USER_FIRST_NAME, POSTAL_INITIAL_USER_LAST_NAME, POSTAL_INITIAL_USER_PASSWORD. Upserts by email (creates new or updates first/last/password on existing). Exit code is non-zero on missing vars or validation failure. Interactive path is unchanged. Adds spec/util/user_creator_spec.rb covering create, update, missing-var, validation-failure. For local testing on the fork before any upstream submission. Companion docs PR: postalserver/docs#89

adamcooke and others added 10 commits February 1, 2026 14:48
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
The app-wide CSP already blocks inline script execution, but the HTML
preview iframe for a stored email was same-origin and un-sandboxed, and
the html_raw response had no per-action hardening. Add a sandbox on the
iframe and tighten the CSP on html_raw to script-src 'none' with
nosniff and no-referrer so the preview has defence in depth against a
future CSP bypass or regression.

Relates to GHSA-f6g9-8555-cw28.
The /img/<server>/<message> endpoint accepted a src=<url> query
parameter and proxied the body of that URL back to the caller. Nothing
in the codebase ever produces a src= parameter — the parser only
inserts a plain tracking pixel and rewrites href links — so this branch
is dead code inherited from the original AppMail import.

Drop the src branch: requests with src now return 400. The no-src path
that serves the tracking pixel and records loads is unchanged, and a
spec covers both the pixel-serving path and the removed branch.
The endpoint and domain option helpers interpolated model attributes
straight into an HTML string before marking the whole buffer html_safe.
Wrap the interpolations in h() so untrusted attributes can't break out
of the surrounding tag.

Also stop the helpers glob in rails_helper from eagerly requiring
_spec.rb files so helper specs can live under spec/helpers/, and add a
small application helper spec covering the escape behaviour.
url_with_return_to only checked that return_to started with a forward
slash, which also allowed protocol-relative values like //host and
/\host. Rails 7.1 already refuses to follow those via redirect_to, so
the user just saw a 500. Reject the same shapes in the helper instead
so we fall back to the default URL cleanly.

Adds a sessions request spec covering the rejected shapes plus the
happy-path relative redirect.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants