Authentication overview

SAWO Labs provides a passwordless authentication platform designed to simplify user login while enhancing security. The system eliminates the need for users to remember or type passwords by leveraging device-based authentication, biometrics, and secure One-Time Password (OTP)-less flows. This approach aims to reduce common vulnerabilities associated with passwords, such as phishing and credential stuffing, and improve user experience by streamlining the login process.

The core of SAWO Labs's authentication system relies on cryptographic keys generated and stored securely on the user's device. When a user attempts to log in, their device communicates with the SAWO Labs backend to verify identity without transmitting a password. This process aligns with modern authentication standards that prioritize device-bound credentials and multi-factor authentication principles to establish trust with user identities, as outlined in FIDO Alliance specifications. Developers integrate SAWO Labs into their applications using dedicated SDKs for various platforms or by directly interacting with its REST API.

Supported authentication methods

SAWO Labs focuses on delivering diverse passwordless authentication methods, enabling developers to choose the most suitable option for their application's security requirements and user base. These methods are designed to be user-friendly while maintaining a high level of security by leveraging device-specific features and secure protocols.

Method When to Use Security Level
Biometric Authentication Mobile and web applications where devices support biometrics (fingerprint, facial recognition). Ideal for high-security contexts and user convenience. High (leverages device-native secure elements, resistant to phishing).
Device-based Authentication Any application where users log in from a trusted device. Suitable for reducing friction by tying user identity to a specific device. High (cryptographically secure, device-bound credentials).
OTP-less Login Applications requiring a seamless login without traditional OTPs. Uses secure, device-generated tokens rather than SMS/email codes. Medium-High (eliminates SMS/email OTP vulnerabilities; relies on device trust).
Magic Link (Email/SMS) For users without biometric capabilities or when a fallback is needed. Provides a link to click, typically for one-time access. Medium (vulnerable if email/SMS account is compromised; better than passwords).

Each method is implemented using SAWO Labs's proprietary technology, which integrates with existing identity management systems or functions as a standalone authentication solution. The platform's flexibility allows for a tailored approach to user identity verification, supporting various application types from e-commerce to enterprise solutions, as detailed in the SAWO Labs documentation.

Getting your credentials

To integrate SAWO Labs authentication into an application, developers must first obtain the necessary credentials. This process typically involves registering an application within the SAWO Labs developer console.

  1. Sign up for a SAWO Labs Account: Navigate to the SAWO Labs homepage and create a new developer account.
  2. Create a New Project: Once logged in, access the SAWO Labs Dashboard. Create a new project, which will represent your application. Projects are used to manage credentials and settings specific to each integration.
  3. Generate Application Credentials: Within your project settings, locate the section for application credentials. SAWO Labs typically provides a Client ID and a Client Secret (or similar API keys). The Client ID identifies your application to the SAWO Labs platform, while the Client Secret is used for server-side authentication and should be kept confidential.
  4. Configure Redirect URIs (for Web/Mobile): For web and mobile applications, it is necessary to configure authorized redirect URIs. These URIs are the locations to which SAWO Labs will redirect users after a successful authentication, helping to prevent phishing attacks.
  5. Install SDK or Prepare API Calls: With credentials in hand, integrate the relevant SAWO Labs SDK into your frontend or backend application. The SDKs abstract much of the complexity, handling secure communication and user interface flows. For direct API integration, the Client ID and Client Secret will be used to authorize requests to the SAWO Labs API endpoints.

For detailed, step-by-step instructions on obtaining credentials and configuring your application, refer to the SAWO Labs API reference and SDK-specific guides.

Authenticated request example

After a user successfully authenticates through the SAWO Labs SDK, the application receives a unique payload containing proof of authentication. This payload is typically exchanged with your backend for verification and to establish a session or issue an access token. The following example demonstrates a common pattern: collecting the authentication token from the SAWO Labs SDK on the client side and then sending it to your backend for validation.

Client-side (JavaScript SDK example):

import Sawo from 'sawo';

const sawoConfig = {
  containerID: 'sawo-container',
  identifierType: 'email',
  apiKey: 'YOUR_SAWO_API_KEY_CLIENT_ID',
  onSuccess: async (payload) => {
    console.log('Authentication successful:', payload);
    // Send the payload to your backend for verification
    try {
      const response = await fetch('/api/verify-sawo-auth', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({ sawo_payload: payload }),
      });
      const data = await response.json();
      if (data.success) {
        console.log('Backend verification successful:', data);
        // Redirect or update UI
      } else {
        console.error('Backend verification failed:', data.error);
      }
    } catch (error) {
      console.error('Error sending payload to backend:', error);
    }
  },
};

