Skip to content

Commit edb98a3

Browse files
author
Matt Muller
committed
WIP: rework of credentials
1 parent 8d0ea6b commit edb98a3

30 files changed

Lines changed: 354 additions & 338 deletions

gems/smithy-client/lib/smithy-client.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050

5151
# identity and auth
5252

53-
require_relative 'smithy-client/identity'
5453
require_relative 'smithy-client/identity_provider'
5554
require_relative 'smithy-client/refreshing_identity_provider'
5655

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
module Smithy
4+
module Client
5+
# Identity class for API Key authentication.
6+
class ApiKey
7+
def initialize(options = {})
8+
@key = options[:key]
9+
end
10+
11+
# @return [String, nil]
12+
attr_reader :key
13+
14+
# @return [Boolean]
15+
def set?
16+
@key && !@key.empty?
17+
end
18+
19+
# @api private
20+
def inspect
21+
super.gsub(/@key="(\\"|[^"])*"/, '@key=[FILTERED]')
22+
end
23+
end
24+
end
25+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
module Smithy
4+
module Client
5+
# Provides an API key for authentication.
6+
class ApiKeyProvider
7+
include IdentityProvider
8+
include RefreshingIdentityProvider
9+
10+
# @param [Hash] options
11+
# @option options [String, nil] :key
12+
# @option options [Time, nil] :expiration
13+
def initialize(options = {})
14+
@key = options[:key]
15+
@expiration = options[:expiration]
16+
super
17+
end
18+
19+
private
20+
21+
def refresh
22+
@identity = ApiKey.new(key: @key)
23+
end
24+
end
25+
end
26+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
module Smithy
4+
module Client
5+
# Identity class for Bearer token authentication.
6+
class BearerToken
7+
def initialize(options = {})
8+
@token = options[:token]
9+
end
10+
11+
# @return [String, nil]
12+
attr_reader :token
13+
14+
# @return [Boolean]
15+
def set?
16+
@token && !@token.empty?
17+
end
18+
19+
# @api private
20+
def inspect
21+
super.gsub(/@token="(\\"|[^"])*"/, '@token=[FILTERED]')
22+
end
23+
end
24+
end
25+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
module Smithy
4+
module Client
5+
# Provides a Bearer token for authentication.
6+
class BearerTokenProvider
7+
include IdentityProvider
8+
include RefreshingIdentityProvider
9+
10+
# @param [Hash] options
11+
# @option options [String] :token
12+
# @option options [Time, nil] :expiration
13+
def initialize(options = {})
14+
@token = options[:token]
15+
@expiration = options[:expiration]
16+
super
17+
end
18+
19+
private
20+
21+
def refresh
22+
@identity = BearerToken.new(token: @token)
23+
end
24+
end
25+
end
26+
end

gems/smithy-client/lib/smithy-client/http_api_key_provider.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

gems/smithy-client/lib/smithy-client/http_bearer_provider.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

gems/smithy-client/lib/smithy-client/http_login_provider.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

gems/smithy-client/lib/smithy-client/identities/api_key.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.

gems/smithy-client/lib/smithy-client/identities/http_login.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)