This is a robust, serverless authentication service that uses AWS Cognito for handling user authentication. It's built using Serverless Framework, AWS Lambda, and Express.js.
This service provides the following REST API endpoints for user authentication:
/signup
- Register a new user/confirm
- Confirm a new user registration/resend-confirm
- Resend the confirmation code to the user's email/login
- Authenticate a user/forgot
- Request a user password reset/reset-password
- Reset a user's password/refresh
- Refresh a user's authentication tokens
- Install Serverless globally
npm install -g serverless
- Clone the repository:
git clone https://github.com/otlichnyy/auth-service-serverless.git
cd repo
- Install dependencies:
npm install
- Deploy the service:
npm run deploy
The API endpoints can be invoked using any HTTP client like curl or Postman. Here are some examples:
- Signup
POST /signup
{
"email": "test@example.com",
"password": "yourpassword"
}
- Confirm Signup
POST /confirm
{
"email": "test@example.com",
"code": "123456"
}
To run tests, use the following npm script:
npm test
This service uses ESLint and Prettier for code formatting and consistency. Run the linter with:
npm run lint
To deploy this service to your AWS account, you need to set up your AWS credentials either by setting up the AWS CLI or by adding the access key and secret key to a .env
file in the root of the project.
Then run:
npm run deploy
To delete the service from your AWS account, run:
npm run destroy
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.