Class: AzureBlob::EntraIdSigner
- Inherits:
-
Object
- Object
- AzureBlob::EntraIdSigner
- Defined in:
- lib/azure_blob/entra_id_signer.rb
Overview
:nodoc:
Defined Under Namespace
Modules: SAS
Instance Attribute Summary collapse
-
#account_name ⇒ Object
readonly
Returns the value of attribute account_name.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #authorization_header(uri:, verb:, headers: {}) ⇒ Object
-
#initialize(account_name:, host:, principal_id: nil) ⇒ EntraIdSigner
constructor
A new instance of EntraIdSigner.
- #sas_token(uri, options = {}) ⇒ Object
Constructor Details
#initialize(account_name:, host:, principal_id: nil) ⇒ EntraIdSigner
Returns a new instance of EntraIdSigner.
17 18 19 20 21 |
# File 'lib/azure_blob/entra_id_signer.rb', line 17 def initialize(account_name:, host:, principal_id: nil) @token = AzureBlob::IdentityToken.new(principal_id:) @account_name = account_name @host = host end |
Instance Attribute Details
#account_name ⇒ Object (readonly)
Returns the value of attribute account_name.
14 15 16 |
# File 'lib/azure_blob/entra_id_signer.rb', line 14 def account_name @account_name end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
15 16 17 |
# File 'lib/azure_blob/entra_id_signer.rb', line 15 def host @host end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
13 14 15 |
# File 'lib/azure_blob/entra_id_signer.rb', line 13 def token @token end |
Instance Method Details
#authorization_header(uri:, verb:, headers: {}) ⇒ Object
23 24 25 |
# File 'lib/azure_blob/entra_id_signer.rb', line 23 def (uri:, verb:, headers: {}) "Bearer #{token}" end |
#sas_token(uri, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/azure_blob/entra_id_signer.rb', line 27 def sas_token(uri, = {}) delegation_key.refresh to_sign = [ [:permissions], [:start], [:expiry], CanonicalizedResource.new(uri, account_name, url_safe: false, service_name: :blob), delegation_key.signed_oid, delegation_key.signed_tid, delegation_key.signed_start, delegation_key.signed_expiry, delegation_key.signed_service, delegation_key.signed_version, nil, nil, nil, [:ip], [:protocol], SAS::Version, SAS::Resources::Blob, nil, nil, nil, [:content_disposition], nil, nil, [:content_type], ].join("\n") query = { SAS::Fields::Permissions => [:permissions], SAS::Fields::Start => [:start], SAS::Fields::Expiry => [:expiry], SAS::Fields::SignedObjectId => delegation_key.signed_oid, SAS::Fields::SignedTenantId => delegation_key.signed_tid, SAS::Fields::SignedKeyStartTime => delegation_key.signed_start, SAS::Fields::SignedKeyExpiryTime => delegation_key.signed_expiry, SAS::Fields::SignedKeyService => delegation_key.signed_service, SAS::Fields::Signedkeyversion => delegation_key.signed_version, SAS::Fields::SignedIp => [:ip], SAS::Fields::SignedProtocol => [:protocol], SAS::Fields::Version => SAS::Version, SAS::Fields::Resource => SAS::Resources::Blob, SAS::Fields::Disposition => [:content_disposition], SAS::Fields::Type => [:content_type], SAS::Fields::Signature => sign(to_sign, key: delegation_key.to_s), }.reject { |_, value| value.nil? } URI.encode_www_form(**query) end |