Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control-service: fix oauth secret name #3404

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ dependencies { // Implementation dependencies are found on compile classpath of
implementation 'org.springdoc:springdoc-openapi-ui:1.8.0'
implementation versions.'com.amazonaws:aws-java-sdk-ecr'
implementation 'org.springdoc:springdoc-openapi-core:1.1.49'
implementation versions.'io.fabric8:kubernetes-client-api'

// transitive dependencies version force
// on next upgrade, revise if those still need to be set explicitly
implementation versions.'org.apache.commons:commons-compress'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.vmware.taurus.service.credentials.webhook.CreateOAuthAppWebHookResult;
import com.vmware.taurus.service.kubernetes.DataJobsKubernetesService;
import com.vmware.taurus.service.webhook.WebHookResult;
import io.fabric8.kubernetes.client.utils.KubernetesResourceUtil;
import io.kubernetes.client.openapi.ApiException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -50,7 +51,7 @@ public class JobCredentialsService {
public static final String K8S_KEYTAB_KEY_IN_SECRET = "keytab";
public static final String K8S_TEAM_CLIENT_ID = "VDK_TEAM_CLIENT_ID";
public static final String K8S_TEAM_CLIENT_SECRET = "VDK_TEAM_CLIENT_SECRET";
public static final String OAUTH_CREDENTIALS = "-oauth-credentials";
public static final String OAUTH_CREDENTIALS = "team-oauth-";

// pattern for the name of the principal to be created - "%(data_job)" will be replaced with the
// job name
Expand Down Expand Up @@ -116,7 +117,7 @@ public void createJobCredentials(String jobName, String teamName) {
K8S_TEAM_CLIENT_SECRET,
Base64.getEncoder().encode(teamCredentials.getClientSecret().getBytes()));

String secretName = teamName + OAUTH_CREDENTIALS;
String secretName = getTeamOAuthSecretName(teamName);
try {
dataJobsKubernetesService.saveSecretData(secretName, secretData);
} catch (ApiException e) {
Expand All @@ -139,6 +140,10 @@ public void createJobCredentials(String jobName, String teamName) {
}
}

public static String getTeamOAuthSecretName(String teamName) {
return KubernetesResourceUtil.sanitizeName(OAUTH_CREDENTIALS + teamName);
}

/** Delete job's credentials. */
public void deleteJobCredentials(String jobName) {
Validate.notBlank(jobName, "jobName must not be blank");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ project.ext {
'com.amazonaws:aws-java-sdk-ecr' : 'com.amazonaws:aws-java-sdk-ecr:1.12.495',
'org.springframework.vault:spring-vault-core' : 'org.springframework.vault:spring-vault-core:2.3.3',
'com.icegreen.greenmail' : 'com.icegreen:greenmail:1.6.5',
'io.fabric8:kubernetes-client-api' : 'io.fabric8:kubernetes-client-api:6.13.1',


// transitive dependencies version force (freeze)
Expand Down
Loading