class Azure::ServiceBus::Auth::SharedAccessSigner
Attributes
expiry_offset[RW]
The number of seconds from the time of signature that the SAS token will expire
key_name[RW]
The number of seconds from the time of signature that the SAS token will expire
Public Class Methods
new(key_name=Azure.sb_sas_key_name, key=Azure.sb_sas_key, expiry_offset = 60*5)
click to toggle source
Public: Initialize the Signer.
@param #key_name [String] The service bus SAS key name. Defaults to the one in the global configuration. @param key [String] The service bus SAS key encoded in Base64. Defaults to the one in the global configuration. @param #expiry_offset [Integer] The number of seconds from the time of signature that the SAS token will expire. Defaults to 30 minutes.
# File lib/azure/service_bus/auth/shared_access_signer.rb, line 16 def initialize(key_name=Azure.sb_sas_key_name, key=Azure.sb_sas_key, expiry_offset = 60*5) @access_key = key @key_name, @expiry_offset = key_name, expiry_offset end
Public Instance Methods
name()
click to toggle source
# File lib/azure/service_bus/auth/shared_access_signer.rb, line 21 def name 'SharedAccessSignature' end
sign_request(req)
click to toggle source
# File lib/azure/service_bus/auth/shared_access_signer.rb, line 32 def sign_request(req) req.headers['Authorization'] = token(req.uri) end
token(uri)
click to toggle source
# File lib/azure/service_bus/auth/shared_access_signer.rb, line 25 def token(uri) url_encoded_resource = CGI.escape(uri.to_s.downcase).gsub('+', '%20').downcase expiry = Time.now.to_i + expiry_offset sig = CGI.escape(signature(url_encoded_resource, expiry)).gsub('+', '%20') "#{name} sig=#{sig}&se=#{expiry}&skn=#{key_name}&sr=#{url_encoded_resource}" end
Private Instance Methods
signature(url_encoded_resource, expiry)
click to toggle source
# File lib/azure/service_bus/auth/shared_access_signer.rb, line 38 def signature(url_encoded_resource, expiry) sign([url_encoded_resource, expiry].join("\n")) end