Skip to content

Commit eecf3ec

Browse files
authored
chore(swift): add AWSTemporaryCredentials callout (#6685)
1 parent d3e0ba3 commit eecf3ec

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

docs/src/pages/[platform]/connected-components/liveness/quick-start-pull.swift.mdx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,76 @@ When initially configuring Amplify (assuming you are using no pieces of Amplify
9393
9494
By default, FaceLivenessDetector uses Amplify Auth to authorize users to perform the Face Liveness check. You can use your own credentials provider to retrieve credentials from [Amazon Cognito](https://aws.amazon.com/cognito/) or assume a role with [Amazon STS](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html), for example:
9595
96+
For long lived credentials, you may retrieve `AWSCredentials` by implementing your custom `AWSCredentialsProvider`.
97+
98+
```swift
99+
/**
100+
Represents AWS credentials.
101+
102+
Typically refers to long-term credentials that do not expire unless manually rotated or deactivated.
103+
These credentials are generally associated with an IAM (Identity and Access Management) user and are used to authenticate API requests to AWS services.
104+
105+
- Properties:
106+
- accessKeyId: A unique identifier.
107+
- secretAccessKey: A secret key used to sign requests cryptographically.
108+
*/
109+
110+
public protocol AWSCredentials {
111+
112+
/// A unique identifier.
113+
var accessKeyId: String { get }
114+
115+
/// A secret key used to sign requests cryptographically.
116+
var secretAccessKey: String { get }
117+
}
118+
```
96119
97120
```swift
98121
import Amplify
99122
100123
struct MyCredentialsProvider: AWSCredentialsProvider {
101124
func fetchAWSCredentials() async throws -> AWSCredentials {
102-
// Fetch the credentials
125+
// Return `AWSCredentials` object instance
103126
}
104127
}
105128
```
106129
130+
If you're providing temporary credentials, make sure that your `AWSCredentials` object conforms to `AWSTemporaryCredentials`, which must include `sessionToken`.
131+
132+
```swift
133+
/**
134+
Represents temporary AWS credentials.
135+
136+
Refers to short-term credentials generated by AWS STS (Security Token Service).
137+
These credentials are used for temporary access, often for applications, temporary roles, federated users, or scenarios requiring limited-time access.
138+
139+
- Inherits: AWSCredentials
140+
141+
- Properties:
142+
- sessionToken: A token that is required when using temporary security credentials to sign requests.
143+
- expiration: The expiration date and time of the temporary credentials.
144+
*/
145+
public protocol AWSTemporaryCredentials: AWSCredentials {
146+
147+
/// A token that is required when using temporary security credentials to sign requests.
148+
var sessionToken: String { get }
149+
150+
/// The expiration date and time of the temporary credentials.
151+
var expiration: Date { get }
152+
}
153+
```
154+
155+
```swift
156+
import Amplify
157+
158+
struct MyCredentialsProvider: AWSCredentialsProvider {
159+
func fetchAWSCredentials() async throws -> AWSCredentials {
160+
// Return `AWSTemporaryCredentials` object instance
161+
}
162+
}
163+
```
164+
165+
107166
```swift
108167
import SwiftUI
109168
import FaceLiveness

0 commit comments

Comments
 (0)