Skip to main content
Skip to main content

Authentication Adapters

Mifty provides comprehensive authentication adapters for popular OAuth providers and OTP-based authentication methods. These adapters handle the complete authentication flow, token management, and user profile integration.

OAuth Authentication Adapters

GitHub OAuth

🔐auth

GitHub OAuth

Integrate GitHub OAuth authentication with automatic user profile synchronization

Installation

npm run auth:install auth-github

Environment Variables

GITHUB_CLIENT_IDRequired

GitHub OAuth application client ID from GitHub Developer Settings

Example: Iv1.a629723000000000
GITHUB_CLIENT_SECRETRequired

GitHub OAuth application client secret from GitHub Developer Settings

Example: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GITHUB_CALLBACK_URLRequired

OAuth callback URL configured in your GitHub application

Example: http://localhost:3000/auth/github/callback
Complete .env example:
GITHUB_CLIENT_ID=Iv1.a629723000000000
GITHUB_CLIENT_SECRET=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GITHUB_CALLBACK_URL=http://localhost:3000/auth/github/callback

Google OAuth

🔐auth

Google OAuth

Integrate Google OAuth authentication with Google profile and email access

Installation

npm run auth:install auth-google

Environment Variables

GOOGLE_CLIENT_IDRequired

Google OAuth client ID from Google Cloud Console

Example: 123456789012-abcdefghijklmnopqrstuvwxyz123456.apps.googleusercontent.com
GOOGLE_CLIENT_SECRETRequired

Google OAuth client secret from Google Cloud Console

Example: GOCSPX-xxxxxxxxxxxxxxxxxxxxxxxx
GOOGLE_CALLBACK_URLRequired

OAuth callback URL configured in Google Cloud Console

Example: http://localhost:3000/auth/google/callback
Complete .env example:
GOOGLE_CLIENT_ID=123456789012-abcdefghijklmnopqrstuvwxyz123456.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxxxxxxxxxx
GOOGLE_CALLBACK_URL=http://localhost:3000/auth/google/callback

LinkedIn OAuth

🔐auth

LinkedIn OAuth

Integrate LinkedIn OAuth authentication for professional networking features

Installation

npm run auth:install auth-linkedin

Environment Variables

LINKEDIN_CLIENT_IDRequired

LinkedIn OAuth application client ID from LinkedIn Developer Portal

Example: 78xxxxxxxxxxxxxxxx
LINKEDIN_CLIENT_SECRETRequired

LinkedIn OAuth application client secret from LinkedIn Developer Portal

Example: xxxxxxxxxxxxxxxx
LINKEDIN_CALLBACK_URLRequired

OAuth callback URL configured in LinkedIn application settings

Example: http://localhost:3000/auth/linkedin/callback
Complete .env example:
LINKEDIN_CLIENT_ID=78xxxxxxxxxxxxxxxx
LINKEDIN_CLIENT_SECRET=xxxxxxxxxxxxxxxx
LINKEDIN_CALLBACK_URL=http://localhost:3000/auth/linkedin/callback

Facebook OAuth

🔐auth

Facebook OAuth

Integrate Facebook OAuth authentication with Facebook profile access

Installation

npm run auth:install auth-facebook

Environment Variables

FACEBOOK_APP_IDRequired

Facebook application ID from Facebook Developers Console

Example: 1234567890123456
FACEBOOK_APP_SECRETRequired

Facebook application secret from Facebook Developers Console

Example: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FACEBOOK_CALLBACK_URLRequired

OAuth callback URL configured in Facebook application settings

Example: http://localhost:3000/auth/facebook/callback
Complete .env example:
FACEBOOK_APP_ID=1234567890123456
FACEBOOK_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FACEBOOK_CALLBACK_URL=http://localhost:3000/auth/facebook/callback

OTP Authentication Adapters

Email OTP Authentication

🔐auth

Email OTP Authentication

Implement secure email-based OTP authentication with customizable templates

Installation

npm run auth:install auth-email-otp

Environment Variables

OTP_EMAIL_PROVIDERRequired

Email service provider for sending OTP codes

Example: gmail(Default: smtp)
OTP_CODE_LENGTH

Length of the generated OTP code

Example: 6(Default: 6)
OTP_EXPIRY_MINUTES

OTP code expiration time in minutes

Example: 10(Default: 5)
OTP_MAX_ATTEMPTS

Maximum number of OTP verification attempts

Example: 3(Default: 3)
Complete .env example:
OTP_EMAIL_PROVIDER=gmail
OTP_CODE_LENGTH=6
OTP_EXPIRY_MINUTES=10
OTP_MAX_ATTEMPTS=3

Mobile OTP Authentication

🔐auth

Mobile OTP Authentication

Implement SMS-based OTP authentication using Twilio or other SMS providers

Installation

npm run auth:install auth-mobile-otp

Environment Variables

SMS_PROVIDERRequired

SMS service provider for sending OTP codes

Example: twilio
TWILIO_ACCOUNT_SIDRequired

Twilio Account SID from Twilio Console

Example: ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKENRequired

Twilio Auth Token from Twilio Console

Example: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_PHONE_NUMBERRequired

Twilio phone number for sending SMS

Example: +1234567890
OTP_SMS_LENGTH

Length of the SMS OTP code

Example: 4(Default: 4)
Complete .env example:
SMS_PROVIDER=twilio
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_PHONE_NUMBER=+1234567890
OTP_SMS_LENGTH=4

General Authentication Commands

Here are the general commands for managing authentication adapters:

# List all available authentication adapters
npm run auth:list

# Install any authentication adapter
npm run auth:install <adapter-name>

# Install with custom model and table configuration
npm run auth:install <adapter-name> --model CustomUser --table custom_users

# List installed authentication adapters
npm run adapter installed

# Uninstall an authentication adapter
npm run adapter uninstall <adapter-name>

Next Steps

After setting up authentication adapters, you might want to:

Security Best Practices

  1. Environment Variables: Always store sensitive credentials in environment variables, never in code
  2. HTTPS: Use HTTPS in production for all OAuth callbacks
  3. Token Storage: Implement secure token storage and refresh mechanisms
  4. Rate Limiting: Implement rate limiting for OTP requests to prevent abuse
  5. Validation: Always validate and sanitize user input, especially phone numbers and email addresses
  6. Monitoring: Monitor authentication attempts and implement alerting for suspicious activity