Supportato da
*Richiede l'edizione Enterprise di sgcWebSockets. Nelle altre edizioni, l'avvio di un server con Negotiate abilitato solleva l'eccezione "Negotiate authentication requires sgcWebSockets Enterprise".
Negotiate è lo schema di autenticazione HTTP alla base dell'autenticazione integrata di Windows. Il client dimostra la propria identità con Kerberos (SPNEGO) oppure, su Windows, ricorre a NTLM, in modo che gli utenti che hanno già effettuato l'accesso a un dominio si connettano senza digitare una password. I browser in una zona intranet, curl --negotiate e i client .NET che usano le credenziali predefinite possono tutti rispondere alla richiesta.
Authentication.Negotiate.Enabled (Boolean, predefinito False): abilita Negotiate. Richiede Authentication.Enabled.Authentication.Negotiate.ServicePrincipal (String): SPN facoltativo come HTTP/host.example.com@EXAMPLE.COM. Se vuoto, viene accettata qualsiasi chiave presente nel keytab o l'account della macchina. Solo per i server Indy, ignorato da http.sys.Authentication.Negotiate.Keytab (String): solo Linux, percorso del keytab del servizio. Se vuoto, si usa KRB5_KTNAME o il valore predefinito di sistema. Ignorato su Windows e da http.sys.OnNegotiateAuthentication(Connection: TsgcWSConnection; const aPrincipal: String; var Authenticated: Boolean): generato quando lo scambio Kerberos o NTLM viene completato. Authenticated arriva impostato a True, quindi senza un gestore viene accettato ogni principal autenticato da Windows o Kerberos. Lo imposti a False per rifiutare (il client riceve 401). Il principal è DOMAIN\user su Windows e user@REALM su Linux. Sui server Indy può essere letto successivamente come TsgcWSConnectionServer(Connection).Authentication.User, con AuthType = authNegotiate.Il server seguente accetta solo due principal. L'evento limita l'accesso in base al nome del 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;
Su Linux, imposti Authentication.Negotiate.Keytab sul percorso del keytab, ad esempio /etc/sgc/http.keytab, e usi nell'evento un principal Kerberos come alice@EXAMPLE.COM.
401 con WWW-Authenticate: Negotiate, più la richiesta del realm Basic quando è abilitato anche Basic.Authorization: Negotiate <token>.Authentication.AllowNonAuth è True una richiesta senza credenziali viene accettata in modo anonimo, mentre una richiesta che contiene un token Negotiate viene comunque autenticata.curl --negotiate -u : http://host.example.com:8080/
HTTP/host. I browser inviano Negotiate solo ai siti nella zona intranet o negli elenchi consentiti.Keytab a esso.