2017-01-15 2 views
1

私は同様の質問に対する回答を見ましたが、2017年には、* .domain.tldへの正当なアクセスを制限したい場合には、CORS for S3/CFの最適な設定方法が何であるか疑問に思っています。 JavascriptはCFからロードされ、api.domain.tldにAjaxリクエストを使用してWebアプリケーションをレンダリングします。S3/CFでJavascriptをホストするCORSの推奨設定は何ですか?

<?xml version="1.0" encoding="UTF-8"?> 
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
    <CORSRule> 
     <AllowedOrigin>*.domain.tld</AllowedOrigin> 
     <AllowedMethod>GET</AllowedMethod> 
     <AllowedMethod>HEAD</AllowedMethod> 
     <AllowedMethod>OPTIONS</AllowedMethod> 
     <MaxAgeSeconds>3000</MaxAgeSeconds> 
     <AllowedHeader>*</AllowedHeader> 
    </CORSRule> 
</CORSConfiguration> 

CORS設定を改善するために追加できるものは他にありますか?

答えて

1

次は、CORSの設定を行うための一般的なルールです:

1)A valid CORS configuration consists of 0 to 100 CORS rules. 
2)Each rule must include at least one origin. 
3)An origin may contain at most one wildcard * 
4)Each rule must include at least one method. 
5)The supported methods are: GET, HEAD, PUT, POST, DELETE. 
6)Each rule may contain an identifying string of up to 255 characters. 
7)Each rule may specify zero or more allowed request headers (which the client may include in the request). 
8)Each rule may specify zero or more exposed response headers (which are sent back from the server to the client). 
9)Each rule may specify a cache validity time of zero or more seconds. If not included, the client should supply their own default. 

は最近、私はJS/CFプロジェクトの一つで働いていたし、ここで私のCORS設定です。あなたはhere

おかげ

見つけることができます

<CORSConfiguration> 
<CORSRule> 
    <ID>example.com: Allow PUT & POST with AWS S3 JS 
    SDK</ID> 
    <AllowedOrigin>https://www.example.com</AllowedOrigin> 
    <AllowedOrigin>http://www.example.com</AllowedOrigin> 
    <AllowedOrigin>https://example.com</AllowedOrigin> 
    <AllowedOrigin>http://example.com</AllowedOrigin> 
    <AllowedMethod>PUT</AllowedMethod> 
    <AllowedMethod>POST</AllowedMethod> 
    <AllowedHeader>Origin</AllowedHeader> 
    <AllowedHeader>Content-Length</AllowedHeader> 
    <AllowedHeader>Content-Type</AllowedHeader> 
    <AllowedHeader>Content-MD5</AllowedHeader> 
    <AllowedHeader>X-Amz-User-Agent</AllowedHeader> 
    <AllowedHeader>X-Amz-Date</AllowedHeader> 
    <AllowedHeader>Authorization</AllowedHeader> 
    <ExposeHeader>ETag</ExposeHeader> 
    <MaxAgeSeconds>1800</MaxAgeSeconds> 
</CORSRule> 
<CORSRule> 
    <ID>example.com: Allow GET with AWS S3 JS SDK</ID> 
    <AllowedOrigin>*</AllowedOrigin> 
    <AllowedMethod>GET</AllowedMethod> 
    <AllowedMethod>HEAD</AllowedMethod> 
    <AllowedHeader>*</AllowedHeader> 
    <ExposeHeader>ETag</ExposeHeader> 
    <MaxAgeSeconds>1800</MaxAgeSeconds> 
</CORSRule> 
</CORSConfiguration> 

詳細

関連する問題