The Authorization and Authentication Service is a robust and scalable system designed to manage user authentication and session management for multiple devices. It provides a secure interface for user login, single sign-on (SSO), logout, and password management operations. This service supports multiple concurrent sessions across different devices, ensuring seamless user experiences.
- Login: Authenticate users with their username and password.
- Login with SSO: Provide Single Sign-On functionality using external identity providers.
- Logout: Log out from the current session.
- Logout All: Log out from all active sessions across devices.
- Forgot Password: Initiate a password reset process by sending a reset link to the registered email address.
- Reset Password: Allow users to reset their password using a secure token.
- Multiple Sessions: Support multiple simultaneous sessions for the same user on different devices.
- NestJS
- Typeorm
POST /auth/login
Request Body:
{
"username": "user@example.com",
"password": "your_password"
}
Response:
{
"message": "Login successful",
"token": "jwt_token",
"sessionId": "session_id"
}
POST /auth/login-sso
Request Body:
{
"provider": "google",
"token": "sso_provider_token"
}
Response:
{
"message": "Login successful",
"token": "jwt_token",
"sessionId": "session_id"
}
POST /auth/logout
Request Body:
{
"sessionId": "session_id"
}
Response:
{
"message": "Logout successful"
}
POST /auth/logout-all
Request Body:
{
"userId": "user_id"
}
Response:
{
"message": "Logged out from all sessions"
}
POST /auth/forgot-password
Request Body:
{
"email": "user@example.com"
}
Response:
{
"message": "Password reset link sent to email"
}
POST /auth/reset-password
Request Body:
{
"token": "reset_token",
"newPassword": "new_password"
}
Response:
{
"message": "Password reset successful"
}
Variable | Description | Example |
---|---|---|
DATABASE_URL |
Database connection string | postgres://localhost:27017 |
JWT_SECRET |
Secret key for signing JWTs | your_secret_key |
EMAIL_SERVICE |
Email service provider | gmail |
EMAIL_USER |
Email service username | your_email@gmail.com |
EMAIL_PASSWORD |
Email service password | your_email_password |