skip to content

Hardening & Secrets

Rails ships its own defences: forgery tokens, encrypted credentials, column encryption, CSP and host checks, and rate_limit. Interviewers ask which are on by default and which you must enable.

part ofRuby on Railsread it →
on this pageshow

explore

questions

page 2 of 2

In Rails 8.1, which header does config.permissions_policy actually emit, and how does a controller override it for one action?

level: middleimportance: nice to knowfreq 15%

basics

~10 s

Despite its name, Rails 8.1's permissions_policy DSL writes the legacy Feature-Policy header; a controller's permissions_policy only: block edits a clone of the global policy, which must exist because the override cannot start from nothing.

open as a page

In a Rails 8.1 app, what can the rate_limit macro not protect that a Rack middleware limiter can, and what does each layer know about the request?

level: seniorimportance: nice to knowfreq 20%

basics

~20 s

rate_limit is a before_action, so it guards only actions that declare it, after middleware, routing and controller setup; a Rack middleware limiter sees every request earlier and more cheaply, but without the controller's knowledge of the user.

open as a page

showing 31–32 of 32