-
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
8f03443
commit 4666776
Showing
9 changed files
with
168 additions
and
44 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
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
117 changes: 117 additions & 0 deletions
117
airbyte-server/src/main/java/io/airbyte/server/config/SecretPersistenceBeanFactory.java
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,117 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.config; | ||
|
||
import io.airbyte.commons.temporal.config.WorkerMode; | ||
import io.airbyte.config.persistence.split_secrets.GoogleSecretManagerPersistence; | ||
import io.airbyte.config.persistence.split_secrets.LocalTestingSecretPersistence; | ||
import io.airbyte.config.persistence.split_secrets.RealSecretsHydrator; | ||
import io.airbyte.config.persistence.split_secrets.SecretPersistence; | ||
import io.airbyte.config.persistence.split_secrets.SecretsHydrator; | ||
import io.airbyte.config.persistence.split_secrets.VaultSecretPersistence; | ||
import io.airbyte.db.Database; | ||
import io.micronaut.context.annotation.Factory; | ||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.context.annotation.Value; | ||
import jakarta.inject.Named; | ||
import jakarta.inject.Singleton; | ||
|
||
/** | ||
* Micronaut bean factory for secret persistence-related singletons. | ||
*/ | ||
@Factory | ||
@SuppressWarnings("PMD.AvoidDuplicateLiterals") | ||
public class SecretPersistenceBeanFactory { | ||
|
||
@Singleton | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^(?!testing_config_db_table).*") | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^(?!google_secret_manager).*") | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^(?!vault).*") | ||
@Requires(env = WorkerMode.CONTROL_PLANE) | ||
@Named("longLivedSecretPersistence") | ||
public SecretPersistence defaultSecretPersistence(@Named("configDatabase") final Database configDatabase) { | ||
return localTestingSecretPersistence(configDatabase); | ||
} | ||
|
||
@Singleton | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^testing_config_db_table$") | ||
@Requires(env = WorkerMode.CONTROL_PLANE) | ||
@Named("longLivedSecretPersistence") | ||
public SecretPersistence localTestingSecretPersistence(@Named("configDatabase") final Database configDatabase) { | ||
return new LocalTestingSecretPersistence(configDatabase); | ||
} | ||
|
||
@Singleton | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^google_secret_manager$") | ||
@Named("longLivedSecretPersistence") | ||
public SecretPersistence googleSecretPersistence(@Value("${airbyte.secret.store.gcp.credentials}") final String credentials, | ||
@Value("${airbyte.secret.store.gcp.project-id}") final String projectId) { | ||
return GoogleSecretManagerPersistence.getLongLived(projectId, credentials); | ||
} | ||
|
||
@Singleton | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^vault$") | ||
@Requires(env = WorkerMode.CONTROL_PLANE) | ||
@Named("longLivedSecretPersistence") | ||
public SecretPersistence vaultSecretPersistence(@Value("${airbyte.secret.store.vault.address}") final String address, | ||
@Value("${airbyte.secret.store.vault.prefix}") final String prefix, | ||
@Value("${airbyte.secret.store.vault.token}") final String token) { | ||
return new VaultSecretPersistence(address, prefix, token); | ||
} | ||
|
||
@Singleton | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^(?!testing_config_db_table).*") | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^(?!google_secret_manager).*") | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^(?!vault).*") | ||
@Requires(env = WorkerMode.CONTROL_PLANE) | ||
@Named("ephemeralSecretPersistence") | ||
public SecretPersistence defaultEphemeralSecretPersistence(@Named("configDatabase") final Database configDatabase) { | ||
return localTestingSecretPersistence(configDatabase); | ||
} | ||
|
||
@Singleton | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^testing_config_db_table$") | ||
@Requires(env = WorkerMode.CONTROL_PLANE) | ||
@Named("ephemeralSecretPersistence") | ||
public SecretPersistence localTestingEphemeralSecretPersistence(@Named("configDatabase") final Database configDatabase) { | ||
return new LocalTestingSecretPersistence(configDatabase); | ||
} | ||
|
||
@Singleton | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^google_secret_manager$") | ||
@Named("ephemeralSecretPersistence") | ||
public SecretPersistence googleEphemeralSecretPersistence(@Value("${airbyte.secret.store.gcp.credentials}") final String credentials, | ||
@Value("${airbyte.secret.store.gcp.project-id}") final String projectId) { | ||
return GoogleSecretManagerPersistence.getEphemeral(projectId, credentials); | ||
} | ||
|
||
@Singleton | ||
@Requires(property = "airbyte.secret.persistence", | ||
pattern = "(?i)^vault$") | ||
@Requires(env = WorkerMode.CONTROL_PLANE) | ||
@Named("ephemeralSecretPersistence") | ||
public SecretPersistence vaultEphemeralSecretPersistence(@Value("${airbyte.secret.store.vault.address}") final String address, | ||
@Value("${airbyte.secret.store.vault.prefix}") final String prefix, | ||
@Value("${airbyte.secret.store.vault.token}") final String token) { | ||
return new VaultSecretPersistence(address, prefix, token); | ||
} | ||
|
||
@Singleton | ||
public SecretsHydrator secretsHydrator(@Named("longLivedSecretPersistence") final SecretPersistence secretPersistence) { | ||
return new RealSecretsHydrator(secretPersistence); | ||
} | ||
|
||
} |
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