-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc83bee
commit 0870cd1
Showing
25 changed files
with
413 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.35.2 | ||
version=0.35.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...lin/io/airbyte/cdk/integrations/destination/s3/credential/S3AssumeRoleCredentialConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
package io.airbyte.cdk.integrations.destination.s3.credential | ||
|
||
import com.amazonaws.auth.* | ||
import com.amazonaws.regions.Regions | ||
import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient | ||
|
||
private const val AIRBYTE_STS_SESSION_NAME = "airbyte-sts-session" | ||
|
||
/** | ||
* The S3AssumeRoleCredentialConfig implementation of the S3CredentialConfig returns an | ||
* STSAssumeRoleSessionCredentialsProvider. The STSAssumeRoleSessionCredentialsProvider | ||
* automatically refreshes assumed role credentials on a background thread. | ||
* The roleArn comes from the spec and the externalId, which | ||
* is used to protect against confused deputy problems, and also is provided through the | ||
* orchestrator via an environment variable. As of 5/2024, the externalId is set to the workspaceId. | ||
* | ||
* @param roleArn The Amazon Resource Name (ARN) of the role to assume. | ||
*/ | ||
class S3AssumeRoleCredentialConfig(private val roleArn: String, environment: Map<String, String>) : | ||
S3CredentialConfig { | ||
private val externalId: String = environment.getValue("AWS_ASSUME_ROLE_EXTERNAL_ID") | ||
|
||
override val credentialType: S3CredentialType = S3CredentialType.ASSUME_ROLE | ||
|
||
/** | ||
* AWSCredentialsProvider implementation that uses the AWS Security Token Service to assume a | ||
* Role and create temporary, short-lived sessions to use for authentication. This credentials | ||
* provider uses a background thread to refresh credentials. This background thread can be shut | ||
* down via the close() method when the credentials provider is no longer used. | ||
*/ | ||
override val s3CredentialsProvider: AWSCredentialsProvider by lazy { | ||
STSAssumeRoleSessionCredentialsProvider.Builder(roleArn, AIRBYTE_STS_SESSION_NAME) | ||
.withExternalId(externalId) | ||
.withStsClient( | ||
AWSSecurityTokenServiceClient.builder() | ||
.withRegion(Regions.DEFAULT_REGION) | ||
.withCredentials( | ||
getCredentialProvider(environment) | ||
) | ||
.build() | ||
) | ||
.build() | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun getCredentialProvider(environment: Map<String, String>): AWSStaticCredentialsProvider { | ||
return AWSStaticCredentialsProvider(BasicAWSCredentials( | ||
environment.getValue("AWS_ACCESS_KEY_ID"), | ||
environment.getValue("AWS_SECRET_ACCESS_KEY") | ||
)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...src/test/kotlin/io/airbyte/cdk/integrations/destination/s3/credential/S3AssumeRoleTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.airbyte.cdk.integrations.destination.s3.credential | ||
|
||
import org.junit.jupiter.api.Test | ||
|
||
class S3AssumeRoleTest { | ||
@Test | ||
fun testFailsWithNoEnvCredentials() { | ||
|
||
} | ||
|
||
@Test | ||
fun testPassesWithAllCredentials() { | ||
|
||
} | ||
|
||
@Test | ||
fun testFailsWithWrongExternalId() { | ||
|
||
} | ||
|
||
|
||
fun testAutomaticRenewal() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.