小さなウェブサイトではHanamiを試しています。本番環境では、非常に厳しいデフォルトのセキュリティ設定が適用されます。ここでは、サーバのレスポンスヘッダです:に結果のフレームワークの厳しいコンテンツセキュリティポリシーのヘッダーがReCaptchaを破損しています
cf-ray:2f14dcb05e2307e5-LAX
content-encoding:gzip
content-security-policy:form-action 'self'; frame-ancestors 'self'; base-uri 'self'; default-src 'none'; script-src 'self' 'sha256-IAaN58htbUDxfKhUX+LYHn2kWUEjPKf5lepkdtqd1gU=' https://www.google.com/recaptcha/api.js https://www.gstatic.com https://www.google-analytics.com/analytics.js https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/; connect-src 'self'; img-src 'self' https: data:; style-src 'self' 'unsafe-inline' https:; font-src 'self' https://fonts.gstatic.com https://fonts.googleapis.com; object-src 'none'; plugin-types application/pdf; child-src 'self'; frame-src 'self' https://www.google.com/recaptcha/; media-src 'self'
content-type:text/html; charset=utf-8
date:Thu, 13 Oct 2016 18:30:19 GMT
server:cloudflare-nginx
status:200
via:1.1 vegur
x-content-type-options:nosniff
x-frame-options:DENY
x-xss-protection:1; mode=block
:私のコンテンツセキュリティポリシーヘッダー内の
何かがreCAPTCHAのが作業できるようにされていません。以下の応答ヘッダでは、localhostの開発で正常に動作念頭に置いて、それを保管してください:
Content-Security-Policy:form-action 'self'; frame-ancestors 'self'; base-uri 'self'; default-src 'none'; script-src 'self' 'sha256-IAaN58htbUDxfKhUX+LYHn2kWUEjPKf5lepkdtqd1gU=' https://www.google.com/recaptcha/api.js https://www.gstatic.com https://www.google-analytics.com/analytics.js https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/; connect-src 'self'; img-src 'self' https: data:; style-src 'self' 'unsafe-inline' https:; font-src 'self' https://fonts.gstatic.com https://fonts.googleapis.com; object-src 'none'; plugin-types application/pdf; child-src 'self'; frame-src 'self' https://www.google.com/recaptcha/; media-src 'self'
Content-Type:text/html; charset=utf-8
Transfer-Encoding:chunked
X-Content-Type-Options:nosniff
X-Frame-Options:DENY
X-XSS-Protection:1; mode=block
ここで生産のためのCSPを定義するブロックがあります:私は許可を追加する必要があるよう
# Content Security Policy usage:
#
# * http://content-security-policy.com/
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
#
# Content Security Policy references:
#
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives
#
security.content_security_policy %{
form-action 'self';
frame-ancestors 'self';
base-uri 'self';
default-src 'none';
script-src 'self' 'sha256-IAaN58htbUDxfKhUX+LYHn2kWUEjPKf5lepkdtqd1gU=' https://www.google.com/recaptcha/api.js https://www.gstatic.com https://www.google-analytics.com/analytics.js https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/;
connect-src 'self';
img-src 'self' https: data:;
style-src 'self' 'unsafe-inline' https:;
font-src 'self' https://fonts.gstatic.com https://fonts.googleapis.com;
object-src 'none';
plugin-types application/pdf;
child-src 'self';
frame-src 'self' https://www.google.com/recaptcha/;
media-src 'self'
}
が見えますスクリプトをロードする。 I'm following Google's own CSP rules。
ここに問題がありますか?
編集:grecaptcha
オブジェクトがページに存在しないため、セキュリティポリシーで'https://www.google.com/recaptcha/api.js'
スクリプトを読み込まないように見えます。
googleは 'script-src'の区切り文字として'、 'を使います。あなたは 'space'を使います – slowjack2k
@ slowjack2kフレームワークがセキュリティポリシーハッシュをどのように消費しているかのように見えます。 [こちらをご覧ください](https://github.com/hanami/hanami/blob/113eeb41df8e9c5b8d763b2a6e40d68e9ff61885/test/fixtures/security_headers/apps/web/application.rb#L36) –