← 返回 Skills 市场
encryptshawn

AWS Cognito Auth

作者 EncryptShawn · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
105
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install aws-cognito
功能描述
Use this skill for ANY task involving AWS Cognito — user pools, identity pools, authentication flows, token handling, social/enterprise federation, MFA, Lamb...
使用说明 (SKILL.md)

AWS Cognito Skill

This skill helps you build, configure, debug, and manage AWS Cognito resources — user pools, identity pools, app clients, Lambda triggers, federation, and integrations with other AWS services.

Quick Decision: What Does the User Need?

  1. New Cognito setup from scratch → Read references/setup-guide.md, then follow the setup workflow
  2. CDK / CloudFormation / Terraform IaC → Read references/iac-patterns.md for production-ready templates
  3. Authentication flow implementation → Read references/auth-flows.md for SDK code and flow selection
  4. Debugging / troubleshooting → Read references/troubleshooting.md for common issues and fixes
  5. Lambda triggers → Read references/lambda-triggers.md for trigger patterns
  6. Security hardening → Read references/security.md for best practices

Read the relevant reference file(s) before generating any code or configuration. Multiple files may apply — for example, a new CDK setup would benefit from both setup-guide.md and iac-patterns.md.

Core Concepts (Always Keep in Mind)

User Pools vs Identity Pools

These are the two main Cognito components and they serve different purposes:

  • User Pool: A user directory and OIDC identity provider. Handles sign-up, sign-in, MFA, token issuance (ID token, access token, refresh token), and federation with external IdPs. Think of it as "who is this user?"
  • Identity Pool (Federated Identities): Exchanges tokens (from a user pool, social provider, SAML, or OIDC) for temporary AWS credentials (STS). Think of it as "what AWS resources can this user access?"

A common architecture uses both: User Pool authenticates the user and issues tokens → Identity Pool exchanges those tokens for AWS credentials → User accesses S3, DynamoDB, etc.

Feature Plans (Pricing Tiers)

As of late 2024, Cognito uses feature plans instead of the old "advanced security" toggle:

  • Lite: Low-cost, basic auth features. Good for simple apps with fewer MAUs.
  • Essentials (default for new pools): All latest auth features including access-token customization and managed login.
  • Plus: Everything in Essentials plus threat protection (adaptive auth, compromised credential detection).

Always ask the user which plan they need, or default to Essentials for new setups.

Token Types

  • ID Token: Contains user identity claims (email, name, groups, custom attributes). Use for identity verification on your backend.
  • Access Token: Contains scopes and authorized actions. Use for API authorization (e.g., API Gateway Cognito Authorizer).
  • Refresh Token: Long-lived token to obtain new ID/access tokens without re-authentication. Default validity is 30 days.

Workflow: Building a Cognito Solution

Step 1: Clarify Requirements

Before writing any code, determine:

  • Auth methods: Username/password? Email-only? Phone? Social login (Google, Apple, Facebook)? Enterprise SAML/OIDC?
  • MFA: Required, optional, or off? SMS, TOTP authenticator app, or email?
  • Self-service sign-up: Enabled or admin-only user creation?
  • Token usage: Frontend-only (SPA/mobile)? Backend API authorization? Direct AWS resource access?
  • IaC preference: CDK (TypeScript/Python), CloudFormation, Terraform, or console/CLI?
  • Frontend framework: React/Amplify, Next.js, Vue, mobile (iOS/Android), or custom?

Step 2: Design the Architecture

Based on requirements, determine:

  • User Pool configuration (sign-in aliases, attributes, password policy, MFA)
  • App client(s) — public (no secret, for SPAs/mobile) vs confidential (with secret, for server-side)
  • OAuth flows — Authorization Code (with PKCE for public clients), Implicit (legacy, avoid), Client Credentials (M2M)
  • Whether an Identity Pool is needed (only if users need direct AWS resource access)
  • Lambda triggers needed (pre-sign-up, post-confirmation, pre-token-generation, custom auth, etc.)
  • Domain — Cognito-hosted prefix domain or custom domain

Step 3: Implement

Read the appropriate reference files and generate code. Always:

  • Use the latest CDK v2 constructs (aws-cdk-lib/aws-cognito) — never CDK v1
  • For SDK code, use AWS SDK v3 (@aws-sdk/client-cognito-identity-provider) — never v2
  • For frontend, prefer Amplify v6 (aws-amplify) patterns
  • Include proper error handling and token refresh logic
  • Set RemovalPolicy.RETAIN on user pools in production (data loss prevention)
  • Never hardcode secrets — use environment variables or AWS Secrets Manager

Step 4: Security Review

Before declaring done, verify against references/security.md:

  • MFA is enabled (at least optional) for production
  • Password policy meets requirements (minimum 8 chars, complexity rules)
  • Token validity periods are reasonable
  • WAF is considered for public-facing auth endpoints
  • Least-privilege IAM for any Identity Pool roles
  • Client secrets are used for confidential clients
  • HTTPS-only callback URLs

Common Patterns Quick Reference

Cognito + API Gateway

Use a Cognito User Pool Authorizer on API Gateway. The access token is validated automatically. Scopes in the token control which API methods are accessible.

Cognito + AppSync

Configure AMAZON_COGNITO_USER_POOLS authorization on your GraphQL API. Use @auth directives in your schema for fine-grained access control.

Cognito + S3 (via Identity Pool)