const sawo = new Sawo(sawoConfig);
sawo.showLogin();

Server-side (Node.js example for verification):

Your backend should receive the sawo_payload and verify its authenticity using your SAWO Labs Client Secret. This verification ensures that the authentication request genuinely originated from SAWO Labs and was not tampered with.

const express = require('express');
const axios = require('axios'); // For making HTTP requests
const app = express();

app.use(express.json());

app.post('/api/verify-sawo-auth', async (req, res) => {
  const { sawo_payload } = req.body;

  if (!sawo_payload || !sawo_payload.user_id) {
    return res.status(400).json({ success: false, error: 'Invalid SAWO payload' });
  }

  const SAWO_API_KEY = process.env.SAWO_API_KEY; // Your SAWO Labs Client ID
  const SAWO_API_SECRET = process.env.SAWO_API_SECRET; // Your SAWO Labs Client Secret

  try {
    // SAWO Labs provides an API for verifying the authentication token.
    // The exact endpoint and payload might vary; consult SAWO Labs documentation.
    const verificationResponse = await axios.post('https://api.sawolabs.com/api/v1/user/verify', {
      user_id: sawo_payload.user_id,
      verification_token: sawo_payload.verification_token, // Or similar token from payload
      api_key: SAWO_API_KEY,
    }, {
      headers: {
        'Content-Type': 'application/json',
        'X-Sawo-Secret': SAWO_API_SECRET, // Often passed as a custom header
      },
    });

    if (verificationResponse.data.status === 'success') {
      // Authentication verified. Create a session for the user.
      console.log('SAWO Labs verification successful for user:', sawo_payload.user_id);
      // Implement your application's session management here
      res.json({ success: true, message: 'Authentication successful', user: sawo_payload.user_id });
    } else {
      res.status(401).json({ success: false, error: 'SAWO Labs verification failed', details: verificationResponse.data });
    }
  } catch (error) {
    console.error('Error during SAWO Labs verification:', error.response ? error.response.data : error.message);
    res.status(500).json({ success: false, error: 'Internal server error during verification' });
  }
});

app.listen(3000, () => {
  console.log('Backend listening on port 3000');
});

This server-side verification step is critical for security, as it confirms the integrity and authenticity of the SAWO Labs authentication event. For the most current and specific verification endpoints and methods, refer to the SAWO Labs API reference documentation.

Security best practices

Implementing SAWO Labs authentication effectively requires adherence to general security best practices to protect both users and the application. While SAWO Labs handles much of the underlying security, developers play a crucial role in securing the integration points.

  • Protect Your Client Secret: The SAWO Labs Client Secret (or equivalent API key for server-side use) must be treated as highly sensitive information. Never expose it in client-side code, commit it to public repositories, or include it in client-side bundles. Store it securely, preferably in environment variables or a secrets management service, and only use it on your backend servers.
  • Validate All Server-Side Payloads: Always verify authentication payloads received from the client-side with the SAWO Labs API on your backend. This prevents spoofed requests and ensures that only legitimate authentication events are processed. This process is similar to how Stripe validates webhook signatures to ensure authenticity.
  • Implement Secure Session Management: After successful SAWO Labs authentication and server-side verification, establish a secure session for the user. Use industry-standard practices like HTTP-only cookies, short-lived access tokens, and refresh tokens. Ensure proper token invalidation upon logout or suspicious activity.
  • Configure Redirect URIs Carefully: For web and mobile integrations, precisely configure your authorized redirect URIs in the SAWO Labs dashboard. This prevents malicious actors from redirecting users to phishing sites after authentication.
  • Use HTTPS Everywhere: Ensure all communication between your application, SAWO Labs, and your users is encrypted using HTTPS. This protects authentication tokens and user data from interception during transit.
  • Regularly Review SAWO Labs Documentation: Authentication methods and security recommendations evolve. Regularly check the official SAWO Labs documentation for updates, new features, and enhanced security guidelines.
  • Implement Rate Limiting: Apply rate limiting to your authentication endpoints to mitigate brute-force attacks and denial-of-service attempts, even with passwordless methods.

By following these best practices, developers can maximize the security benefits of SAWO Labs's passwordless authentication and provide a robust, user-friendly experience.