Class: Aws::RDS::AuthTokenGenerator
- Inherits:
-
Object
- Object
- Aws::RDS::AuthTokenGenerator
- Defined in:
- lib/aws-sdk-rds/customizations/auth_token_generator.rb
Overview
A utility class that generates an auth token that supports database logins. IAM credentials are used for authentication instead of the database password.
Instance Method Summary collapse
-
#auth_token(params) ⇒ String
Creates an auth login token.
-
#initialize(options = {}) ⇒ AuthTokenGenerator
constructor
A new instance of AuthTokenGenerator.
Constructor Details
#initialize(options = {}) ⇒ AuthTokenGenerator
Returns a new instance of AuthTokenGenerator.
16 17 18 |
# File 'lib/aws-sdk-rds/customizations/auth_token_generator.rb', line 16 def initialize( = {}) @credentials = .fetch(:credentials) end |
Instance Method Details
#auth_token(params) ⇒ String
Creates an auth login token.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/aws-sdk-rds/customizations/auth_token_generator.rb', line 31 def auth_token(params) region = params.fetch(:region) endpoint = params.fetch(:endpoint) user_name = params.fetch(:user_name) param_list = Aws::Query::ParamList.new param_list.set('Action', 'connect') param_list.set('DBUser', user_name) signer = Aws::Sigv4::Signer.new( service: 'rds-db', region: region, credentials_provider: @credentials ) presigned_url = signer.presign_url( http_method: 'GET', url: "https://#{endpoint}/?#{param_list}", body: '', expires_in: 900 ).to_s # Remove extra scheme for token presigned_url[8..-1] end |