Middleware & Sécurité

Permissions-Policy

Preset par défaut

Refusés (toutes origines) :

FeatureCatégorie
accelerometerCapteur
ambient-light-sensorCapteur
bluetoothMatériel
cameraMatériel
gyroscopeCapteur
hidMatériel
magnetometerCapteur
microphoneMatériel
midiMatériel
serialMatériel
usbMatériel
geolocationLocalisation
idle-detectionVie privée
display-captureCapture écran
paymentPaiements
interest-cohortFingerprinting (désactive FLoC)
local-fontsFingerprinting
sync-xhrLegacy / déprécié
xr-spatial-trackingXR
window-managementMulti-fenêtre

Autorisés pour la même origine ((self)) :

FeatureNotes
fullscreenBesoin UX standard
picture-in-pictureBesoin UX standard
publickey-credentials-createWebAuthn / passkeys
publickey-credentials-getWebAuthn / passkeys

Configuration via le builder

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

Méthodes disponibles

MéthodeValeur headerDescription
.deny("feature")feature=()Refus total
.allow_self("feature")feature=(self)Même origine uniquement
.allow_any("feature")feature=*Toutes origines
.allow("feature", vec!["https://…"])feature=("url1" "url2")Origines explicites

Les méthodes surchargent le défaut pour cette directive. Les directives non mentionnées conservent leur valeur par défaut.


Conserver le défaut

Ne pas appeler .with_permissions_policy — le preset sécurisé s'applique automatiquement.