{"id":15348228,"url":"https://github.com/ironcore864/aws-cognito-demo","last_synced_at":"2026-01-28T10:03:11.898Z","repository":{"id":186124187,"uuid":"612011590","full_name":"IronCore864/aws-cognito-demo","owner":"IronCore864","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-29T08:35:21.000Z","size":264,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-01T02:43:59.039Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IronCore864.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-10T02:16:58.000Z","updated_at":"2023-03-15T05:32:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"852e89bb-bfdb-40d6-b54c-abd69372023c","html_url":"https://github.com/IronCore864/aws-cognito-demo","commit_stats":null,"previous_names":["ironcore864/aws-cognito-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/IronCore864/aws-cognito-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Faws-cognito-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Faws-cognito-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Faws-cognito-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Faws-cognito-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IronCore864","download_url":"https://codeload.github.com/IronCore864/aws-cognito-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Faws-cognito-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28844011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T07:39:25.367Z","status":"ssl_error","status_checked_at":"2026-01-28T07:39:24.487Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T11:45:27.286Z","updated_at":"2026-01-28T10:03:11.880Z","avatar_url":"https://github.com/IronCore864.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Cognito Demo\n\n## 1 Prerequisite\n\n### 1.1 Tools\n\n- AWS CLI\n- Terraform\n- Node, npm\n\n### 1.2 AWS Cognito / Lambda / API Gateway\n\n_This step is already done._\n\n```bash\ncd terraform\nterraform init\nterraform plan\nterraform apply\n```\n\nMore on the API Gateway:\n\nHere I created a Rest API in API Gateway, with a Lambda function as the backend mock. Created Terraform resources:\n\nLambda:\n\n- aws_iam_role for lambda\n- aws_lambda_function\n\nAPI Gateway:\n\n- aws_api_gateway_rest_api\n- aws_api_gateway_authorizer\n- aws_api_gateway_resource\n- aws_api_gateway_method\n\nAPI Gateway integration settings (as in this example, it's configured to use a Lambda function as the backend):\n\n- aws_api_gateway_integration\n- aws_api_gateway_method_response\n- aws_api_gateway_integration_response\n- aws_lambda_permission\n\nAPI Gateway deployment/stage:\n\n- aws_api_gateway_deployment\n- aws_api_gateway_stage\n\nIn short, the created API has only one path with one action (GET), and it uses the Congnito user pool for authentication. A logged in user has an id_token, and we can set the id_token in the Authorization header to access the backend.\n\n### 1.3 Create Users\n\n_This step is already done._\n\nCreate user with a verified email address (user doesn't have to verify again):\n\n```bash\naws cognito-idp admin-create-user \\\n              --user-pool-id us-east-2_C0GL3MgBU \\\n              --username testuser \\\n              --user-attributes Name=email,Value=tiexin.guo@merico.dev Name=email_verified,Value=\"true\"\n```\n\nOnly with verified email can a user reset his password.\n\nSet password:\n\n```bash\naws cognito-idp admin-set-user-password --user-pool-id \"us-east-2_C0GL3MgBU\" --username \"testuser\" --password 'Password1234#' --permanent\n```\n\n---\n\n## 2 Demo App\n\nStart the frontend app:\n\n```bash\ncd amplify-test\nnpm i\nnpm start\n```\n\nThen you can login with the user created in step [1.3](#13-create-users)\n\n_Check out the console log to get the id_token of the user, which will be used to demo the backend API authentication._\n\n---\n\n## 3 Backend\n\nAfter successfully logging in to the frontend app, the id_token will be printed in the console log. Get the id_token, and access the backend:\n\ncurl --header \"Authorization: ID_TOKEN_HERE\" https://ufa5pqf424.execute-api.us-east-2.amazonaws.com/dev/test\n\n_Note that this is only a demo to show how backend API authorization works. In reality, we will use `Auth.currentSession()` to get the id_token, set it in the header, then access backend API programmatically._\n\n---\n\n## 4 TODO\n\n- Terraform module for API Gateway to support multiple APIs\n- Use a Deployment in EKS with Ingress instead of a Lambda function as the backend of the API Gateway.\n\n---\n\n## 5 Read More\n\n- https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-integrate-apps.html\n- https://docs.amplify.aws/lib/auth/getting-started/q/platform/js/#option-1-use-pre-built-ui-components\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fironcore864%2Faws-cognito-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fironcore864%2Faws-cognito-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fironcore864%2Faws-cognito-demo/lists"}