Skip to content

Commit 7e88fbd

Browse files
authored
chore: kickoff release
2 parents 76ba8f1 + 9a05bdd commit 7e88fbd

File tree

40 files changed

+1155
-694
lines changed

40 files changed

+1155
-694
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Dependency Review
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- v1
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
dependency-review:
14+
name: Dependency Review
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
19+
with:
20+
persist-credentials: false
21+
22+
- name: Dependency Review
23+
uses: actions/dependency-review-action@7d90b4f05fea31dde1c4a1fb3fa787e197ea93ab # v3.0.7
24+
with:
25+
config-file: aws-amplify/amplify-ci-support/.github/dependency-review-config.yml@main

.github/workflows/integ_test_datastore_auth_iam.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ on:
55

66
permissions:
77
id-token: write
8-
contents: read
8+
contents: read
99

1010
jobs:
1111
datastore-integration-auth-iam-test-iOS:
1212
timeout-minutes: 30
13-
runs-on: macos-12
13+
runs-on: macos-13
1414
environment: IntegrationTest
1515
steps:
1616
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
@@ -33,6 +33,8 @@ jobs:
3333
with:
3434
project_path: ./AmplifyPlugins/DataStore/Tests/DataStoreHostApp
3535
scheme: AWSDataStorePluginAuthIAMTests
36+
destination: 'platform=iOS Simulator,name=iPhone 14,OS=latest'
37+
xcode_path: '/Applications/Xcode_14.3.app'
3638

3739
datastore-integration-auth-iam-test-tvOS:
3840
timeout-minutes: 30

.github/workflows/integ_test_datastore_multi_auth.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010
jobs:
1111
datastore-integration-multi-auth-test-iOS:
1212
timeout-minutes: 30
13-
runs-on: macos-12
13+
runs-on: macos-13
1414
environment: IntegrationTest
1515
steps:
1616
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
@@ -33,6 +33,8 @@ jobs:
3333
with:
3434
project_path: ./AmplifyPlugins/DataStore/Tests/DataStoreHostApp
3535
scheme: AWSDataStorePluginMultiAuthTests
36+
destination: 'platform=iOS Simulator,name=iPhone 14,OS=latest'
37+
xcode_path: '/Applications/Xcode_14.3.app'
3638

3739
datastore-integration-multi-auth-test-tvOS:
3840
timeout-minutes: 30

AmplifyPlugins/API/Sources/AWSAPIPlugin/Configuration/AWSAPICategoryPluginConfiguration.swift

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public struct AWSAPICategoryPluginConfiguration {
7272
self.authService = authService
7373
}
7474

