Here we will go deeper into Cognito. There are some features of Cognito that we need to pay attention to.
To store a user, we need to have their information, which is divided into attributes. In a User Pool, we have three different types of attributes:
This is my own naming convention. “Custom attributes” is the exact term used in the official documentation, while the other two types are names I created based on their nature.

Officially supported attributes only help identify users in the pool and serve no other role. Imagine our application needs to implement authorization, but we only know the user’s information and not their role or team—this would make it difficult to implement such a feature. That’s why we need two additional types of attributes besides the official ones.
So, in this workshop, we will need an additional optional attribute to authorize users—role—along with using Cognito’s extended attribute—groups.
This is the process of authenticating with a Cognito user pool, and the user can define how they “initiate auth,” send information, and respond to any challenges returned.
The most common and widely used authentication type is username and password. In a Cognito Client App, this is called the USER_PASSWORD_AUTH authentication flow. Another, less visible but equally common form is token-based authentication, called the REFRESH_TOKEN_AUTH flow in Cognito.
We can also define our own custom flow when using external services, known in Cognito as CUSTOM_AUTH.
Server-side applications can also use a user’s username and password to log in; in Cognito, this is called ADMIN_USER_PASSWORD_AUTH. For this workshop, we only need to focus on these flows because we will directly use ADMIN_USER_PASSWORD_AUTH and also REFRESH_TOKEN_AUTH.
In short, users can log in directly with Cognito, or we can implement our own custom logic on the server side, which is what we’ll do in this workshop.
In Cognito, there are two main flows: sign-up and sign-in. We can inject custom logic into these flows. For example, if sign-in goes A-B-C-D, we can insert a piece of code before B to execute additional logic—this is how I understand “Extension.” Cognito has four types of triggers, corresponding to four flows: Sign-up, Authentication, Custom authentication, and Messaging:
For Sign-up:
For Authentication:
For Custom authentication:
For Messaging:
This section will include: