POC (Proof of Concept) with the purpose of testing Cognito functionality for Machine To Machine authentication.
Cognito is a well-established authentication service from AWS widely used in the market.
Env. dependencies:
- Node >= v18
- Yarn, NPM or PNPM
Install dependencies:
yarn
Copy the .env-sample
file and rename it to .env
. Enter the required information from your Cognito configuration.
Run dev:
yan dev
Run build:
yarn build
Cognito - SignUp:
# Method: POST
# {url}/signup
{
"email": "jhondoe@email.com",
"name": "John Doe",
"password": "****"
}
Cognito - SignIn:
# Method: POST
# {url}/signin
{
"email": "jhondoe@email.com",
"password": "****"
}
Create Products:
# Method: POST
# {url}/products
# Headers: authorization - idToken
{
"id": "1c5da790-b6cf-41a4-8770-9bf8bd3a7b97",
"name": "Truck 4x4",
"type": "vehicle"
}
List Products:
# Method: GET
# {url}/products
# Headers: authorization - idToken
Controlar o acesso a uma API REST usando um grupo de usuários do Amazon Cognito como autorizador
Como verificar um token Web JSON
Exemplos de código do Amazon Cognito usando AWS SDKs
Using Cognito groups to control access to API endpoints
NodeJS (Typescript) Authentication Service with Amazon Cognito User Pools
Cognito-Express: API Authentication with AWS Congito
Video - Configurando Autenticação com o Amazon Cognito
Video - Implementando Autenticação e Autorização em APIs na AWS | Cognito + OAuth2