Neil Balcombe
05/24/2022, 1:59 PMAshishkumar Pandey
05/24/2022, 2:28 PMAshishkumar Pandey
05/24/2022, 2:30 PMNeil Balcombe
05/24/2022, 2:38 PMAshishkumar Pandey
05/24/2022, 2:42 PMNeil Balcombe
05/24/2022, 2:49 PMAshishkumar Pandey
05/24/2022, 2:50 PMNeil Balcombe
05/24/2022, 5:48 PMAshishkumar Pandey
05/24/2022, 7:32 PMNeil Balcombe
05/24/2022, 7:49 PMFrank
manitej
05/25/2022, 3:28 PMAshishkumar Pandey
05/25/2022, 3:30 PMNeil Balcombe
05/25/2022, 8:31 PM// Create Api
const api = new Api(stack, 'Api', {
authorizers: {
jwt: {
type: 'jwt',
cdk: {
authorizer: new apigAuthorizers.HttpJwtAuthorizer('Authorizer', '<https://dev-8rchfy1d.us.auth0.com/>', {
jwtAudience: ['ExWTATqlrVZXReAEv7JMjUkQmZWAXDlB'],
}),
},
},
},
defaults: {
authorizer: 'jwt',
},
routes: {
'GET /private': 'functions/private.handler',
'GET /public': {
function: 'functions/public.handler',
authorizer: 'none',
},
},
});
Ashishkumar Pandey
05/25/2022, 8:55 PMjwtAudience
should be <https://aw6lgqy70i.execute-api.us-east-1.amazonaws.com>
and not ExWTATqlrVZXReAEv7JMjUkQmZWAXDlB
. Change that it should work.Ashishkumar Pandey
05/25/2022, 8:57 PM<https://aw6lgqy70i.execute-api.us-east-1.amazonaws.com>
as the unique identifier? If yes, keep in mind that this endpoint is ephemeral in nature, if you tear down the stack and recreate it this endpoint will be different.Neil Balcombe
05/25/2022, 9:03 PMNeil Balcombe
05/25/2022, 9:04 PMAshishkumar Pandey
05/26/2022, 12:39 AM<https://some-amazing-api-audience.somedomain.sometld>
and it will still work. It’s just that this identifier needs to be available to your authorizers as well, you should also consider separating the user and admin APIs into different audiences that way your admin APIs get protected automatically from hijack attempts from normal users. provide the issuer and audiences to your APIs via env variables. Also, if you’re separating your dev and prod environments as you should across multiple stages, separate them in auth0 at the tenant level, so have a tenant for your dev stage and another for your production stage. Hope that helps!Neil Balcombe
05/26/2022, 8:24 AMAshishkumar Pandey
05/26/2022, 8:29 AMmanitej
05/26/2022, 8:30 AMmanitej
05/26/2022, 8:30 AMAshishkumar Pandey
05/26/2022, 8:31 AMmanitej
05/26/2022, 8:31 AMmanitej
05/26/2022, 8:31 AMapi = new Api(stack, "Api", {
authorizers: {
auth0: {
type: "jwt",
cdk: {
authorizer: new apigAuthorizers.HttpJwtAuthorizer(
"Authorizer",
"<https://dev-0abky2gm.us.auth0.com>",
{
jwtAudience: ["private"],
}
),
},
},
},
Neil Balcombe
05/26/2022, 8:32 AMAshishkumar Pandey
05/26/2022, 8:33 AM<https://dev-0abky2gm.us.auth0.com/>
whereas the authorizer shows <https://dev-0abky2gm.us.auth0.com>
.Neil Balcombe
05/26/2022, 8:35 AMmanitej
05/26/2022, 8:36 AMAshishkumar Pandey
05/26/2022, 8:36 AMmanitej
05/26/2022, 8:41 AMmanitej
05/26/2022, 8:58 AMauthorizers: {
auth0: {
type: "jwt",
jwt: {
issuer: "....",
audience: ["...."],
},
},
},
manitej
05/26/2022, 8:59 AMAshishkumar Pandey
05/26/2022, 9:16 AM