Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
docs: closes #1104
Browse files Browse the repository at this point in the history
  • Loading branch information
jayair committed Sep 23, 2024
1 parent 49f6c05 commit 51cd27c
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions platform/src/components/aws/apigatewayv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1218,11 +1218,22 @@ export class ApiGatewayV2 extends Component implements Link.Linkable {
*
* @param args Configure the authorizer.
* @example
* Add a JWT authorizer.
* Add a Lambda authorizer.
*
* ```js title="sst.config.ts"
* api.addAuthorizer({
* name: "myAuthorizer",
* lambda: {
* function: "src/authorizer.index"
* }
* });
* ```
*
* Add a JWT authorizer.
*
* ```js title="sst.config.ts"
* const authorizer = api.addAuthorizer({
* name: "myAuthorizer",
* jwt: {
* issuer: "https://issuer.com/",
* audiences: ["https://api.example.com"],
Expand All @@ -1231,13 +1242,29 @@ export class ApiGatewayV2 extends Component implements Link.Linkable {
* });
* ```
*
* Add a Lambda authorizer.
* Add a Cognito UserPool as a JWT authorizer.
*
* ```js title="sst.config.ts"
* api.addAuthorizer({
* name: "myAuthorizer",
* lambda: {
* function: "src/authorizer.index"
* const pool = new sst.aws.CognitoUserPool("MyUserPool");
* const poolClient = userPool.addClient("Web");
*
* const authorizer = api.addAuthorizer({
* name: "myCognitoAuthorizer",
* jwt: {
* issuer: $interpolate`https://cognito-idp.${aws.getRegionOutput().name}.amazonaws.com/${pool.id}`,
* audiences: [poolClient.id]
* }
* });
* ```
*
* Now you can use the authorizer in your routes.
*
* ```js title="sst.config.ts"
* api.route("GET /", "src/get.handler", {
* auth: {
* jwt: {
* authorizer: authorizer.id
* }
* }
* });
* ```
Expand Down

0 comments on commit 51cd27c

Please sign in to comment.