io.quarkus.amazon.lambda.http.CognitoPrincipal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-amazon-lambda-http Show documentation
Show all versions of quarkus-amazon-lambda-http Show documentation
Allow applications written for a servlet container to run in AWS Lambda
package io.quarkus.amazon.lambda.http;
import java.security.Principal;
import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent;
/**
* Represents a Cognito JWT used to authenticate request
*
* Will only be allocated if requestContext.authorizer.jwt.claims.cognito:username is set
* in the http event sent by API Gateway
*/
public class CognitoPrincipal implements Principal {
private APIGatewayV2HTTPEvent.RequestContext.Authorizer.JWT jwt;
private String name;
public CognitoPrincipal(APIGatewayV2HTTPEvent.RequestContext.Authorizer.JWT jwt) {
this.jwt = jwt;
this.name = jwt.getClaims().get("cognito:username");
}
@Override
public String getName() {
return name;
}
public APIGatewayV2HTTPEvent.RequestContext.Authorizer.JWT getClaims() {
return jwt;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy