A full-stack web application implementing secure authentication using AWS Cognito with Time-based One-Time Password (TOTP) multi-factor authentication.
- AWS Cognito Authentication: Secure user authentication with your existing Cognito user pool
- TOTP-based MFA: Multi-factor authentication using Google Authenticator or similar apps
- QR Code Setup: Easy MFA setup by scanning QR codes
- Modern UI: Clean, responsive interface built with React and Tailwind CSS
- Session Management: Secure session handling with automatic cleanup
Before running this application locally, make sure you have:
-
Node.js (version 18 or higher)
- Download from nodejs.org
- Verify installation:
node --version
-
Git (for cloning the repository)
- Download from git-scm.com
-
AWS Cognito User Pool (already configured)
- User Pool ID:
us-east-1_x06JPtf0r - Client ID:
63r5ue04ggrk1g0tvic031njh - Region:
us-east-1
- User Pool ID:
If you have the project files, skip to step 2. Otherwise:
# Clone the repository (if using Git)
git clone <repository-url>
cd secure-auth-app
# OR download and extract the project files to a folder- Windows: Press
Win + R, typecmd, press Enter - Mac: Press
Cmd + Space, typeterminal, press Enter - Linux: Press
Ctrl + Alt + T
# Change to your project directory
cd path/to/your/project
# Example:
# cd C:\Users\YourName\Downloads\secure-auth-app
# cd /Users/YourName/Downloads/secure-auth-app
# cd ~/Downloads/secure-auth-app# Install all required packages
npm installThis will download and install all necessary dependencies. It may take a few minutes.
The application uses these AWS Cognito settings (already configured):
- User Pool ID:
us-east-1_x06JPtf0r - Client ID:
63r5ue04ggrk1g0tvic031njh - Region:
us-east-1
These are hardcoded in the application, so no additional setup is needed.
# Start the development server
npm run devYou should see output like:
> rest-express@1.0.0 dev
> NODE_ENV=development tsx server/index.ts
[timestamp] [express] serving on port 5000
- Open your web browser
- Go to:
http://localhost:5000 - You should see the login page
- Login: Enter your email and password
- QR Code: If MFA setup is required, you'll see a QR code
- Google Authenticator:
- Download Google Authenticator from your app store
- Open the app and tap "Scan QR code"
- Scan the QR code displayed on screen
- Enter Code: Type the 6-digit code from Google Authenticator
- Success: You'll be redirected to the success page
- Login: Enter your email and password
- Enter Code: Type the 6-digit code from your Google Authenticator app
- Success: You'll be redirected to the success page
secure-auth-app/
├── client/ # Frontend React application
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── pages/ # Application pages
│ │ └── lib/ # Utilities and configurations
├── server/ # Backend Express server
│ ├── index.ts # Server entry point
│ ├── routes.ts # API routes
│ └── storage.ts # Session storage
├── shared/ # Shared types and schemas
│ └── schema.ts # Data validation schemas
└── package.json # Dependencies and scripts
# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm start-
Port 5000 is busy:
Error: listen EADDRINUSE: address already in use :::5000- Close other applications using port 5000
- Or kill the process:
npx kill-port 5000
-
Node.js not found:
'node' is not recognized as an internal or external command- Install Node.js from nodejs.org
- Restart your terminal after installation
-
Permission errors on Mac/Linux:
EACCES: permission denied- Try:
sudo npm install(use with caution) - Or fix npm permissions: npm docs
- Try:
-
Login fails with "Invalid credentials":
- Verify you're using a valid user from the AWS Cognito user pool
- Check that the user is confirmed (not pending verification)
-
MFA code doesn't work:
- Ensure your phone's time is synchronized
- Try generating a new code (they change every 30 seconds)
- Make sure you scanned the QR code correctly
If you encounter issues:
- Check the terminal/console for error messages
- Verify all prerequisites are installed
- Make sure port 5000 is available
- Ensure you have a stable internet connection (for AWS Cognito)
- SRP Authentication: Uses Secure Remote Password protocol
- Session Management: Secure session handling with automatic cleanup
- TOTP Verification: Time-based one-time passwords for MFA
- Input Validation: All inputs are validated and sanitized
- Error Handling: Comprehensive error handling and user feedback
- Frontend: React 18, TypeScript, Tailwind CSS, Wouter (routing)
- Backend: Node.js, Express, TypeScript
- Authentication: AWS Amplify, AWS Cognito
- MFA: Speakeasy (TOTP), QRCode generation
- Build Tools: Vite, tsx
This application works with the pre-configured AWS Cognito user pool:
- Region: us-east-1
- User Pool ID: us-east-1_x06JPtf0r
- Client ID: 63r5ue04ggrk1g0tvic031njh
No additional AWS configuration is required to run the application locally.