New authorizers created for each new api route
jaduplessis opened this issue · comments
× Failed
ApiRouteKoeseuAuthorizerBszbxo aws:apigatewayv2:Authorizer
StatusCode: 429, RequestID: f3048aa1-31b4-405f-bb6c-49c8b4519b41, ConflictException: Maximum number of Authorizers for this API has been reached. Please contact AWS if you need additional Authorizers.
Each new api route creates a new Authorizer instead of using an existing one.
api.route(
'GET /user/me',
{
handler: './api/user/handler.get',
},
{
auth: {
jwt: {
audiences: [client.id],
issuer: $interpolate`https://cognito-idp.${aws.getRegionOutput().name}.amazonaws.com/${pool.id}`,
},
},
};
);
This error is not found on older versions of Ion. I believe the issue was introduced in PR-471 in an attempt to make multiple authorizers for different apis
Hmm we'll take a look.
Fixed in v0.0.433
Authorizers now need to be created explicitly, ie.
const myAuthorizer = api.addAuthorizer({
name: "myAuthorizer",
jwt: {
issuer: "https://issuer.com/",
audiences: ["https://api.example.com"],
identitySource: "$request.header.AccessToken"
}
});
And set it on the route:
api.route("GET /", "src/get.handler", {
auth: {
jwt: {
authorizer: myAuthorizer.id,
}
}
});
Here's the doc - https://ion.sst.dev/docs/component/aws/apigatewayv2/#addauthorizer