Files
rickyandClaude Opus 5.5 5876c07a1a Harden installs reachable from the internet without a proxy
- Refuse to start with a placeholder or short SECRET_KEY_BASE (under 32
  characters); warn and fail sam:doctor under 64. .env.example no longer
  ships a placeholder.
- First-run setup needs a one-time code printed only in the server log, so
  only whoever runs the server can create the admin account.
- AirTrail: the server resolves the address and connects to exactly that;
  never the server itself or link-local addresses (cloud metadata);
  private-network addresses only for admins or hosts in
  AIRTRAIL_ALLOWED_HOSTS.
- Host authorization when APP_HOST is set: APP_HOST, the APP_URL host,
  ALLOWED_HOSTS, localhost and IP addresses; /up exempt. A blocked name
  gets a short explanation instead of a blank 403.
- docker-compose.direct.yml: HTTPS without a proxy via Thruster's built-in
  Let's Encrypt (TLS_DOMAIN).
- Notes' Markdown no longer allows the unused class attribute.
- README, .env.example and the user guide updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:42:53 -05:00

29 lines
920 B
Ruby

class SetupController < ApplicationController
allow_unauthenticated_access
before_action { redirect_to root_path if User.exists? }
rate_limit to: 10, within: 15.minutes, only: :create, with: -> { redirect_to new_setup_path, alert: t("flash.setup.try_again_later") }
layout "public"
def new
@user = User.new
SetupCode.announce
end
def create
@user = User.new(params.require(:user).permit(:name, :email_address, :password, :password_confirmation))
@user.admin = true
unless SetupCode.matches?(params[:setup_code])
@user.errors.add(:base, t("flash.setup.wrong_code"))
SetupCode.announce
return render(:new, status: :unprocessable_entity)
end
if @user.save
SetupCode.clear
start_new_session_for @user
redirect_to root_path, notice: t("flash.setup.welcome_you_re_the")
else
render :new, status: :unprocessable_entity
end
end
end