Class: Azure::Core::Auth::Signer
- Inherits:
-
Object
- Object
- Azure::Core::Auth::Signer
- Defined in:
- lib/azure/core/auth/signer.rb
Overview
Utility class to sign strings with HMAC-256 and then encode the signed string using Base64.
Direct Known Subclasses
SharedKey, Storage::Common::Core::Auth::AnonymousSigner, Storage::Common::Core::Auth::SharedAccessSignatureSigner, Storage::Common::Core::Auth::TokenSigner
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
The access key for the account.
Instance Method Summary collapse
-
#initialize(access_key) ⇒ Signer
constructor
Initialize the Signer.
-
#sign(body) ⇒ String
Generate an HMAC signature.
Constructor Details
#initialize(access_key) ⇒ Signer
Initialize the Signer.
30 31 32 33 34 35 36 |
# File 'lib/azure/core/auth/signer.rb', line 30 def initialize(access_key) if access_key.nil? raise ArgumentError, 'Signing key must be provided' end @access_key = Base64.decode64(access_key) end |
Instance Attribute Details
#access_key ⇒ Object (readonly)
The access key for the account
25 26 27 |
# File 'lib/azure/core/auth/signer.rb', line 25 def access_key @access_key end |
Instance Method Details
#sign(body) ⇒ String
Generate an HMAC signature.
43 44 45 46 |
# File 'lib/azure/core/auth/signer.rb', line 43 def sign(body) signed = OpenSSL::HMAC.digest('sha256', access_key, body) Base64.strict_encode64(signed) end |