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.15.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d93b4c4214d1eea5d9e02107bd0284f9134304e1bd2e1bc0ccc30821aa6b00a1 |
|
MD5 | e674ccfefaa3110b10c345466b3ac73a |
|
BLAKE2b-256 | 5661a8492e9677e90fdcba97e5b5f8d333e1020ba66835cde1142cca6a0a68b0 |
Close
Hashes for cloudy_with_a_chance_of_meatballs.cdk_lambda_token_authorizer_jwt-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ac1239e00c79eacd77c728824a123a0caf838e99f53569cf471995ce22bcb63 |
|
MD5 | 5f3bbfa822f30f9650a53d8433e6e9d8 |
|
BLAKE2b-256 | d91d62b48f28d8f20a6c4d94906ee761586e67c503782fefd83643744616f31d |