AWS CDK user pool authorizer

前端 未结 7 1423
滥情空心
滥情空心 2021-02-12 23:31

I\'m trying to create an API gateway using the AWS-CDK and protect the REST endpoints with a Cognito user pool authorizer.

I cannot find any examples how one would do th

7条回答
  •  旧时难觅i
    2021-02-13 00:01

    I figured out what looks like a mechanism... I was able to get it to work like this:

    var auth = new apigw.cloudformation.AuthorizerResource(this, 'myAuthorizer', {
        restApiId: api.restApiId,
        authorizerName: 'mypoolauth',
        authorizerResultTtlInSeconds: 300,
        identitySource: 'method.request.header.Authorization',
        providerArns: [ 'arn:aws:cognito-idp:us-west-2:redacted:userpool/redacted' ],
        type: "COGNITO_USER_POOLS"
    });
    
    tmethod.addMethod('GET', getSessionIntegration, {
        authorizationType: apigw.AuthorizationType.Cognito,
        authorizerId : auth.authorizerId
    });
    

    Now to figure out how to enable CORS headers on API Gateway...

提交回复
热议问题