Включите беспарольную аутентификацию
🔐 Passwordless Authentication for MedusaJS using WebAuthn - The Modern, Secure Authentication Standard
1flowchart TD2 A[User Starts Registration] --> B[Request Registration Options]3 B --> C[Browser Creates Credential]4 C --> D[Send Credential to Server]5 D --> E[Server Verifies & Saves Credential]67 F[User Starts Login] --> G[Request Authentication Options]8 G --> H[User Interacts with Security Key]9 H --> I[Browser Generates Authentication Assertion]10 I --> J[Server Verifies Assertion]11 J --> K[User Authenticated]
Registration
Authentication
Install the package using npm:
npm install @vymalo/medusa-webauthn
Or using yarn:
yarn add @vymalo/medusa-webauthn
1plugins: [2 {3 resolve: "@vymalo/medusa-webauthn",4 options: {5 rpName: process.env.WEBAUTHN_RP_NAME, // Relying Party Name6 rpID: process.env.WEBAUTHN_RP_ID, // Relying Party ID7 origin: process.env.WEBAUTHN_ORIGIN, // Origin of your application8 },9 },10],1112projectConfig: {13 http: {14 authMethodsPerActor: {15 customer: ["webauthn"], // Enable WebAuthn for customers16 },17 },18},1920modules: [21 {22 resolve: "@medusajs/medusa/auth",23 dependencies: ["webauthn_api"],24 options: {25 providers: [26 {27 resolve: "@vymalo/medusa-webauthn/auth",28 id: "webauthn",29 options: {},30 },31 ],32 },33 }34]
1graph TD2 A[User Device] -->|Public Key| B[Server]3 B -->|Challenge| A4 A -->|Signed Challenge| B5 B -->|Verify Signature| A67 subgraph Cryptographic Process8 PK[Public Key Cryptography]9 Challenge[Challenge Generation]10 Signature[Signature Verification]11 end
Contributions are welcome! Please submit pull requests or open issues.
If you discover a security vulnerability, please contact [your security contact].