helmetjs / helmet

Help secure Express apps with various HTTP headers
https://helmetjs.github.io/
MIT License
10.24k stars 369 forks source link

Request to add `Permissions-Policy` header #470

Closed AshGw closed 3 months ago

AshGw commented 4 months ago

I propose adding a new middleware option in Helmet to set the Permissions-Policy header, which I think can be a great add-on to the existing security middlewares.

Example Implementation

app.use(permissionsPolicy({
    features: {
        geolocation: ['self'],
        camera: [],
        microphone: []
    },
    directives: {
        accelerometer: "'none'",
        autoplay: ["'self'", 'https://example.com'],
        syncXhr: ["'self'"],
        usb: "'none'"
    },
    reportOnly: false,
    reportUri: '/report-violation', 
    forceHTTPS: true  
}));
EvanHahn commented 4 months ago

Permissions-Policy is still in a draft state. It's also unsupported in Firefox or Safari, so I'm hesitant to add it.

For now, here are some options:

Would that work for you?

AshGw commented 3 months ago

That'll do