Skip to content

Commit fcae2a1

Browse files
sichanyooSichan Yoojbelkins
authored
feat: Credential feature IDs (#945)
* Add Attributes propertybag to identity objects. * Update unit test. --------- Co-authored-by: Sichan Yoo <[email protected]> Co-authored-by: Josh Elkins <[email protected]>
1 parent 5912145 commit fcae2a1

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

Sources/SmithyIdentity/AWSCredentialIdentity.swift

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

88
import protocol SmithyIdentityAPI.Identity
99
import struct Foundation.Date
10+
import struct Smithy.Attributes
1011

1112
/// A type representing AWS credentials for authenticating with an AWS service
1213
///
@@ -17,6 +18,7 @@ public struct AWSCredentialIdentity: Identity {
1718
public let accountID: String?
1819
public let sessionToken: String?
1920
public let expiration: Date?
21+
public let properties: Attributes
2022

2123
/// Creates AWS credentials with the specified keys and optionally an expiration and session token.
2224
///
@@ -26,17 +28,20 @@ public struct AWSCredentialIdentity: Identity {
2628
/// - accountID: The account ID for the credentials, if known. Defaults to `nil`.
2729
/// - expiration: The date when the credentials will expire and no longer be valid. If value is `nil` then the credentials never expire. Defaults to `nil`
2830
/// - sessionToken: A session token for this session. Defaults to `nil`
31+
/// - properties: Arbitrary grab-bag of properties related to this credentials object.
2932
public init(
3033
accessKey: String,
3134
secret: String,
3235
accountID: String? = nil,
3336
expiration: Date? = nil,
34-
sessionToken: String? = nil
37+
sessionToken: String? = nil,
38+
properties: Attributes = Attributes()
3539
) {
3640
self.accessKey = accessKey
3741
self.secret = secret
3842
self.accountID = accountID
3943
self.expiration = expiration
4044
self.sessionToken = sessionToken
45+
self.properties = properties
4146
}
4247
}

Sources/SmithyIdentity/BearerTokenIdentity.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77

88
import protocol SmithyIdentityAPI.Identity
99
import struct Foundation.Date
10+
import struct Smithy.Attributes
1011

1112
/// The type representing bearer token identity, used in HTTP bearer auth.
1213
public struct BearerTokenIdentity: Identity {
1314
public let token: String
1415
public let expiration: Date?
16+
public let properties: Attributes
1517

16-
public init(token: String, expiration: Date? = nil) {
18+
public init(token: String, expiration: Date? = nil, properties: Attributes = Attributes()) {
1719
self.token = token
1820
self.expiration = expiration
21+
self.properties = properties
1922
}
2023
}

Sources/SmithyIdentityAPI/Identity.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
//
77

88
import struct Foundation.Date
9+
import struct Smithy.Attributes
910

1011
// Base protocol for all identity types
1112
public protocol Identity: Sendable {
1213
var expiration: Date? { get }
14+
var properties: Attributes { get }
1315
}

Sources/SmithyTestUtil/RequestTestUtil/AuthTestUtil/MockIdentity.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import SmithyIdentityAPI
1111
import ClientRuntime
1212

1313
public struct MockIdentity: Identity {
14-
public init() {}
14+
public var properties: Smithy.Attributes
15+
16+
public init() { self.properties = Attributes() }
1517
public var expiration: Date? = nil
1618
}
1719

0 commit comments

Comments
 (0)