Servidor WebAuthn

· Features

Desde sgcWebSockets 2025.4.0 Enterprise, se admite el protocolo WebAuthn (actualmente en BETA). 

WebAuthn (Web Authentication) es un estándar web desarrollado por el World Wide Web Consortium (W3C) y la FIDO Alliance para habilitar autenticación sin contraseña segura en la web. Forma parte del framework más amplio FIDO2 y busca reducir la dependencia de las contraseñas tradicionales, que suelen ser vulnerables a phishing, credential stuffing y otros ataques.

En esencia, WebAuthn permite autenticar a los usuarios mediante criptografía de clave pública. En lugar de un usuario y contraseña, los usuarios registran un par único de claves privada-pública con una aplicación web (el Relying Party). La clave privada se almacena de forma segura en un autenticador (una clave hardware, un smartphone o un dispositivo biométrico integrado), mientras que la clave pública se guarda en el servidor.

Durante la autenticación, el servidor emite un challenge que debe firmarse con la clave privada del usuario. El challenge firmado se devuelve y se verifica con la clave pública almacenada, asegurando la integridad y el origen de la respuesta. Este enfoque evita que las credenciales puedan ser interceptadas o reutilizadas.

WebAuthn admite una amplia variedad de autenticadores y dispositivos, lo que lo hace flexible tanto para desarrolladores como para usuarios. También permite autenticación multifactor (MFA) cuando se combina con otros factores como PIN o biometría, mejorando significativamente la seguridad sin sacrificar la usabilidad.

Formatos de atestación admitidos

Los distintos formatos de atestación definen cómo se estructuran y verifican estos datos. Tres formatos habituales son android-key, packed, y otros como fido-u2f, apple o none. Por defecto, todos los formatos de atestación están activados; a continuación se muestra la lista de formatos admitidos:


Flujo WebAuthn


Componente servidor WebAuthn

El componente TsgcWSAPIServer_WebAuthn proporciona una solución sencilla pero potente para implementar el servidor Relying Party de WebAuthn, habilitando autenticación sin contraseña en tu aplicación web. Una aplicación WebAuthn consiste en un WebAuthn server that handles the server-side registration and authentication and a client-side application that usually is a javascript application.


Find below a simple configuration of the WebAuthn Server:


  // ... create the servers
  HTTPServer := TsgcWebSocketHTTPServer.Create(nil);
  WebAuthnServer := TsgcWSAPIServer_WebAuthn.Create(nil);
  WebAuthnServer.Server := HTTPServer;
  // ... enable for testing
  WebAuthnServer.EndpointsOptions.Test.Enabled := True;
  // ... WebAuthn options
  WebAuthnServer.WebAuthnOptions.RelyingParty := 'localhost';
  // ... bindings
  Server.Port := 443;
  HTTPServer.SSLOptions.Port := 443;
  HTTPServer.Bindings.Clear;
  With HTTPServer.Bindings.Add do
  begin
    Port := 443;
    IP := '127.0.0.1';
  end;
  HTTPServer.SSLOptions.Certificate := 'sgc.pem';
  HTTPServer.SSLOptions.KeyFile := 'sgc.pem';  
  HTTPServer.SSL := True;
  // ... active
  HTTPServer.Active := True; 

Delphi WebAuthn Server Demo

The following Delphi WebAuthn Demo shows how to register a new credential and use after to authenticate the user.