Content-Security-Policy-Report-Onlyを追加
This commit is contained in:
parent
ddde68ad2d
commit
b888c66ca2
11 changed files with 76 additions and 56 deletions
|
|
@ -172,6 +172,14 @@ export class ClientServerService {
|
|||
fastify.addHook('onRequest', (request, reply, done) => {
|
||||
// クリックジャッキング防止のためiFrameの中に入れられないようにする
|
||||
reply.header('X-Frame-Options', 'DENY');
|
||||
|
||||
// XSSが存在した場合に影響を軽減する
|
||||
// (script-srcにunsafe-inline等を追加すると意味が無くなるので注意)
|
||||
const csp = this.config.contentSecurityPolicy
|
||||
?? 'script-src \'self\' \'unsafe-eval\' ' +
|
||||
'https://challenges.cloudflare.com https://hcaptcha.com https://*.hcaptcha.com https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/ https://www.recaptcha.net/recaptcha/; ' +
|
||||
'base-uri \'self\'; object-src \'self\';';
|
||||
reply.header('Content-Security-Policy', csp);
|
||||
done();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue