cdk-lambda-token-authorizer-jwt
Project description
CDK Lambda TokenAuthorizer JWT
Add a lambda function to your project which can be used as a apigateway token authorizer
Install
TypeScript
npm install @cloudy-with-a-chance-of-meatballs/cdk-lambda-token-authorizer-jwt
yarn add @cloudy-with-a-chance-of-meatballs/cdk-lambda-token-authorizer-jwt
Python
pip install cloudy-with-a-chance-of-meatballs.cdk-lambda-token-authorizer-jwt
Usage
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
//### EXAMPLE: import the function
import { TokenAuthorizerJwtFunction } from "@cloudy-with-a-chance-of-meatballs/cdk-lambda-token-authorizer-jwt";
//### END
export class HelloworldStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const api = new apigateway.RestApi(this, 'ApiName', {});
//### EXAMPLE: init the function
const tokenAuthFunction = new TokenAuthorizerJwtFunction(this, 'lambdaFunctionName', {
environment: {
// PROVIDE VARIABLES
TOKEN_AUTHORIZER_JWKS_URI: 'https://example.auth0.com/.well-known/jwks.json',
TOKEN_AUTHORIZER_JWKS_KID: 'SOME_KID_FROM_JWKS_RESPONSE',
// OR
TOKEN_AUTHORIZER_JWT_VERIFICATION_SECRET: 'A_PUBLIC_KEY_OR_SYMETRIC_SECRET'
}
});
//### END
const tokenAuthorizer = new apigateway.TokenAuthorizer(this, 'tokenAuthorizerName', {
//### EXAMPLE: use as handler
handler: tokenAuthFunction
//### END
});
// ...
const someMethod = SOMEAPIRESOURCE.addMethod("GET", SOMETARGETINTEGRATION, { authorizer: tokenAuthorizer });
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for cloudy-with-a-chance-of-meatballs.cdk-lambda-token-authorizer-jwt-0.0.18.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b4a07830291dbe21a032b8218437e46c04581ac3a6f0b07779fb587dee14fa7 |
|
MD5 | 54349ede5a3ed8e1172df398ed45b1d9 |
|
BLAKE2b-256 | 71821850a5b3e39880ab41c1efb239380f9fe03bddfc6a40e5627f3398e75f03 |
Close
Hashes for cloudy_with_a_chance_of_meatballs.cdk_lambda_token_authorizer_jwt-0.0.18-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99f2e9a4b2b3d0c6da326113872e5b5dd4650b9c89161959ef1a5549ec9bdb2a |
|
MD5 | 72b8b963f9b2ca3aaae4c9292f210480 |
|
BLAKE2b-256 | 8d79b06919fd16f97f1c0fa3d127d7bfda9b9c211028888c42acbb24abfd9f42 |