Slawomir Stec
08/25/2021, 4:27 AMconst api = new sst.Api(this, "Api", {
// defaultAuthorizationType: ApiAuthorizationType.CUSTOM,
defaultAuthorizer: new HttpLambdaAuthorizer({
authorizerName: "LambdaAuthorizer",
handler: new sst.Function(this, "Authorizer", {
handler: "src/authorizer.handler"
}),
}),
routes: {
"GET /private": {
authorizationType: ApiAuthorizationType.CUSTOM,
handler: "src/private.handler"
},
"GET /authenticate/facebook": "src/auth-facebook.handler"
}
[8:27 AM] I checked 0.40.1 and latest 0.40.2 -> in both cases produced Cloudformation template contains
[8:27 AM] AuthorizationType: NONE
[8:28 AM] I can set defaultAuthorizationType to CUSTOM, however this apply for all routes and can’t be overwritten with authorizationType for specific routesSam Hulick
08/25/2021, 4:34 AM'GET /embeds/{embedId}': {
function: 'get-embed.main',
authorizationType: sst.ApiAuthorizationType.NONE,
},
Slawomir Stec
08/25/2021, 4:39 AMSlawomir Stec
08/25/2021, 4:40 AMSam Hulick
08/25/2021, 5:23 AMSam Hulick
08/25/2021, 5:24 AMconst api = new sst.Api(this, 'RestAPI', {
defaultAuthorizationType: sst.ApiAuthorizationType.JWT,
defaultAuthorizer: new HttpUserPoolAuthorizer({
userPool: props.cognitoAuth.cognitoUserPool!,
userPoolClient: props.cognitoAuth.cognitoUserPoolClient!,
}),
so all my API routes require JWT auth. but I can override with NONE
in specific routesSlawomir Stec
08/25/2021, 5:32 AMSlawomir Stec
08/25/2021, 5:32 AMSlawomir Stec
08/25/2021, 5:34 AMSam Hulick
08/25/2021, 6:00 AMSam Hulick
08/25/2021, 6:00 AMSlawomir Stec
08/25/2021, 6:37 AMFrank
"GET /private": {
authorizationType: ApiAuthorizationType.CUSTOM,
handler: "src/private.handler"
},
This is valid
"GET /private": {
authorizationType: ApiAuthorizationType.CUSTOM,
function: "src/private.handler"
},
This is also valid
"GET /private": {
authorizationType: ApiAuthorizationType.CUSTOM,
function: {
handler: "src/private.handler"
}
},
Slawomir Stec
08/25/2021, 7:27 AMFrank
Sean Matheson
01/25/2022, 9:02 AMfunction
vs handler
. I need to do some more reading on the difference here.