-
Notifications
You must be signed in to change notification settings - Fork 136
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
Showing
23 changed files
with
1,068 additions
and
4 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
38 changes: 38 additions & 0 deletions
38
...rkus-common/src/main/java/org/projectnessie/quarkus/config/QuarkusSecretsCacheConfig.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,38 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.quarkus.config; | ||
|
||
import io.smallrye.config.WithDefault; | ||
import java.time.Duration; | ||
import java.util.OptionalLong; | ||
|
||
/** Configurations for secrets caching. */ | ||
public interface QuarkusSecretsCacheConfig { | ||
/** Flag whether the secrets cache is enabled. */ | ||
@WithDefault("true") | ||
boolean enabled(); | ||
|
||
/** Optionally restrict the number of cached secrets. */ | ||
OptionalLong maxElements(); | ||
|
||
/** Approximated maximum size on the Java heap for cached secrets. */ | ||
@WithDefault("16") | ||
long capacityMb(); | ||
|
||
/** Time until cached secrets expire. */ | ||
@WithDefault("PT15M") | ||
Duration ttl(); | ||
} |
38 changes: 38 additions & 0 deletions
38
...s/quarkus-common/src/main/java/org/projectnessie/quarkus/config/QuarkusSecretsConfig.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,38 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.quarkus.config; | ||
|
||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithDefault; | ||
|
||
@ConfigMapping(prefix = "nessie.secrets") | ||
public interface QuarkusSecretsConfig { | ||
/** Choose the secrets manager to use. */ | ||
@WithDefault("NONE") | ||
SecretsSupplierType type(); | ||
|
||
@WithDefault("nessie/secrets") | ||
String path(); | ||
|
||
QuarkusSecretsCacheConfig cache(); | ||
|
||
enum SecretsSupplierType { | ||
NONE, | ||
VAULT, | ||
GOOGLE, | ||
AMAZON | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...c/main/java/org/projectnessie/quarkus/providers/secrets/AmazonSecretsSupplierBuilder.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,34 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.quarkus.providers.secrets; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.inject.Inject; | ||
import org.projectnessie.catalog.secrets.aws.AwsSecretsSupplier; | ||
import org.projectnessie.catalog.secrets.spi.SecretsSupplier; | ||
import org.projectnessie.quarkus.config.QuarkusSecretsConfig.SecretsSupplierType; | ||
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; | ||
|
||
@Dependent | ||
@SecretsType(SecretsSupplierType.AMAZON) | ||
public class AmazonSecretsSupplierBuilder implements SecretsSupplierBuilder { | ||
@Inject SecretsManagerClient client; | ||
|
||
@Override | ||
public SecretsSupplier buildSupplier() { | ||
return new AwsSecretsSupplier(client); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...c/main/java/org/projectnessie/quarkus/providers/secrets/GoogleSecretsSupplierBuilder.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,35 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.quarkus.providers.secrets; | ||
|
||
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient; | ||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.inject.Inject; | ||
import org.projectnessie.catalog.secrets.gcs.GcsSecretsSupplier; | ||
import org.projectnessie.catalog.secrets.spi.SecretsSupplier; | ||
import org.projectnessie.quarkus.config.QuarkusSecretsConfig.SecretsSupplierType; | ||
|
||
@Dependent | ||
@SecretsType(SecretsSupplierType.GOOGLE) | ||
public class GoogleSecretsSupplierBuilder implements SecretsSupplierBuilder { | ||
|
||
@Inject SecretManagerServiceClient client; | ||
|
||
@Override | ||
public SecretsSupplier buildSupplier() { | ||
return new GcsSecretsSupplier(client); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...src/main/java/org/projectnessie/quarkus/providers/secrets/NoneSecretsSupplierBuilder.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,30 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.quarkus.providers.secrets; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import java.util.Map; | ||
import org.projectnessie.catalog.secrets.spi.SecretsSupplier; | ||
import org.projectnessie.quarkus.config.QuarkusSecretsConfig.SecretsSupplierType; | ||
|
||
@Dependent | ||
@SecretsType(SecretsSupplierType.NONE) | ||
public class NoneSecretsSupplierBuilder implements SecretsSupplierBuilder { | ||
@Override | ||
public SecretsSupplier buildSupplier() { | ||
return names -> Map.of(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...mon/src/main/java/org/projectnessie/quarkus/providers/secrets/SecretsSupplierBuilder.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,22 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.quarkus.providers.secrets; | ||
|
||
import org.projectnessie.catalog.secrets.spi.SecretsSupplier; | ||
|
||
public interface SecretsSupplierBuilder { | ||
SecretsSupplier buildSupplier(); | ||
} |
55 changes: 55 additions & 0 deletions
55
...quarkus-common/src/main/java/org/projectnessie/quarkus/providers/secrets/SecretsType.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,55 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.quarkus.providers.secrets; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import jakarta.enterprise.util.AnnotationLiteral; | ||
import jakarta.inject.Qualifier; | ||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import org.projectnessie.quarkus.config.QuarkusSecretsConfig.SecretsSupplierType; | ||
|
||
/** Store type qualifier for {@code VersionStoreFactory} classes. */ | ||
@Target({TYPE, METHOD, PARAMETER, FIELD}) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@Qualifier | ||
public @interface SecretsType { | ||
/** Gets the store type. */ | ||
SecretsSupplierType value(); | ||
|
||
/** Supports inline instantiation of the {@link SecretsType} qualifier. */ | ||
final class Literal extends AnnotationLiteral<SecretsType> implements SecretsType { | ||
|
||
private static final long serialVersionUID = 1L; | ||
private final SecretsSupplierType value; | ||
|
||
public Literal(SecretsSupplierType value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public SecretsSupplierType value() { | ||
return value; | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...rc/main/java/org/projectnessie/quarkus/providers/secrets/VaultSecretsSupplierBuilder.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,37 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.quarkus.providers.secrets; | ||
|
||
import io.quarkus.vault.VaultKVSecretReactiveEngine; | ||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.inject.Inject; | ||
import org.projectnessie.catalog.secrets.spi.SecretsSupplier; | ||
import org.projectnessie.catalog.secrets.vault.VaultSecretsSupplier; | ||
import org.projectnessie.quarkus.config.QuarkusSecretsConfig; | ||
import org.projectnessie.quarkus.config.QuarkusSecretsConfig.SecretsSupplierType; | ||
|
||
@Dependent | ||
@SecretsType(SecretsSupplierType.VAULT) | ||
public class VaultSecretsSupplierBuilder implements SecretsSupplierBuilder { | ||
@Inject VaultKVSecretReactiveEngine engine; | ||
|
||
@Inject QuarkusSecretsConfig secretsConfig; | ||
|
||
@Override | ||
public SecretsSupplier buildSupplier() { | ||
return new VaultSecretsSupplier(engine, secretsConfig.path() + "/"); | ||
} | ||
} |
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.