use of com.nike.cerberus.aws.sts.AwsStsHttpHeader in project cerberus by Nike-Inc.
the class AwsIamStsAuthController method authenticate.
@RequestMapping(method = POST)
public AuthTokenResponse authenticate(@RequestHeader(value = HEADER_X_AMZ_DATE, required = false) String headerXAmzDate, @RequestHeader(value = HEADER_X_AMZ_SECURITY_TOKEN, required = false) String headerXAmzSecurityToken, @RequestHeader(value = HEADER_AUTHORIZATION, required = false) String headerAuthorization) {
String iamPrincipalArn;
AuthTokenResponse authResponse;
try {
if (headerAuthorization == null || headerXAmzDate == null) {
throw new ApiException(DefaultApiError.MISSING_AWS_SIGNATURE_HEADERS);
}
AwsStsHttpHeader header = new AwsStsHttpHeader(headerXAmzDate, headerXAmzSecurityToken, headerAuthorization);
GetCallerIdentityResponse getCallerIdentityResponse = awsStsClient.getCallerIdentity(header);
iamPrincipalArn = getCallerIdentityResponse.getGetCallerIdentityResult().getArn();
authResponse = authenticationService.stsAuthenticate(iamPrincipalArn);
auditLoggingFilterDetails.setAction("Successfully authenticated with AWS IAM STS Auth");
} catch (Exception e) {
String auditMessage = String.format("Failed to authenticate with AWS IAM STS Auth: %s", e.getMessage());
auditLoggingFilterDetails.setAction(auditMessage);
throw e;
}
return authResponse;
}
Aggregations