Class: Fluent::Plugin::AzureLogsIngestion::Auth
- Inherits:
-
Object
- Object
- Fluent::Plugin::AzureLogsIngestion::Auth
- Defined in:
- lib/fluent/plugin/azure_logs_ingestion/auth.rb
Defined Under Namespace
Classes: Token
Constant Summary collapse
- IMDS_API_VERSION =
'2018-02-01'- APP_SERVICE_API_VERSION =
'2019-08-01'- IMDS_ENDPOINT =
'http://169.254.169.254/metadata/identity/oauth2/token'
Instance Method Summary collapse
-
#initialize(use_msi:, tenant_id:, client_id:, client_secret:, authority_host:, logs_ingestion_scope:, token_refresh_skew:, logger:) ⇒ Auth
constructor
A new instance of Auth.
- #token ⇒ Object
Constructor Details
#initialize(use_msi:, tenant_id:, client_id:, client_secret:, authority_host:, logs_ingestion_scope:, token_refresh_skew:, logger:) ⇒ Auth
Returns a new instance of Auth.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fluent/plugin/azure_logs_ingestion/auth.rb', line 19 def initialize(use_msi:, tenant_id:, client_id:, client_secret:, authority_host:, logs_ingestion_scope:, token_refresh_skew:, logger:) @use_msi = use_msi @tenant_id = tenant_id @client_id = client_id @client_secret = client_secret @authority_host = @logs_ingestion_scope = logs_ingestion_scope @token_refresh_skew = token_refresh_skew @log = logger @token = nil @mutex = Mutex.new end |
Instance Method Details
#token ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/azure_logs_ingestion/auth.rb', line 32 def token @mutex.synchronize do if token_valid?(@token) @log.debug('reusing cached access token', expires_at: @token.expires_at.utc.iso8601) return @token.value end @token = @use_msi ? fetch_msi_token : fetch_service_principal_token @log.debug('fetched new access token', mode: @use_msi ? 'managed_identity' : 'service_principal', expires_at: @token.expires_at.utc.iso8601) @token.value end end |