Sam
01/20/2022, 3:00 AMauth.attachPermissionsForUnauthUsers([api])
allow unauthenticated users access to my api? Api endpoints returns {"message":"Forbidden"}
if I am unauthenticated. Am I missing something?
Thanks!Sam
01/20/2022, 3:04 AMconst policy = new iam.Policy(this, "AuthPolicy", {
statements: [
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ["execute-api:Invoke"],
resources: [`arn:aws:execute-api:${scope.region}:${scope.account}:${api.httpApiId}/*`]
})
],
});
policy.attachToRole(this.auth.iamUnauthRole)
Daniel Gato
01/20/2022, 9:09 AMauthorizationType
on your route.
I removed the default auth type from the API and add it individually on the routes:
'GET /unprotected': {
function: 'src/test.main',
},
'GET /protected': {
authorizationType: ApiAuthorizationType.AWS_IAM,
function: 'src/test.main',
},
Sam
01/20/2022, 11:41 AMDaniel Gato
01/20/2022, 12:38 PMDaniel Gato
01/20/2022, 12:39 PMauthorizationType
defines how your route is protected (the route itself)
• attachPermissionsForUnauthUsers
defines the resources an unauth user could accessSam
01/20/2022, 1:15 PMDevin
01/20/2022, 1:22 PM"POST /beta-signup": {
authorizationType: sst.ApiAuthorizationType.NONE,
function: "src/betaSignUp.main"
},
Devin
01/20/2022, 1:22 PMSam
01/20/2022, 1:32 PMsst.ApiAuthorizationType.NONE
because I want to check in the function whether the user is authenticated or not.Devin
01/20/2022, 1:54 PMFrank
auth.attachPermissionsForUnauthUsers([api])
will allow non-authed users to access the Api, both NONE and IAM authorized routes.Frank
Sam
01/21/2022, 1:02 PMFrank
x-amzn-errortype
response header and see if any of the following tips help? https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-troubleshoot-403-forbidden/Frank
Sam
01/24/2022, 9:12 AMFrank