Skip to content

Commit

Permalink
ID-1278 Remove SSH Key Pair Functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tlangs committed May 15, 2024
1 parent 200e3ca commit 184d16d
Show file tree
Hide file tree
Showing 17 changed files with 11 additions and 1,549 deletions.
64 changes: 0 additions & 64 deletions common/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,70 +304,6 @@ paths:
description: "Version not configured"
'500':
$ref: '#/components/responses/ServerError'
/api/sshkeypair/v1/{type}:
parameters:
- $ref: '#/components/parameters/sshKeyPairTypeParam'
get:
parameters:
- $ref: '#/components/parameters/includePrivateKey'
summary: Get the ssh key pair of the given provider.
tags: [ ssh key pair ]
operationId: getSshKeyPair
responses:
'200':
$ref: '#/components/responses/SshKeyPairResponse'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/ServerError'
put:
summary: Store an ssh key pair to the given provider.
tags: [ ssh key pair ]
operationId: putSshKeyPair
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SshKeyPair'
responses:
'200':
$ref: '#/components/responses/SshKeyPairResponse'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/ServerError'
post:
parameters:
- $ref: '#/components/parameters/includePrivateKey'
summary: Generates a pair of ssh keys
tags: [ ssh key pair ]
operationId: generateSshKeyPair
requestBody:
required: true
content:
application/json:
schema:
type: string
example: foo@gmail.com
description: User email associated with the ssh key pair
responses:
'200':
$ref: '#/components/responses/SshKeyPairResponse'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/ServerError'
delete:
summary: delete the ssh key pair of the given provider
tags: [ ssh key pair ]
operationId: deleteSshKeyPair
responses:
'204':
description: Deletes the ssh key pair.
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/ServerError'
components:
parameters:
sshKeyPairTypeParam:
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package bio.terra.externalcreds;

import bio.terra.common.logging.LoggingInitializer;
import bio.terra.common.logging.LoggingUtils;
import bio.terra.externalcreds.services.PassportProviderService;
import bio.terra.externalcreds.services.SshKeyPairService;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringBootConfiguration;
Expand Down Expand Up @@ -35,12 +33,9 @@ public static void main(String[] args) {
}

private final PassportProviderService passportProviderService;
private final SshKeyPairService sshKeyPairService;

public ExternalCredsCronApplication(
PassportProviderService passportProviderService, SshKeyPairService sshKeyPairService) {
public ExternalCredsCronApplication(PassportProviderService passportProviderService) {
this.passportProviderService = passportProviderService;
this.sshKeyPairService = sshKeyPairService;
}

@Scheduled(fixedRateString = "#{${externalcreds.background-job-interval-mins} * 60 * 1000}")
Expand All @@ -57,18 +52,4 @@ public void checkForExpiringCredentials() {
var checkedPassportCount = passportProviderService.validateAccessTokenVisas();
log.info("completed validateVisas", Map.of("checked_passport_count", checkedPassportCount));
}

@Scheduled(fixedRateString = "#{${externalcreds.background-job-interval-mins} * 60 * 1000}")
public void checkForExpiringSshKeyPair() {
log.info("Beginning checkForExpiringSshKeyPair");
try {
sshKeyPairService.reEncryptExpiringSshKeyPairs();
} catch (Exception e) {
LoggingUtils.logAlert(
log,
"Unexpected error during checkForExpiringSshKeyPair execution, see stacktrace below");
log.error("checkForExpiringSshKeyPair failed, stacktrace: ", e);
}
log.info("Completed checkForExpiringSshKeyPair");
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package bio.terra.externalcreds;

import bio.terra.externalcreds.config.ExternalCredsConfig;
import bio.terra.externalcreds.models.StringToSshKeyPairTypeConverter;
import javax.sql.DataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.jdbc.support.JdbcTransactionManager;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableScheduling;
Expand Down Expand Up @@ -45,11 +43,6 @@ public ExternalCredsConfig getExternalCredsSpringConfig() {
return ExternalCredsConfig.create();
}

@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new StringToSshKeyPairTypeConverter());
}

@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
import bio.terra.externalcreds.generated.model.OneOfValidatePassportRequestCriteriaItems;
import bio.terra.externalcreds.generated.model.OneOfValidatePassportResultMatchedCriterion;
import bio.terra.externalcreds.generated.model.RASv1Dot1VisaCriterion;
import bio.terra.externalcreds.generated.model.SshKeyPair;
import bio.terra.externalcreds.generated.model.ValidatePassportResult;
import bio.terra.externalcreds.models.LinkedAccount;
import bio.terra.externalcreds.models.SshKeyPairInternal;
import bio.terra.externalcreds.models.ValidatePassportResultInternal;
import bio.terra.externalcreds.visaComparators.RASv1Dot1VisaCriterionInternal;
import bio.terra.externalcreds.visaComparators.VisaCriterionInternal;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -74,16 +71,5 @@ public static LinkInfo convert(LinkedAccount linkedAccount) {
.expirationTimestamp(linkedAccount.getExpires())
.authenticated(linkedAccount.isAuthenticated());
}

public static SshKeyPair convert(
SshKeyPairInternal sshKeyPairInternal, boolean includePrivateKey) {
return new SshKeyPair()
.externalUserEmail(sshKeyPairInternal.getExternalUserEmail())
.publicKey(sshKeyPairInternal.getPublicKey())
.privateKey(
includePrivateKey
? new String(sshKeyPairInternal.getPrivateKey(), StandardCharsets.UTF_8)
: null);
}
}
}

This file was deleted.

Loading

0 comments on commit 184d16d

Please sign in to comment.