2016-07-20 3 views
0

を有効に私はは、私がここでy.example.com</p> <p>でホストされているWebページにx.example.comからのiframeを表示しようとしていますサブドメインのiframeアクセス

Tomcat用して行っている設定です。

<filter> 
    <filter-name>ClickJackFilterEnabled</filter-name> 
    <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class> 
    <init-param> 
     <param-name>antiClickJackingEnabled</param-name> 
     <param-value>false</param-value> 
    </init-param> 
</filter> 

<filter-mapping> 
    <filter-name>ClickJackFilterEnabled</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

春のセキュリティ:私は組み込みiframsでページを開くと

httpResponse.setHeader("Content-Security-Policy", "default-src 'self' *.example.com; style-src 'self' *.googleapis.com *.amazonaws.com 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; child-src 'self' *.example.com; font-src *;img-src 'self' *.amazonaws.com"); 
    httpResponse.setHeader("Access-Control-Allow-Origin", "http://*.example.com"); 

、私はまだgettinのよグラムこのエラー:私はカール、ヘッダX-フレーム・オプションを使用してヘッダをチェックすると

Refused to display 'http://x.example.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. 

Uncaught SecurityError: Sandbox access violation: Blocked a frame at "http://y.example.com" from accessing a frame at "http://x.example.com". The frame being accessed is sandboxed and lacks the "allow-same-origin" flag. 

この

カール
* Rebuilt URL to: y.example.com/ 
    % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
    0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0* Trying 127.0.0.1... 
* Connected to y.example.com (127.0.0.1) port 80 (#0) 
> GET/HTTP/1.1 
> Host: y.example.com 
> User-Agent: curl/7.47.0 
> Accept: */* 
> 
< HTTP/1.1 200 OK 
< Server: Apache-Coyote/1.1 
< X-Content-Type-Options: nosniff 
< X-XSS-Protection: 1; mode=block 
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate 
< Pragma: no-cache 
< Expires: 0 
< X-Application-Context: application:dev:8080 
< Content-Security-Policy: default-src 'self' *.example.com; style-src 'self' *.googleapis.com *.amazonaws.com 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; child-src 'self' *.example.com; font-src *;img-src 'self' *.amazonaws.com 
< Access-Control-Allow-Origin: http://*.example.com 
< Content-Type: text/html;charset=UTF-8 
< Content-Language: en-IN 
< Transfer-Encoding: chunked 
< Date: Wed, 20 Jul 2016 13:21:57 GMT 
< 
{ [8200 bytes data] 

の出力、私は何をしないのですが存在しません。 ?

はUPDATE:

私は

document.domain 

を入力すると、私はまだエラー

Refused to display 'http://x.example.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN' 

を取得しています、両方のWebページに

document.domain = "example.com" 

を設定しようとしましたJavaScriptのコンソでル、私は得ている

両方のWebページで。したがって、両方のページの原点は同じです。

答えて

0

x.example.comは、SAMEORIGINヘッダーを送信するものです。 y.example.comはこれをオーバーライドできません。なぜならiframeインクルードをブロックする方法がないからです。サイトは、コンテンツを含めるために、他のサイトへのアクセス許可(発信元ポリシーまたは許可を得たサイトのリストがないことによる)を許可する必要があります。

x .example.comからのヘッダーを確認すると、実際にiframeをブロックするポリシーが表示されます。

+0

両方のサブドメインが同じサーバー上にホストされ、設定が同じである場合、両方のサブドメインによって返されるヘッダーはまったく同じです。 –

0

最後に問題を解決できました。この問題はおそらく、ブラウザがX-Frame-Optionsヘッダーをどのように処理するかにあります。

document.domain = "example.com" 

設定の背後にある考え方は、両方のWebページの起源が同じようにすることです。ブラウザはそうaxexample.comのページでも、document.domainをにx.example.comまたはにexample.com今

の値を設定することができ、親ドメインに起源を設定することが可能設定後document.domain to 例です。私はX-Freme-オプションが完全にヘッダ削除すると、COMが、私は

securityConfiguration.javaで
http.headers().frameOptions().disable(); 

使用して、エラー

Refused to display 'http://x.example.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN' 

を得ていた、それが働きました!

ブラウザがdocument.domain設定を尊重しなかった理由はわかりません。これについては、mozillaのドキュメンテーションなどでは何も見つかりませんでした。これが誰かを助けることを望みます。

関連する問題