AWS Cognito

2023. 8. 19. 12:32☁️ Cloud

Cognito

AWS Congnito 는 웹/앱에 대한 인증, 권한 부여 및 사용자 관리를 제공한다.

유저는 이름과 패스워드를 사용하여 직접 로그인 하거나, SNS 계정으로 로그인(Oauth) 할 수 있다.

 

Cognito 특징

- 손쉬운 사용자 관리

- Managed Service 와 뛰어난 확장성 (Scalability)

 

 

사용자 풀

출처 : https://docs.aws.amazon.com/ko_kr/cognito/latest/developerguide/what-is-amazon-cognito.html

Cognito에서 제공하는 사용자 풀은 말 그대로 사용자의 모임을 의미한다. 애플리케이션을 사용하는 유저를 관리하기 위한 일종의 사용자 데이터베이스 역할로 볼 수 있다. 사용자 풀은 회원가입과 로그인 기능(+Oauth)을 사용할 수 있으며, 인증이 완료된 사용자에게 JWT를  반환한다. 이 JWT는 API GW에서 자격증명에 사용될 수 있으며, 사용자 풀에 있는 모든 사용자는 각각의 프로필을 보유한다.

 

 

자격 증명 풀

출처 : https://docs.aws.amazon.com/ko_kr/cognito/latest/developerguide/what-is-amazon-cognito.html

 

자격 증명 풀은 사용자에게 임시 AWS 보안 인증 권한을 부여하는 자격 증명 모음이다. 사용자 풀은 사용자 인증을 관리하는데 사용된다면, 자격 증명 풀은 AWS 리소스 접근 제어에 사용된다고 생각할 수 있다.

 

사용자 풀과 자격증명 풀의 차이를 정리하면
  1. 자격증명 풀은 자격증명을 생성하여 AWS 리소스에 대한 접근을 제어하는 데 사용되며, 사용자 풀은 사용자 인증을 관리하는 데 사용됩니다.
  2. 자격증명 풀은 AWS 리소스에 대한 액세스를 허용하는 데 중점을 둡니다. 사용자 풀은 사용자 계정 관리에 중점을 둡니다.
  3. 자격증명 풀은 애플리케이션이 AWS 리소스와 함께 사용될 때 사용됩니다. 사용자 풀은 일반적으로 사용자 인증 및 권한 부여가 필요한 곳 모두에서 사용될 수 있습니다.

 

 

Dump 로 알아보는 예시
A company hosts its application on AWS. The company uses Amazon Cognito to manage users. When users log in to the application, the application fetches required data from Amazon DynamoDB by using a REST API that is hosted in Amazon API Gateway. The company wants an AWS managed solution that will control access to the REST API to reduce development efforts.
Which solution will meet these requirements with the LEAST operational overhead?
  1. Congure an AWS Lambda function to be an authorizer in API Gateway to validate which user made the request.
  2. For each user, create and assign an API key that must be sent with each request. Validate the key by using an AWS Lambda function.
  3. Send the user’s email address in the header with every request. Invoke an AWS Lambda function to validate that the user with that email address has proper access.
  4. Congure an Amazon Cognito user pool authorizer in API Gateway to allow Amazon Cognito to validate each request.

기존) 사용자 정보를 DynamoDB에서 관리

변경) API GW 내부에 Cognito의 user pool 을 설정하여 애플리케이션 사용자 관리를 수행할 수 있다.