4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS 署名付きURL発行を試す

Last updated at Posted at 2013-10-21

概要

結果

  • 対象のS3オブジェクトへのアクセス権限が設定できる
  • URLの有効期限を設定できる
  • 秒単位で設定する
  • 有効期限は任意(デフォルト900s)
  • 期限切れになると、レスポンスコード : AccessDeniedが返される
  • 発行されたURL(署名)は無効にできない
  • 署名の改ざんはできない
  • 署名はリクエストパラメータとして付加される
  • パラメータにはAWSAccessKeyID、Expires、Signatureが含まれる
  • AWSAccessKeyId、 Signatureはもちろん、 Expiresも変更(改ざん)不可
  • 改ざんした場合、レスポンスコードでSignatureDoseNotMatch が返される

検証コード

require 'aws-sdk'

object_name = "test_object"
bucket_name = "test_bucket"
expires = 60*60

uris = {}
s3 = AWS::S3.new
obj = s3.buckets[bucket_name].objects[object_name]
uri = obj.url_for(:read, :expires => expires).to_s
puts uri
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?