Middleware & Security

Permissions-Policy

Default preset

Denied (all origins):

FeatureCategory
accelerometerSensor
ambient-light-sensorSensor
bluetoothHardware
cameraHardware
gyroscopeSensor
hidHardware
magnetometerSensor
microphoneHardware
midiHardware
serialHardware
usbHardware
geolocationLocation
idle-detectionPrivacy
display-captureScreen capture
paymentPayments
interest-cohortFingerprinting (disables FLoC)
local-fontsFingerprinting
sync-xhrLegacy / deprecated
xr-spatial-trackingXR
window-managementMulti-window

Allowed for same origin ((self)):

FeatureNotes
fullscreenStandard UX need
picture-in-pictureStandard UX need
publickey-credentials-createWebAuthn / passkeys
publickey-credentials-getWebAuthn / passkeys

Configuration via the builder

.middleware(|m| {
    m.with_permissions_policy(|p| {
        p.deny("geolocation")
         .allow_self("fullscreen")
         .allow("payment", vec!["https://pay.example.com"])
    })
})

Available methods

MethodHeader valueDescription
.deny("feature")feature=()Deny all origins
.allow_self("feature")feature=(self)Same origin only
.allow_any("feature")feature=*Any origin
.allow("feature", vec!["https://…"])feature=("url1" "url2")Specific origins

Methods override the default for that directive. Directives not mentioned keep their default value.


Keeping the default

Do not call .with_permissions_policy — the secure default applies automatically.