Class: Conjur::API::AzureAuthenticator
- Inherits:
-
Object
- Object
- Conjur::API::AzureAuthenticator
- Includes:
- TokenExpiration
- Defined in:
- lib/conjur/api/authn_azure.rb
Overview
Authenticator that uses an Azure Managed Identity JWT to obtain Conjur access tokens. Fetches a JWT from the Azure Instance Metadata Service (IMDS), then POSTs it to the Conjur authn-azure endpoint.
Constant Summary collapse
- IMDS_TOKEN_PATH =
'/metadata/identity/oauth2/token'.freeze
- DEFAULT_RESOURCE =
'https://management.azure.com/'.freeze
- DEFAULT_IMDS_BASE =
'http://169.254.169.254'.freeze
- DEFAULT_IMDS_VER =
'2018-02-01'.freeze
Constants included from TokenExpiration
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
-
#imds_api_version ⇒ Object
readonly
Returns the value of attribute imds_api_version.
-
#imds_base_url ⇒ Object
readonly
Returns the value of attribute imds_base_url.
-
#resource_uri ⇒ Object
readonly
Returns the value of attribute resource_uri.
-
#service_id ⇒ Object
readonly
Returns the value of attribute service_id.
Attributes included from TokenExpiration
Instance Method Summary collapse
-
#initialize(account, service_id, identity, resource_uri: DEFAULT_RESOURCE, client_id: nil, imds_base_url: DEFAULT_IMDS_BASE, imds_api_version: DEFAULT_IMDS_VER) ⇒ AzureAuthenticator
constructor
A new instance of AzureAuthenticator.
- #refresh_token ⇒ Object
Methods included from TokenExpiration
#gettime, #needs_token_refresh?, #token_age, #update_token_born
Constructor Details
#initialize(account, service_id, identity, resource_uri: DEFAULT_RESOURCE, client_id: nil, imds_base_url: DEFAULT_IMDS_BASE, imds_api_version: DEFAULT_IMDS_VER) ⇒ AzureAuthenticator
Returns a new instance of AzureAuthenticator.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/conjur/api/authn_azure.rb', line 24 def initialize(account, service_id, identity, resource_uri: DEFAULT_RESOURCE, client_id: nil, imds_base_url: DEFAULT_IMDS_BASE, imds_api_version: DEFAULT_IMDS_VER) @account = account @service_id = service_id @identity = identity @resource_uri = resource_uri @client_id = client_id @imds_base_url = imds_base_url @imds_api_version = imds_api_version update_token_born end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
21 22 23 |
# File 'lib/conjur/api/authn_azure.rb', line 21 def account @account end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
21 22 23 |
# File 'lib/conjur/api/authn_azure.rb', line 21 def client_id @client_id end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
21 22 23 |
# File 'lib/conjur/api/authn_azure.rb', line 21 def identity @identity end |
#imds_api_version ⇒ Object (readonly)
Returns the value of attribute imds_api_version.
21 22 23 |
# File 'lib/conjur/api/authn_azure.rb', line 21 def imds_api_version @imds_api_version end |
#imds_base_url ⇒ Object (readonly)
Returns the value of attribute imds_base_url.
21 22 23 |
# File 'lib/conjur/api/authn_azure.rb', line 21 def imds_base_url @imds_base_url end |
#resource_uri ⇒ Object (readonly)
Returns the value of attribute resource_uri.
21 22 23 |
# File 'lib/conjur/api/authn_azure.rb', line 21 def resource_uri @resource_uri end |
#service_id ⇒ Object (readonly)
Returns the value of attribute service_id.
21 22 23 |
# File 'lib/conjur/api/authn_azure.rb', line 21 def service_id @service_id end |
Instance Method Details
#refresh_token ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/conjur/api/authn_azure.rb', line 39 def refresh_token Conjur::API.authenticate_azure(service_id, identity, account: account, resource_uri: resource_uri, client_id: client_id, imds_base_url: imds_base_url, imds_api_version: imds_api_version).tap do update_token_born end end |