This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new admin endpoint for getting kms key metadata (#166)
- Loading branch information
Showing
11 changed files
with
219 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,6 @@ | |
# limitations under the License. | ||
# | ||
|
||
version=3.16.2 | ||
version=3.17.0 | ||
groupId=com.nike.cerberus | ||
artifactId=cms |
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
67 changes: 67 additions & 0 deletions
67
src/main/java/com/nike/cerberus/domain/AuthKmsKeyMetadata.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,67 @@ | ||
package com.nike.cerberus.domain; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
public class AuthKmsKeyMetadata { | ||
|
||
private String awsIamRoleArn; | ||
private String awsKmsKeyId; | ||
private String awsRegion; | ||
private OffsetDateTime createdTs; | ||
private OffsetDateTime lastUpdatedTs; | ||
private OffsetDateTime lastValidatedTs; | ||
|
||
public String getAwsIamRoleArn() { | ||
return awsIamRoleArn; | ||
} | ||
|
||
public AuthKmsKeyMetadata setAwsIamRoleArn(String awsIamRoleArn) { | ||
this.awsIamRoleArn = awsIamRoleArn; | ||
return this; | ||
} | ||
|
||
public String getAwsKmsKeyId() { | ||
return awsKmsKeyId; | ||
} | ||
|
||
public AuthKmsKeyMetadata setAwsKmsKeyId(String awsKmsKeyId) { | ||
this.awsKmsKeyId = awsKmsKeyId; | ||
return this; | ||
} | ||
|
||
public String getAwsRegion() { | ||
return awsRegion; | ||
} | ||
|
||
public AuthKmsKeyMetadata setAwsRegion(String awsRegion) { | ||
this.awsRegion = awsRegion; | ||
return this; | ||
} | ||
|
||
public OffsetDateTime getCreatedTs() { | ||
return createdTs; | ||
} | ||
|
||
public AuthKmsKeyMetadata setCreatedTs(OffsetDateTime createdTs) { | ||
this.createdTs = createdTs; | ||
return this; | ||
} | ||
|
||
public OffsetDateTime getLastUpdatedTs() { | ||
return lastUpdatedTs; | ||
} | ||
|
||
public AuthKmsKeyMetadata setLastUpdatedTs(OffsetDateTime lastUpdatedTs) { | ||
this.lastUpdatedTs = lastUpdatedTs; | ||
return this; | ||
} | ||
|
||
public OffsetDateTime getLastValidatedTs() { | ||
return lastValidatedTs; | ||
} | ||
|
||
public AuthKmsKeyMetadata setLastValidatedTs(OffsetDateTime lastValidatedTs) { | ||
this.lastValidatedTs = lastValidatedTs; | ||
return this; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/nike/cerberus/domain/AuthKmsKeyMetadataResult.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 @@ | ||
package com.nike.cerberus.domain; | ||
|
||
import java.util.List; | ||
|
||
public class AuthKmsKeyMetadataResult { | ||
private List<AuthKmsKeyMetadata> authenticationKmsKeyMetadata; | ||
|
||
public AuthKmsKeyMetadataResult() { | ||
} | ||
|
||
public AuthKmsKeyMetadataResult(List<AuthKmsKeyMetadata> authenticationKmsKeyMetadata) { | ||
this.authenticationKmsKeyMetadata = authenticationKmsKeyMetadata; | ||
} | ||
|
||
public List<AuthKmsKeyMetadata> getAuthenticationKmsKeyMetadata() { | ||
return authenticationKmsKeyMetadata; | ||
} | ||
|
||
public void setAuthenticationKmsKeyMetadata(List<AuthKmsKeyMetadata> authenticationKmsKeyMetadata) { | ||
this.authenticationKmsKeyMetadata = authenticationKmsKeyMetadata; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/com/nike/cerberus/endpoints/admin/GetAuthKmsKeyMetadata.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,53 @@ | ||
package com.nike.cerberus.endpoints.admin; | ||
|
||
import com.nike.cerberus.domain.AuthKmsKeyMetadataResult; | ||
import com.nike.cerberus.endpoints.AdminStandardEndpoint; | ||
import com.nike.cerberus.service.KmsService; | ||
import com.nike.riposte.server.http.RequestInfo; | ||
import com.nike.riposte.server.http.ResponseInfo; | ||
import com.nike.riposte.server.http.impl.FullResponseInfo; | ||
import com.nike.riposte.util.AsyncNettyHelper; | ||
import com.nike.riposte.util.Matcher; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.http.HttpMethod; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.core.SecurityContext; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.Executor; | ||
|
||
/** | ||
* Endpoint for retrieving kms key metadata for all created keys in the db | ||
*/ | ||
public class GetAuthKmsKeyMetadata extends AdminStandardEndpoint<Void, AuthKmsKeyMetadataResult> { | ||
|
||
private final KmsService kmsService; | ||
|
||
@Inject | ||
public GetAuthKmsKeyMetadata(KmsService kmsService) { | ||
this.kmsService = kmsService; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<ResponseInfo<AuthKmsKeyMetadataResult>> doExecute(RequestInfo<Void> request, | ||
Executor longRunningTaskExecutor, | ||
ChannelHandlerContext ctx, | ||
SecurityContext securityContext) { | ||
|
||
return CompletableFuture.supplyAsync( | ||
AsyncNettyHelper.supplierWithTracingAndMdc(() -> getAuthKmsKeyMetadata(request), ctx), | ||
longRunningTaskExecutor | ||
); | ||
} | ||
|
||
private FullResponseInfo<AuthKmsKeyMetadataResult> getAuthKmsKeyMetadata(RequestInfo<Void> request) { | ||
return ResponseInfo.newBuilder(new AuthKmsKeyMetadataResult( | ||
kmsService.getAuthenticationKmsMetadata() | ||
)).build(); | ||
} | ||
|
||
@Override | ||
public Matcher requestMatcher() { | ||
return Matcher.match("/v1/admin/authentication-kms-metadata", HttpMethod.GET); | ||
} | ||
} |
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