Class: LogStash::Filters::Empow::CognitoClient
- Inherits:
-
Object
- Object
- LogStash::Filters::Empow::CognitoClient
- Includes:
- Util::Loggable
- Defined in:
- lib/logstash/filters/cognito-client.rb
Instance Method Summary collapse
- #authenticate ⇒ Object
-
#initialize(username, password, aws_region_name, aws_client_id) ⇒ CognitoClient
constructor
A new instance of CognitoClient.
Constructor Details
#initialize(username, password, aws_region_name, aws_client_id) ⇒ CognitoClient
Returns a new instance of CognitoClient.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/logstash/filters/cognito-client.rb', line 9 def initialize(username, password, aws_region_name, aws_client_id) @logger = self.logger @logger.debug("aws region: #{aws_region_name}") @logger.debug("aws aws_client_id: #{aws_client_id}") @logger.debug("cognito username: #{username}") @username = username @password = password @aws_region_name = aws_region_name @aws_client_id = aws_client_id Aws.config.update({ region: @aws_region_name, credentials: Aws::Credentials.new('aaaa', 'aaaa') }) @client = Aws::CognitoIdentityProvider::Client.new end |
Instance Method Details
#authenticate ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/logstash/filters/cognito-client.rb', line 29 def authenticate resp = @client.initiate_auth({ auth_flow: "USER_PASSWORD_AUTH", auth_parameters: { 'USERNAME': @username, 'PASSWORD': @password, }, client_id: @aws_client_id, }) id_token = resp.authentication_result.id_token token_type = resp.authentication_result.token_type token = token_type + " " + id_token return id_token end |