aws-sdk-bedrock 1.46.0 → 1.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws::Bedrock
4
+ module Plugins
5
+ # @api private
6
+ class BearerAuthorization < Seahorse::Client::Plugin
7
+ def after_initialize(client)
8
+ return unless (token = ENV['AWS_BEARER_TOKEN_BEDROCK'])
9
+
10
+ token_provider = Aws::StaticTokenProvider.new(token)
11
+ token_provider.metrics = ['BEARER_SERVICE_ENV_VARS']
12
+ client.config.token_provider ||= token_provider
13
+ end
14
+
15
+ class Handler < Seahorse::Client::Handler
16
+ def call(context)
17
+ # This also sets the preferred auth scheme even if the code token has precedence.
18
+ context[:auth_scheme] = { 'name' => 'bearer' } if ENV['AWS_BEARER_TOKEN_BEDROCK']
19
+ @handler.call(context)
20
+ end
21
+ end
22
+
23
+ # After endpoint/auth but before builders.
24
+ handle(Handler, priority: 60)
25
+ end
26
+ end
27
+ end