awslambda

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package awslambda provides an adapter that bridges protosource's provider-agnostic handlers to AWS API Gateway Lambda proxy integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth0Extractor

func Auth0Extractor(request events.APIGatewayProxyRequest) string

Auth0Extractor extracts the actor from an Auth0 JWT authorizer. Auth0 uses the standard "sub" claim in the JWT, which API Gateway passes through the authorizer context.

func CognitoExtractor

func CognitoExtractor(request events.APIGatewayProxyRequest) string

CognitoExtractor extracts the actor from a Cognito User Pool JWT authorizer. It reads the "sub" claim from the authorizer context.

func CustomAuthExtractor

func CustomAuthExtractor(request events.APIGatewayProxyRequest) string

CustomAuthExtractor extracts the actor from a custom/Lambda authorizer. It reads the "principalId" field from the authorizer context.

func IAMExtractor

func IAMExtractor(request events.APIGatewayProxyRequest) string

IAMExtractor extracts the actor from IAM authorization. It returns the caller's ARN from the request identity.

func OktaExtractor

func OktaExtractor(request events.APIGatewayProxyRequest) string

OktaExtractor extracts the actor from an Okta JWT authorizer. Okta uses the "uid" claim for the user identifier.

func Wrap

Wrap is a convenience function that returns the Handle method directly, suitable for passing to lambda.Start().

func WrapRouter

WrapRouter returns a Lambda handler that dispatches to the router based on the request's HTTP method and path. Suitable for passing to lambda.Start().

Types

type ActorExtractor

type ActorExtractor func(events.APIGatewayProxyRequest) string

ActorExtractor extracts the actor identity from an API Gateway request. Return an empty string if no identity can be determined.

func Chain

func Chain(extractors ...ActorExtractor) ActorExtractor

Chain returns an ActorExtractor that tries each extractor in order, returning the first non-empty result. This is useful when your API supports multiple authentication methods (e.g., Cognito for end users, IAM for service-to-service calls).

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter wraps a protosource.HandlerFunc with AWS API Gateway conversion and actor extraction.

func New

func New(handler protosource.HandlerFunc, extractor ActorExtractor) *Adapter

New creates an Adapter that converts API Gateway requests to protosource requests, extracts the actor using the provided extractor, and converts the protosource response back to an API Gateway response.

func (*Adapter) Handle

Handle is the Lambda entry point. Pass this to lambda.Start().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL