小编blu*_*hrt的帖子

amazon S3存储桶策略 - 限制referer的访问但不限制是否通过查询字符串身份验证生成URL

我的存储桶上设置了以下存储桶策略:

{

"Version": "2008-10-17",

"Id": "My access policy",

"Statement": [

     {

 "Sid": "Allow only requests from our site",

 "Effect": "Allow",

 "Principal": { "AWS": "*"},

 "Action": "s3:GetObject",

 "Resource": "arn:aws:s3:::my_bucket/*",

 "Condition": {

   "StringLike": {

      "aws:Referer": [" http://mydomain.com/*"," http://www.mydomain.com/*"]

        }

              }

 },

{

   "Sid": "Dont allow direct acces to files  when no referer is present",

   "Effect": "Deny",

   "Principal": {"AWS": "*" },

  "Action": "s3:GetObject",

  "Resource": "arn:aws:s3:::my_bucket/*",

  "Condition": {

  "Null": {"aws:Referer": true }

         }

         }

]

  }
Run Code Online (Sandbox Code Playgroud)

我还配置了查询字符串身份验证,但看起来我不能同时拥有它们.如果我将我的存储桶策略设置为拒绝任何不是源自mydomain的请求,则使用查询字符串身份验证的临时URL也将无法提供.所以我的问题是,我怎么能同时拥有这两个?有没有办法检查url参数,看看它是否有一个名为"Signature"的参数,在这种情况下不应用引用策略?

policy amazon amazon-s3 bucket query-string

14
推荐指数
1
解决办法
1万
查看次数

当状态未立即更新时,ReactJS表单验证

我正在尝试使用ReactJS在我的注册表单上创建客户端验证.我使用http://validatejs.org/库进行验证,并使用https://github.com/jhudson8/react-semantic-ui组件来渲染semantic-ui React组件.这是代码.

var constraints = {
  email: {
    presence: true, 
    email:true
  }, 
  password: {
    presence: true,
    length: { minimum: 5 }
  }
}

var RegistrationForm = React.createClass({

  getInitialState: function() {
    return { 
      data: {},
      errors: {}
    };
  },

  changeState: function () {
    this.setState({
      data: {
        email: this.refs.email.getDOMNode().value,
        password: this.refs.password.getDOMNode().value,
        password_confirmation:  this.refs.password_confirmation.getDOMNode().value
      }
    });
    console.log("State after update");
    console.log(this.state.data);
  },

  handleChange: function(e) {
    this.changeState();
    var validation_errors = validate(this.state.data, constraints);

    if(validation_errors){
      console.log(validation_errors);
      this.setState({errors: validation_errors});
    }
    else
      this.setState({errors: {}});
  }, …
Run Code Online (Sandbox Code Playgroud)

javascript forms validation reactjs react-rails

6
推荐指数
1
解决办法
3625
查看次数