Skip to content

Commit

Permalink
Added code to handle Cognito Credentials and return the identity id i…
Browse files Browse the repository at this point in the history
…nstead of the user ARN. This fixes issue #43
  • Loading branch information
sapessi committed Jul 5, 2017
1 parent 0e762c6 commit 237a7c7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ public Principal getUserPrincipal() {
if (getAuthenticationScheme().equals(AUTH_SCHEME_CUSTOM)) {
return event.getRequestContext().getAuthorizer().getPrincipalId();
} else if (getAuthenticationScheme().equals(AUTH_SCHEME_AWS_IAM)) {
return event.getRequestContext().getIdentity().getUserArn();
// if we received credentials from Cognito Federated Identities then we return the identity id
if (event.getRequestContext().getIdentity().getCognitoIdentityId() != null) {
return event.getRequestContext().getIdentity().getCognitoIdentityId();
} else { // otherwise the user arn from the credentials
return event.getRequestContext().getIdentity().getUserArn();
}
} else if (getAuthenticationScheme().equals(AUTH_SCHEME_COGNITO_POOL)) {
return event.getRequestContext().getAuthorizer().getClaims().getSubject();
}
Expand Down

0 comments on commit 237a7c7

Please sign in to comment.