Auth passkey
A starter for Medusa plugins.
Compatibility
This starter is compatible with versions >= 2.4.0 of .
@tsc_tech/medusa-plugin-auth-passkey
This plugin allows users to register through email and mobile number using OTP. After registration, users are prompted to add a passkey. For already registered users, the generated passkey can be used to log in. If a user does not add a passkey during registration, they can add it later from the account section.
Usage
-
Registration:
- Users can register using their email or mobile number.
- An OTP will be sent to the provided email or mobile number for verification.
- After successful verification, users will be prompted to add a passkey.
-
Login:
- Registered users can log in using their email/mobile number and the generated passkey.
- If a user did not add a passkey during registration, they can add it later from their account section.
-
Adding Passkey:
- Users can navigate to the account section to add or update their passkey at any time.
Installation
To install the , run the following command:
or
Additionally, install the auth-plugin package:
or
Configuration
Step 1: Update Medusa Configuration Modify your medusa-config.ts to include the auth provider:
Run migrations after installation
Step 2. Set Up Environment Variables In your .env file, define the following variables:
Step 3: See the example (auth-passkey-storefront-example) to integrate with frontend (Medusa Starter Template).
Important: You must have a notification provider to send the otp to email or phone.
Features
Secure Authentication: Leverages passkeys for enhanced security.
OTP-based Verification: Ensures user identity with one-time passwords.
Seamless Integration: Easily integrates with Medusa’s authentication system.
Customizable: Environment variables allow configuration for different use cases.
Multi-Platform Support: Works with both email and mobile authentication.
Troubleshooting
If you encounter issues while setting up the plugin, consider the following:
Database Migration Issues: Run npx medusa db:migrate again and ensure your database is correctly set up.
Environment Variables Not Loading: Check if .env is correctly configured and restart your Medusa server.
Passkey Not Prompting: Ensure HTTPS is enabled if running on a production server.
Contribution
We welcome contributions to improve this plugin! If you have suggestions or find issues, feel free to submit a pull request or open an issue in the repository.