Class: Azure::Blob::Auth::SharedAccessSignature
- Inherits:
-
Core::Auth::Signer
- Object
- Core::Auth::Signer
- Azure::Blob::Auth::SharedAccessSignature
- Defined in:
- lib/azure/blob/auth/shared_access_signature.rb
Constant Summary collapse
- DEFAULTS =
{ resource: 'b', permissions: 'r', version: '2013-08-15' }
- KEY_MAPPINGS =
{ permissions: :sp, start: :st, expiry: :se, resource: :sr, identifier: :si, version: :sv, cache_control: :rscc, content_disposition: :rscd, content_encoding: :rsce, content_language: :rscl, content_type: :rsct }
- OPTIONAL_QUERY_PARAMS =
[:sp, :si, :rscc, :rscd, :rsce, :rscl, :rsct]
Instance Attribute Summary collapse
-
#account_name ⇒ Object
readonly
Returns the value of attribute account_name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Core::Auth::Signer
Instance Method Summary collapse
- #canonicalized_resource ⇒ Object
-
#initialize(path, options, account_name = Azure.config.storage_account_name, access_key = Azure.config.storage_access_key) ⇒ SharedAccessSignature
constructor
Public: Initialize the Signer.
-
#signable_string ⇒ Object
Public: Construct the plaintext to the spec required for signatures.
-
#signed_uri ⇒ Object
Public: A customised URI reflecting options for the resource signed with the Shared Access Signature.
- #to_s ⇒ Object
Methods inherited from Core::Auth::Signer
Constructor Details
#initialize(path, options, account_name = Azure.config.storage_account_name, access_key = Azure.config.storage_access_key) ⇒ SharedAccessSignature
Public: Initialize the Signer.
Attributes
-
path
- the container or blob path -
options
- Hash. Required and optional parameters -
account_name
- The account name. Defaults to the one in theglobal configuration.
-
access_key
- The access_key encoded in Base64. Defaults to theone in the global configuration.
Options
-
:resource
- String. Resource type, either ‘b’ (blob) or ‘c’ (container). Default ‘b’ -
:permissions
- String. Combination of ‘r’,‘w’,‘d’,‘l’ (container only) in this order. Default ‘r’ -
:start
- String. UTC Date/Time in ISO8601 format. Optional. -
:expiry
- String. UTC Date/Time in ISO8601 format. Required. -
:identifier
- String. Identifier for stored access policy. Optional -
:version
- String. API version. Default ‘2013-08-15’ -
+:cache_control - String. Response header override. Optional.
-
+:content_disposition - String. Response header override. Optional.
-
+:content_encoding - String. Response header override. Optional.
-
+:content_language - String. Response header override. Optional.
-
+:content_type - String. Response header override. Optional.
79 80 81 82 83 84 85 |
# File 'lib/azure/blob/auth/shared_access_signature.rb', line 79 def initialize(path, , account_name=Azure.config.storage_account_name, access_key=Azure.config.storage_access_key) @path = path @account_name = account_name @options = DEFAULTS.merge() super(access_key) end |
Instance Attribute Details
#account_name ⇒ Object (readonly)
Returns the value of attribute account_name.
52 53 54 |
# File 'lib/azure/blob/auth/shared_access_signature.rb', line 52 def account_name @account_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
51 52 53 |
# File 'lib/azure/blob/auth/shared_access_signature.rb', line 51 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
50 51 52 |
# File 'lib/azure/blob/auth/shared_access_signature.rb', line 50 def path @path end |
Instance Method Details
#canonicalized_resource ⇒ Object
108 109 110 |
# File 'lib/azure/blob/auth/shared_access_signature.rb', line 108 def canonicalized_resource "/#{account_name}/#{path}" end |
#signable_string ⇒ Object
Public: Construct the plaintext to the spec required for signatures
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/azure/blob/auth/shared_access_signature.rb', line 88 def signable_string # Order is significant # The newlines from empty strings here are required [ [:permissions], [:start], [:expiry], canonicalized_resource, [:identifier], [:version], [:cache_control], [:content_disposition], [:content_encoding], [:content_language], [:content_type] ].join("\n") end |
#signed_uri ⇒ Object
Public: A customised URI reflecting options for the resource signed with the Shared Access Signature
113 114 115 116 |
# File 'lib/azure/blob/auth/shared_access_signature.rb', line 113 def signed_uri query_params = URI.encode_www_form(query_hash) "https://#{account_name}.blob.core.windows.net/#{path}?#{query_params}" end |
#to_s ⇒ Object
118 119 120 |
# File 'lib/azure/blob/auth/shared_access_signature.rb', line 118 def to_s signed_uri end |