Blog | G5 Cyber Security

Kiosk Browser Authentication

TL;DR

This guide shows how to authenticate a browser acting as a kiosk from another browser (e.g., an admin interface). We’ll use cookies and a simple server-side check to verify the connection.

Steps

  1. Set up a Server-Side Component
  • Kiosk Browser – Initial Registration
  • app.get('/kiosk/register', (req, res) => {
      const token = uuidv4(); // Generate a unique token
      res.cookie('kiosk_token', token, { secure: true, httpOnly: true });
      res.json({ success: true, token });
    });
  • The cookie name (e.g., kiosk_token) is important and will be used later for validation.
  • Admin Browser – Authentication Request
  • Server-Side Validation
  • app.get('/admin/validate/:kioskId', (req, res) => {
      const { kioskId } = req.params;
      const tokenFromAdminCookie = req.cookies.kiosk_token;
    
      // Retrieve the expected token from your database based on kioskId.
      const expectedToken = getKioskToken(kioskId);
    
      if (tokenFromAdminCookie === expectedToken) {
        res.json({ success: true, message: 'Authentication successful' });
      } else {
        res.status(401).json({ success: false, message: 'Invalid token' });
      }
    });
  • Security Considerations
  • Exit mobile version