Class: LogStash::Outputs::MicrosoftSentinelOutputInternal::LogAnalyticsAadTokenProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/sentinel_la/logAnalyticsAadTokenProvider.rb

Instance Method Summary collapse

Constructor Details

#initialize(logstashLoganalyticsConfiguration) ⇒ LogAnalyticsAadTokenProvider

Returns a new instance of LogAnalyticsAadTokenProvider.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/logstash/sentinel_la/logAnalyticsAadTokenProvider.rb', line 11

def initialize (logstashLoganalyticsConfiguration)
  scope = CGI.escape("#{logstashLoganalyticsConfiguration.get_monitor_endpoint}//.default")
  @aad_uri = logstashLoganalyticsConfiguration.get_aad_endpoint
  @token_request_body = sprintf("client_id=%s&scope=%s&client_secret=%s&grant_type=client_credentials", logstashLoganalyticsConfiguration.client_app_Id, scope, logstashLoganalyticsConfiguration.client_app_secret)
  @token_request_uri = sprintf("%s/%s/oauth2/v2.0/token",@aad_uri, logstashLoganalyticsConfiguration.tenant_id)
  @token_state = {
    :access_token => nil,
    :expiry_time => nil,
    :token_details_mutex => Mutex.new,
  }
  @logger = logstashLoganalyticsConfiguration.logger
  @logstashLoganalyticsConfiguration = logstashLoganalyticsConfiguration
end

Instance Method Details

#get_aad_token_bearerObject



28
29
30
31
32
33
34
35
# File 'lib/logstash/sentinel_la/logAnalyticsAadTokenProvider.rb', line 28

def get_aad_token_bearer()
  @token_state[:token_details_mutex].synchronize do
    if is_saved_token_need_refresh()
      refresh_saved_token()
    end
    return @token_state[:access_token]
  end
end