The Passwordless Auth Service is a Spring Boot application that facilitates OTP-based login using the Multi-Factor Authentication (MFA) feature of Amazon Cognito. This service provides a secure and seamless authentication process without requiring traditional passwords. It stores basic user details in MongoDB and includes API endpoints for registration, login, refreshing tokens, and logout.
- Passwordless Authentication: Users can log in using an OTP, enhancing security and user convenience.
- Integration with Amazon Cognito: Leverages Cognito's MFA feature for managing OTPs and user sessions.
- MongoDB Integration: Stores user information securely in MongoDB.
- Dockerization: The application is containerized with Docker, facilitating easy deployment and scalability.
- API Endpoints: Includes endpoints for registration, login, token refresh, and logout.
- Java JDK 17
- MongoDB (latest version recommended)
- AWS account with Amazon Cognito configured
- Maven 3.4+
- Docker (latest version recommended)
- Clone the repository:
Clone the project to your local machine using the following command:
git clone https://github.com/BitanSarkar/passwordless-auth-service.git
- Navigate to the project directory:
cd passwordless-auth-service - Install dependencies:
mvn clean install
Configure the application and external services as follows:
- MongoDB: Ensure MongoDB is running and accessible. Configure the connection details in
application.properties. - Amazon Cognito: Set up a user pool and app client in Amazon Cognito. Include the necessary configurations in
application.properties. - Environment Variables: Set environment variables for sensitive information such as AWS access keys and MongoDB credentials.
To run the application using Maven:
The application supports the following endpoints:
- Register:
POST /register— Register a new user. - Login:
POST /login— Login using an OTP sent to your registered email. - Refresh Token:
POST /refresh-token— Refresh your authentication token. - Logout:
POST /logout— Log out the current user.
To run the application using Maven in local:
mvn clean install
java -jar /target/passwordless-auth-service-0.0.1.jar --spring.profiles.active=local --MONGODB_URL="your-mongo-url" --COGNITO_CLIENT_ID="your-cognito-client-id" --COGNITO_CLIENT_SECRET="your-cognito-client-secret" --COGNITO_GLOBAL_PASSWORD="self-generated-global-password"To build and run the application using Docker:
- Build the Docker image:
docker build -t passwordless-auth-service .- Run the Docker container:
docker run -p 8080:8080 \
-e MONGODB_URL="your-mongo-url" \
-e COGNITO_CLIENT_ID="your-cognito-client-id" \
-e COGNITO_CLIENT_SECRET="your-cognito-client-secret" \
-e COGNITO_GLOBAL_PASSWORD="self-generated-global-password" \
passwordless-auth-service
Contributions are welcome! Please fork the repository and submit pull requests with any new features or fixes. Report any issues through the repository's issue tracker.
For further questions or collaborations, feel free to contact me at bitansarkar12345@gmail.com.
Thanks to all contributors and testers who helped in refining this authentication service.