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
-
#generate_auth_token(options) ⇒ String
(also: #auth_token)
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
#generate_auth_token(options) ⇒ String Also known as: auth_token
Creates an auth login token.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/aws-sdk-rds/customizations/auth_token_generator.rb', line 32 def generate_auth_token() region = .fetch(:region) endpoint = .fetch(:endpoint) user_name = .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: [:expires_in] ).to_s # Remove extra scheme for token presigned_url[8..-1] end |