Ross Coundon
04/20/2021, 9:08 PMconst authFunc = new Function(this, 'AuthorizerFunction', {
handler: 'src/main/handler/firebaseAuth.handler',
timeout: 30,
environment,
});
const authorizer = new RequestAuthorizer(this, 'Authorizer', {
handler: authFunc,
resultsCacheTtl: Duration.millis(0),
identitySources: [IdentitySource.header('Authorization')], // I think this should extract the token and add to the authorizationToken property of the event
});
const retrieveHandler = new Function(this, 'retrieveHandler', {
handler:
'src/main/handler/retrieveFeedbackHandler.handleRetrieveFeedback',
timeout: scope.local ? 30 : 5,
environment,
});
const api = new ApiGatewayV1Api(this, 'CustFeedbackApi', {
defaultAuthorizer: authorizer,
defaultAuthorizationType: AuthorizationType.CUSTOM,
cors: true,
routes: {
'GET /retrieve': {
function: retrieveHandler,
},
},
});
Is there something I’m missing in how to define the auth function or hook it up to the API?Frank
.build/cdk.out
with the one that’s generated in SLS?Frank
AWS::ApiGateway::Authorizer
resourceFrank
Ross Coundon
04/20/2021, 9:13 PMFrank
AWS::ApiGateway::Authorizer
looks identitcle?Ross Coundon
04/20/2021, 9:15 PMRoss Coundon
04/20/2021, 9:15 PMFrank
Ross Coundon
04/20/2021, 9:16 PMFrank
Ross Coundon
04/20/2021, 9:18 PM"FirebaseAuthApiGatewayAuthorizer": {
"Type": "AWS::ApiGateway::Authorizer",
"Properties": {
"AuthorizerResultTtlInSeconds": 0,
"IdentitySource": "method.request.header.Authorization",
"Name": "FirebaseAuth",
"RestApiId": {
"Ref": "ApiGatewayRestApi"
},
"AuthorizerUri": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":apigateway:",
{
"Ref": "AWS::Region"
},
":lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"FirebaseAuthLambdaFunction",
"Arn"
]
},
"/invocations"
]
]
},
"Type": "TOKEN"
}
},
SST
"AuthorizerBD825682": {
"Type": "AWS::ApiGateway::Authorizer",
"Properties": {
"RestApiId": {
"Ref": "CustFeedbackApi10B0E354"
},
"Type": "REQUEST",
"AuthorizerResultTtlInSeconds": 0,
"AuthorizerUri": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":apigateway:eu-west-2:lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"AuthorizerFunctionB4DBAA43",
"Arn"
]
},
"/invocations"
]
]
},
"IdentitySource": "method.request.header.Authorization",
"Name": "devcustomerfeedbacksstdevcustomerfeedbackstackAuthorizer1A04D2EE"
},
"Metadata": {
"aws:cdk:path": "dev-customer-feedback-sst-dev-customer-feedback-stack/Authorizer/Resource"
}
},
Ross Coundon
04/20/2021, 9:19 PMFrank
const authorizer = new RequestAuthorizer(this, 'Authorizer', {
handler: authFunc,
resultsCacheTtl: Duration.millis(0),
identitySources: [IdentitySource.header('Authorization')], // I think this should extract the token and add to the authorizationToken property of the event
});
to use the TokenAuthorizerFrank
Ross Coundon
04/20/2021, 9:22 PMFrank
ApiGatewayV1Api
construct isn’t doing a good job helping configure the authorizeors. If you got suggestions at any point, i’m all ears 🙂Ross Coundon
04/20/2021, 9:25 PM