User Pool → Identity Pool → IAM role with S3 permissions scoped to ${cognito-identity.amazonaws.com:sub}/* for per-user folders.

Cognito + Lambda (Custom Auth)

Use CUSTOM_AUTH flow with Define, Create, and Verify Auth Challenge triggers for passwordless (magic link, OTP) or multi-step authentication.

Machine-to-Machine (M2M)

Use Client Credentials grant with a resource server and custom scopes. No user interaction — one app authenticating to another.

Important Reminders

  • User pool attributes marked as required at creation CANNOT be changed later. Plan attributes carefully.
  • Custom attributes are always prefixed with custom: (e.g., custom:company).
  • The sub attribute is the unique, immutable user identifier. Use it as your primary key, not email or username.
  • Email/phone verification is separate from sign-in aliases. Auto-verify what you use for sign-in.
  • Cognito has service quotas (e.g., API request rate limits). For high-volume apps, request quota increases proactively.
  • Lambda triggers execute synchronously and have a 5-second timeout. Keep them fast.
安全使用建议
This skill is a documentation/authoring helper for AWS Cognito and appears internally consistent. It will show and generate code that expects you to provide AWS credentials, environment variables (USER_POOL_ID, CLIENT_ID, USERS_TABLE, etc.), and possibly Secrets Manager entries when you deploy the generated Lambdas/clients — but the skill does not itself collect or require those secrets. Before using it: 1) do not paste long-lived AWS credentials into chat; prefer IAM roles with least privilege for admin operations and use Secrets Manager for client secrets; 2) review any generated Pre-Token-Generation or Lambda trigger code carefully — these modify tokens and can elevate claims (e.g., inject admin roles) if misused; 3) ensure token storage and refresh patterns follow the security guidance in the references (avoid localStorage, use HttpOnly cookies or platform-provided secure storage); 4) when deploying triggers, verify they run within the 5s Cognito timeout and have appropriate IAM permissions scoped to specific resources; 5) confirm you are comfortable granting whatever runtime AWS credentials are necessary to execute the code the skill generates. If you want the skill to perform live AWS actions on your behalf, ask the publisher how it expects credentials to be provided and audited; otherwise using it as a documentation/authoring aid is low-risk.
功能分析
Type: OpenClaw Skill Name: aws-cognito Version: 1.0.0 The AWS Cognito skill bundle is a comprehensive and well-documented resource for managing authentication and authorization. It includes high-quality code snippets for AWS SDK v3, Amplify v6, and various IaC tools (CDK, Terraform, CloudFormation) that follow industry best practices. The documentation, particularly in security.md and lambda-triggers.md, emphasizes security-first configurations such as MFA, WAF integration, and least-privilege IAM roles, with no evidence of malicious intent, data exfiltration, or prompt injection.
能力评估
Purpose & Capability
Name/description (AWS Cognito guidance, code patterns, IaC, triggers, security) match the provided content: lots of documentation and examples for Cognito use-cases. The skill does not request unrelated credentials or binaries.
Instruction Scope
SKILL.md directs the agent to read the included reference files and generate code/config. The references include sample Lambda handlers and SDK/CDK code that call AWS APIs, use environment variables (e.g., USER_POOL_ID, CLIENT_ID, USERS_TABLE) and recommend using AWS credentials/Secrets Manager for admin actions — which is expected for a Cognito skill, but the guidance implicitly assumes the user will supply AWS creds when they deploy/run generated code.
Install Mechanism
No install spec and no code files that would be executed by the platform; this is instruction-only, so nothing downloaded or installed by the skill itself.
Credentials
The skill declares no required environment variables (none requested), which is reasonable for an instruction-only skill. However the included examples reference many env vars and AWS credentials for admin/API operations; be aware you will need to provide appropriate AWS credentials and secrets when you run generated code. The skill itself does not attempt to read or demand those secrets at install time.
Persistence & Privilege
always:false, no installers, and no modification of other skills or system-wide settings. Autonomous invocation is enabled (default) but is not combined with other concerning privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install aws-cognito
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /aws-cognito 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Major update: The skill now exclusively focuses on AWS Cognito, covering user pools, identity pools, authentication flows, Lambda triggers, federation, security, and integration patterns. - Added comprehensive reference files for setup, infrastructure-as-code templates, auth flows, troubleshooting, triggers, and security best practices. - Improved setup and architecture guidance, with clear workflows for new builds, IaC deployment, debugging, and secure production usage. - Outlines preference for latest AWS toolchain versions (CDK v2, AWS SDK v3, Amplify v6) and includes patterns for API Gateway, AppSync, S3, Lambda, and machine-to-machine usage. - Emphasizes Cognito’s updated feature plans (Lite, Essentials, Plus) and highlights critical design and security considerations.
元数据
Slug aws-cognito
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

AWS Cognito Auth 是什么?

Use this skill for ANY task involving AWS Cognito — user pools, identity pools, authentication flows, token handling, social/enterprise federation, MFA, Lamb... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 105 次。

如何安装 AWS Cognito Auth?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install aws-cognito」即可一键安装,无需额外配置。

AWS Cognito Auth 是免费的吗?

是的,AWS Cognito Auth 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

AWS Cognito Auth 支持哪些平台?

AWS Cognito Auth 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 AWS Cognito Auth?

由 EncryptShawn(@encryptshawn)开发并维护,当前版本 v1.0.0。

💬 留言讨论