Class RequestAuthorizer

  • All Implemented Interfaces:
    com.amazonaws.services.lambda.runtime.RequestHandler<com.amazonaws.services.lambda.runtime.events.APIGatewayCustomAuthorizerEvent,​AuthorizerResponse>
    Direct Known Subclasses:
    DefaultRequestAuthorizer

    public abstract class RequestAuthorizer
    extends java.lang.Object
    implements com.amazonaws.services.lambda.runtime.RequestHandler<com.amazonaws.services.lambda.runtime.events.APIGatewayCustomAuthorizerEvent,​AuthorizerResponse>
    Abstract class for implementing a Request Authorizer. Implementation is based on the AWS examples found in the following page : "https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer .html".
    • Constructor Detail

      • RequestAuthorizer

        protected RequestAuthorizer()
    • Method Detail

      • handleRequest

        public AuthorizerResponse handleRequest​(com.amazonaws.services.lambda.runtime.events.APIGatewayCustomAuthorizerEvent input,
                                                com.amazonaws.services.lambda.runtime.Context context)
        Specified by:
        handleRequest in interface com.amazonaws.services.lambda.runtime.RequestHandler<com.amazonaws.services.lambda.runtime.events.APIGatewayCustomAuthorizerEvent,​AuthorizerResponse>
      • formatPolicyResource

        protected java.lang.String formatPolicyResource​(java.lang.String methodArn)
        This method can be overridden to change the template of the accessed resource. The resource that access will be allowed to. It can contain wildcards.

        Example methodARN: arn:aws:execute-api:eu-west-1:884807050265:2lcqynkwke/Prod/GET/some/path/to/resource Example output: arn:aws:execute-api:eu-west-1:884807050265:2lcqynkwke/Prod\/*\/*

        Another possible output is: "*"

        Parameters:
        methodArn - the method ARN as provided by the API gateway
        Returns:
        a resource for the policy
      • createAllowAuthPolicy

        protected AuthPolicy createAllowAuthPolicy​(java.lang.String methodArn)
      • createDenyAuthPolicy

        protected AuthPolicy createDenyAuthPolicy()
      • principalId

        protected abstract java.lang.String principalId()
      • callerIsAllowedToPerformAction

        protected boolean callerIsAllowedToPerformAction​(com.amazonaws.services.lambda.runtime.events.APIGatewayCustomAuthorizerEvent requestInfo)
                                                  throws ForbiddenException
        Throws:
        ForbiddenException