Karmo Rosental
06/01/2022, 11:54 PM{"message":"Unauthorized"}
before authorizer is even run. I can't see what I am doing differently from the official example.
authorizers: {
lambda: {
type: "lambda",
responseTypes: ["simple"],
function: new Function(stack, "Authorizer", {
handler: `functions/authorizer.main`,
}),
},
},
defaults: {
authorizer: "lambda",
},
If I try to access protected endpoint then nothing at all is printed to terminal like it is for public endpoint.
`functions/authorizer.ts`:
export const main = async (event) => {
console.log("Inside authorizer");
};
Where it can get blocked?outaTiME
06/02/2022, 12:34 AMttl
that the authorizer handles by default (which is 5 minutes), maybe you were doing some tests and it was saved in the cache, you can force it using resultsCacheTtl
in 0, for another side I remind you that it is always necessary for the authorizer to return some value for everything to work correctlyKarmo Rosental
06/02/2022, 10:18 AMresultsCacheTtl: "0 seconds",
and return this:
export const main = async (event) => {
console.log("Inside authorizer");
return {
isAuthorized: true,
context: {
username: "123",
},
};
};
Still nothing is printed out and it gives 401 Unauthorized.outaTiME
06/02/2022, 12:33 PMKarmo Rosental
06/02/2022, 7:28 PMoutaTiME
06/02/2022, 7:40 PMKarmo Rosental
06/02/2022, 9:33 PMconst api = new Api(stack, "Api", {
authorizers: {
lambda: {
type: "lambda",
responseTypes: ["simple"],
function: new Function(stack, "Authorizer", {
handler: `functions/authorizer.main`,
}),
},
},
defaults: {
authorizer: "lambda",
function: {
environment: {
DATABASE: SERVICE,
CLUSTER_ARN: rds.clusterArn,
SECRET_ARN: rds.secretArn,
},
permissions: [rds],
},
},
routes: {
"GET /one": "functions/one.main",
"GET /two": {
authorizer: "none",
function: "functions/two.main",
},
},
});
outaTiME
06/02/2022, 9:44 PMoutaTiME
06/02/2022, 9:48 PMmyAuthorizer
instead of lambda
Karmo Rosental
06/02/2022, 9:51 PMoutaTiME
06/02/2022, 9:52 PMoutaTiME
06/02/2022, 9:56 PMKarmo Rosental
06/02/2022, 9:57 PMoutaTiME
06/02/2022, 9:58 PMKarmo Rosental
06/02/2022, 10:09 PMFrank
Authorization
header, and then calls the Lambda authorizer.Frank
true
)Frank
Karmo Rosental
06/04/2022, 7:46 AM