75-
/// Registers an interceptor for the provided API endpoint
75+
/// Registers an customer interceptor for the provided API endpoint
7676
/// - Parameter interceptor: operation interceptor used to decorate API requests
7777
/// - Parameter toEndpoint: API endpoint name
7878
mutating func addInterceptor(_ interceptor: URLRequestInterceptor,
@@ -86,20 +86,16 @@ public struct AWSAPICategoryPluginConfiguration {
8686

8787
/// Returns all the interceptors registered for `apiName` API endpoint
8888
/// - Parameter apiName: API endpoint name
89-
/// - Returns: request interceptors
90-
internal func interceptorsForEndpoint(named apiName: APIEndpointName) -> [URLRequestInterceptor] {
91-
guard let interceptorsConfig = interceptors[apiName] else {
92-
return []
93-
}
94-
return interceptorsConfig.interceptors
89+
/// - Returns: Optional AWSAPIEndpointInterceptors for the apiName
90+
internal func interceptorsForEndpoint(named apiName: APIEndpointName) -> AWSAPIEndpointInterceptors? {
91+
return interceptors[apiName]
9592
}
9693

97-
/// Returns interceptors for the provided endpointConfig
94+
/// Returns the interceptors for the provided endpointConfig
9895
/// - Parameters:
9996
/// - endpointConfig: endpoint configuration
100-
/// - Throws: PluginConfigurationError in case of failure building an instance of AWSAuthorizationConfiguration
101-
/// - Returns: An array of URLRequestInterceptor
102-
internal func interceptorsForEndpoint(withConfig endpointConfig: EndpointConfig) throws -> [URLRequestInterceptor] {
97+
/// - Returns: Optional AWSAPIEndpointInterceptors for the endpointConfig
98+
internal func interceptorsForEndpoint(withConfig endpointConfig: EndpointConfig) -> AWSAPIEndpointInterceptors? {
10399
return interceptorsForEndpoint(named: endpointConfig.name)
104100
}
105101

@@ -108,9 +104,11 @@ public struct AWSAPICategoryPluginConfiguration {
108104
/// - endpointConfig: endpoint configuration
109105
/// - authType: overrides the registered auth interceptor
110106
/// - Throws: PluginConfigurationError in case of failure building an instance of AWSAuthorizationConfiguration
111-
/// - Returns: An array of URLRequestInterceptor
112-
internal func interceptorsForEndpoint(withConfig endpointConfig: EndpointConfig,
113-
authType: AWSAuthorizationType) throws -> [URLRequestInterceptor] {
107+
/// - Returns: Optional AWSAPIEndpointInterceptors for the endpointConfig and authType
108+
internal func interceptorsForEndpoint(
109+
withConfig endpointConfig: EndpointConfig,
110+
authType: AWSAuthorizationType
111+
) throws -> AWSAPIEndpointInterceptors? {
114112

115113
guard let apiAuthProviderFactory = self.apiAuthProviderFactory else {
116114
return interceptorsForEndpoint(named: endpointConfig.name)
@@ -126,12 +124,10 @@ public struct AWSAPICategoryPluginConfiguration {
126124
authConfiguration: authConfiguration)
127125

128126
// retrieve current interceptors and replace auth interceptor
129-
let currentInterceptors = interceptorsForEndpoint(named: endpointConfig.name).filter {
130-
!isAuthInterceptor($0)
131-
}
132-
config.interceptors.append(contentsOf: currentInterceptors)
127+
let currentInterceptors = interceptorsForEndpoint(named: endpointConfig.name)
128+
config.interceptors.append(contentsOf: currentInterceptors?.interceptors ?? [])
133129

134-
return config.interceptors
130+
return config
135131
}
136132

137133
// MARK: Private

AmplifyPlugins/API/Sources/AWSAPIPlugin/Configuration/AWSAPIEndpointInterceptors.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,27 @@ import Amplify
99
import Foundation
1010
import AWSPluginsCore
1111

12+
/// The order of interceptor decoration is as follows:
13+
/// 1. **prelude interceptors**
14+
/// 2. **cutomize headers**
15+
/// 3. **customer interceptors**
16+
/// 4. **postlude interceptors**
17+
///
18+
/// **Prelude** and **postlude** interceptors are used by library maintainers to
19+
/// integrate essential functionality for a variety of authentication types.
1220
struct AWSAPIEndpointInterceptors {
1321
// API name
1422
let apiEndpointName: APIEndpointName
1523

1624
let apiAuthProviderFactory: APIAuthProviderFactory
1725
let authService: AWSAuthServiceBehavior?
1826

27+
var preludeInterceptors: [URLRequestInterceptor] = []
28+
1929
var interceptors: [URLRequestInterceptor] = []
2030

31+
var postludeInterceptors: [URLRequestInterceptor] = []
32+
2133
init(endpointName: APIEndpointName,
2234
apiAuthProviderFactory: APIAuthProviderFactory,
2335
authService: AWSAuthServiceBehavior? = nil) {
@@ -42,7 +54,7 @@ struct AWSAPIEndpointInterceptors {
4254
case .apiKey(let apiKeyConfig):
4355
let provider = BasicAPIKeyProvider(apiKey: apiKeyConfig.apiKey)
4456
let interceptor = APIKeyURLRequestInterceptor(apiKeyProvider: provider)
45-
addInterceptor(interceptor)
57+
preludeInterceptors.append(interceptor)
4658
case .awsIAM(let iamConfig):
4759
guard let authService = authService else {
4860
throw PluginError.pluginConfigurationError("AuthService is not set for IAM",
@@ -52,31 +64,31 @@ struct AWSAPIEndpointInterceptors {
5264
let interceptor = IAMURLRequestInterceptor(iamCredentialsProvider: provider,
5365
region: iamConfig.region,
5466
endpointType: endpointType)
55-
addInterceptor(interceptor)
67+
postludeInterceptors.append(interceptor)
5668
case .amazonCognitoUserPools:
5769
guard let authService = authService else {
5870
throw PluginError.pluginConfigurationError("AuthService not set for cognito user pools",
5971
"")
6072
}
6173
let provider = BasicUserPoolTokenProvider(authService: authService)
6274
let interceptor = AuthTokenURLRequestInterceptor(authTokenProvider: provider)
63-
addInterceptor(interceptor)
75+
preludeInterceptors.append(interceptor)
6476
case .openIDConnect:
6577
guard let oidcAuthProvider = apiAuthProviderFactory.oidcAuthProvider() else {
6678
throw PluginError.pluginConfigurationError("AuthService not set for OIDC",
6779
"Provide an AmplifyOIDCAuthProvider via API plugin configuration")
6880
}
6981
let wrappedAuthProvider = AuthTokenProviderWrapper(tokenAuthProvider: oidcAuthProvider)
7082
let interceptor = AuthTokenURLRequestInterceptor(authTokenProvider: wrappedAuthProvider)
71-
addInterceptor(interceptor)
83+
preludeInterceptors.append(interceptor)
7284
case .function:
7385
guard let functionAuthProvider = apiAuthProviderFactory.functionAuthProvider() else {
7486
throw PluginError.pluginConfigurationError("AuthService not set for function auth",
7587
"Provide an AmplifyFunctionAuthProvider via API plugin configuration")
7688
}
7789
let wrappedAuthProvider = AuthTokenProviderWrapper(tokenAuthProvider: functionAuthProvider)
7890
let interceptor = AuthTokenURLRequestInterceptor(authTokenProvider: wrappedAuthProvider)
79-
addInterceptor(interceptor)
91+
preludeInterceptors.append(interceptor)
8092
}
8193
}
8294
}

AmplifyPlugins/API/Sources/AWSAPIPlugin/Interceptor/RequestInterceptor/AuthTokenURLRequestInterceptor.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ struct AuthTokenURLRequestInterceptor: URLRequestInterceptor {
3232

3333
mutableRequest.setValue(amzDate,
3434
forHTTPHeaderField: URLRequestConstants.Header.xAmzDate)
35-
mutableRequest.setValue(URLRequestConstants.ContentType.applicationJson,
36-
forHTTPHeaderField: URLRequestConstants.Header.contentType)
37-
mutableRequest.setValue(userAgent,
35+
mutableRequest.addValue(userAgent,
3836
forHTTPHeaderField: URLRequestConstants.Header.userAgent)
3937

4038
let token: String

AmplifyPlugins/API/Sources/AWSAPIPlugin/Interceptor/RequestInterceptor/IAMURLRequestInterceptor.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct IAMURLRequestInterceptor: URLRequestInterceptor {
3636
throw APIError.unknown("Could not get host from mutable request", "")
3737
}
3838

39-
request.setValue(URLRequestConstants.ContentType.applicationJson, forHTTPHeaderField: URLRequestConstants.Header.contentType)
4039
request.setValue(host, forHTTPHeaderField: "host")
4140
request.setValue(userAgent, forHTTPHeaderField: URLRequestConstants.Header.userAgent)
4241

0 commit comments

Comments
 (0)