Skip to content

Commit 7e1fe31

Browse files
committed
further improvement to docs for user-pool
1 parent 736ad53 commit 7e1fe31

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

types/stacktape-config/user-pools.d.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,23 +701,108 @@ type StpUserAuthPool = UserAuthPool['properties'] & {
701701
};
702702

703703
interface CognitoAuthorizerProperties {
704+
/**
705+
* #### Name of the user pool to protect the API
706+
*
707+
* ---
708+
*
709+
* The Stacktape name of the `user-auth-pool` resource whose tokens should be accepted by this HTTP API authorizer.
710+
* Stacktape uses this to:
711+
*
712+
* - Set the expected **audience** to the user pool client ID.
713+
* - Build the expected **issuer** URL based on the user pool and AWS region.
714+
*
715+
* In practice this means only JWTs issued by this pool (and its client) will be considered valid.
716+
*/
704717
userPoolName: string;
718+
/**
719+
* #### Where to read the JWT from in the request
720+
*
721+
* ---
722+
*
723+
* A list of identity sources that tell API Gateway where to look for the bearer token, using the
724+
* `$request.*` syntax from API Gateway (for example `'$request.header.Authorization'`).
725+
*
726+
* If you omit this, Stacktape defaults to reading the token from the `Authorization` HTTP header,
727+
* using a JWT authorizer as described in the API Gateway v2 authorizer docs
728+
* ([AWS::ApiGatewayV2::Authorizer](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigatewayv2-authorizer)).
729+
*/
705730
identitySources?: string[];
706731
}
707732

708733
interface CognitoAuthorizer {
734+
/**
735+
* #### Cognito JWT authorizer
736+
*
737+
* ---
738+
*
739+
* Configures an HTTP API authorizer that validates JSON Web Tokens (JWTs) issued by a Cognito user pool.
740+
* This is the simplest way to protect routes when your users sign in via `user-auth-pool`.
741+
*
742+
* Stacktape turns this into an API Gateway v2 authorizer of type `JWT` that checks the token's issuer and audience.
743+
*/
709744
type: 'cognito';
710745
properties: CognitoAuthorizerProperties;
711746
}
712747

713748
interface LambdaAuthorizerProperties {
749+
/**
750+
* #### Name of the authorizer function
751+
*
752+
* ---
753+
*
754+
* The Stacktape name of a `function` resource that should run for each authorized request.
755+
* API Gateway calls this Lambda, passes request details, and uses its response to allow or deny access.
756+
*/
714757
functionName: string;
758+
/**
759+
* #### Use IAM-style (v1) authorizer responses
760+
*
761+
* ---
762+
*
763+
* - If `true`, your Lambda must return a full IAM policy document (the "v1" format).
764+
* - If `false` or omitted, Stacktape enables **simple responses** (the HTTP API v2 payload format)
765+
* so your Lambda can return a small JSON object with an `isAuthorized` flag and optional context.
766+
*
767+
* This flag is wired to `EnableSimpleResponses` on the underlying `AWS::ApiGatewayV2::Authorizer`.
768+
*/
715769
iamResponse?: boolean;
770+
/**
771+
* #### Where to read identity data from
772+
*
773+
* ---
774+
*
775+
* A list of request fields API Gateway should pass into your Lambda authorizer (for example headers, query parameters,
776+
* or stage variables) using the `$request.*` syntax.
777+
*
778+
* When left empty, no specific identity sources are configured and your Lambda must inspect the incoming event directly.
779+
*/
716780
identitySources?: string[];
781+
/**
782+
* #### Cache authorizer results
783+
*
784+
* ---
785+
*
786+
* Number of seconds API Gateway should cache the result of the Lambda authorizer for a given identity.
787+
* While cached, repeated requests skip calling your authorizer function and reuse the previous result.
788+
*
789+
* This value is applied to `AuthorizerResultTtlInSeconds`. If omitted, Stacktape sets it to `0` (no caching).
790+
*/
717791
cacheResultSeconds?: number;
718792
}
719793

720794
interface LambdaAuthorizer {
795+
/**
796+
* #### Lambda-based HTTP API authorizer
797+
*
798+
* ---
799+
*
800+
* Configures an API Gateway **request** authorizer that runs a Lambda function to decide whether a request is allowed.
801+
* This is useful when your authorization logic can't be expressed as simple JWT validation – for example when you
802+
* check API keys, look up permissions in a database, or integrate with a non-JWT identity system.
803+
*
804+
* Stacktape creates an `AWS::ApiGatewayV2::Authorizer` of type `REQUEST` and wires it up to your Lambda.
805+
*/
721806
type: 'lambda';
722807
properties: LambdaAuthorizerProperties;
723808
}

0 commit comments

Comments
 (0)