Skip to content

Commit c39145d

Browse files
committed
feat: encrypt the ECR auth token by default
1 parent c5fd916 commit c39145d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/main/java/io/kestra/plugin/aws/ecr/GetAuthToken.java

+15
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import io.kestra.core.models.annotations.Example;
44
import io.kestra.core.models.annotations.Plugin;
5+
import io.kestra.core.models.annotations.PluginProperty;
56
import io.kestra.core.models.tasks.Output;
67
import io.kestra.core.models.tasks.RunnableTask;
78
import io.kestra.core.runners.RunContext;
89
import io.kestra.plugin.aws.AbstractConnection;
910
import io.swagger.v3.oas.annotations.media.Schema;
11+
import jakarta.validation.constraints.NotNull;
1012
import lombok.*;
1113
import lombok.experimental.SuperBuilder;
1214
import software.amazon.awssdk.regions.Region;
@@ -40,6 +42,15 @@
4042
)
4143
public class GetAuthToken extends AbstractConnection implements RunnableTask<GetAuthToken.TokenOutput> {
4244

45+
@PluginProperty
46+
@Schema(
47+
title = "Whether to encrypt the authorization token into the output.",
48+
description = "If set to true, it can be decrypted via the Pebble `decrypt()` function."
49+
)
50+
@Builder.Default
51+
@NotNull
52+
private Boolean encrypt = false;
53+
4354
@Override
4455
public TokenOutput run(RunContext runContext) throws Exception {
4556
EcrClientBuilder ecrClientBuilder = EcrClient.builder().credentialsProvider(this.credentials(runContext));
@@ -63,6 +74,10 @@ public TokenOutput run(RunContext runContext) throws Exception {
6374
token = token.substring(token.indexOf(":") + 1);
6475
}
6576

77+
if (Boolean.TRUE.equals(encrypt)) {
78+
token = runContext.encrypt(token);
79+
}
80+
6681
return TokenOutput.builder()
6782
.token(token)
6883
.build();

src/test/java/io/kestra/plugin/aws/ecr/GetAuthTokenTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void run() throws Exception {
3131
.accessKeyId(localstack.getAccessKey())
3232
.secretKeyId(localstack.getSecretKey())
3333
.region(localstack.getRegion())
34+
.encrypt(false)
3435
.build();
3536

3637
GetAuthToken.TokenOutput output = query.run(runContext);

0 commit comments

Comments
 (0)