Autenticação Kerberos e Negotiate

Suportado por

TsgcWebSocketServer

TsgcWebSocketHTTPServer

TsgcWebSocketProxyServer

TsgcWebSocketServer_HTTPAPI

*Requer a Edição Enterprise do sgcWebSockets. Em outras edições, iniciar um servidor com Negotiate habilitado gera a exceção "Negotiate authentication requires sgcWebSockets Enterprise".

Visão geral

Negotiate é o esquema de autenticação HTTP por trás da autenticação integrada do Windows. O cliente prova sua identidade com Kerberos (SPNEGO) ou, no Windows, recorre ao NTLM, de modo que usuários que já estão conectados a um domínio se conectam sem digitar uma senha. Navegadores em uma zona de intranet, curl --negotiate e clientes .NET que usam credenciais padrão podem responder ao desafio.

Plataformas

Propriedades e evento

Exemplo

O servidor a seguir aceita apenas dois principais. O evento restringe o acesso pelo nome do principal.


uses
  sgcWebSocket, sgcWebSocket_Classes;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    oServer: TsgcWebSocketHTTPServer;
    procedure OnNegotiateAuthenticationEvent(Connection: TsgcWSConnection;
      const aPrincipal: String; var Authenticated: Boolean);
  end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  oServer := TsgcWebSocketHTTPServer.Create(Self);
  oServer.Port := 8080;
  oServer.Authentication.Enabled := True;
  oServer.Authentication.Negotiate.Enabled := True;
  oServer.Authentication.Negotiate.ServicePrincipal :=
    'HTTP/host.example.com@EXAMPLE.COM';
  oServer.OnNegotiateAuthentication := OnNegotiateAuthenticationEvent;
  oServer.Active := True;
end;

procedure TForm1.OnNegotiateAuthenticationEvent(Connection: TsgcWSConnection;
  const aPrincipal: String; var Authenticated: Boolean);
begin
  Authenticated := SameText(aPrincipal, 'EXAMPLE\alice') or
    SameText(aPrincipal, 'EXAMPLE\bob');
end;

No Linux, defina Authentication.Negotiate.Keytab com o caminho do keytab, por exemplo /etc/sgc/http.keytab, e use um principal Kerberos como alice@EXAMPLE.COM no evento.

Como a troca funciona

Teste com curl

curl --negotiate -u : http://host.example.com:8080/

Notas de configuração