지원 대상
*sgcWebSockets Enterprise Edition이 필요합니다. 다른 에디션에서 Negotiate를 활성화한 서버를 시작하면 "Negotiate authentication requires sgcWebSockets Enterprise" 예외가 발생합니다.
Negotiate는 Windows 통합 인증의 기반이 되는 HTTP 인증 스킴입니다. 클라이언트는 Kerberos(SPNEGO)로 자신의 ID를 증명하며, Windows에서는 NTLM으로 폴백하므로 이미 도메인에 로그인한 사용자는 비밀번호를 입력하지 않고 연결할 수 있습니다. 인트라넷 영역의 브라우저, curl --negotiate, 기본 자격 증명을 사용하는 .NET 클라이언트 모두 이 챌린지에 응답할 수 있습니다.
Authentication.Negotiate.Enabled(Boolean, 기본값 False): Negotiate를 활성화합니다. Authentication.Enabled가 필요합니다.Authentication.Negotiate.ServicePrincipal(String): HTTP/host.example.com@EXAMPLE.COM과 같은 선택적 SPN입니다. 비어 있으면 keytab의 모든 키 또는 머신 계정이 허용됩니다. Indy 서버 전용이며 http.sys에서는 무시됩니다.Authentication.Negotiate.Keytab(String): Linux 전용이며 서비스 keytab의 경로입니다. 비어 있으면 KRB5_KTNAME 또는 시스템 기본값이 사용됩니다. Windows와 http.sys에서는 무시됩니다.OnNegotiateAuthentication(Connection: TsgcWSConnection; const aPrincipal: String; var Authenticated: Boolean): Kerberos 또는 NTLM 교환이 완료될 때 발생합니다. Authenticated는 True로 전달되므로, 핸들러가 없으면 Windows 또는 Kerberos가 인증한 모든 주체가 수락됩니다. 거부하려면 False로 설정하십시오(클라이언트는 401을 받습니다). 주체는 Windows에서는 DOMAIN\user, Linux에서는 user@REALM입니다. Indy 서버에서는 이후 AuthType = authNegotiate와 함께 TsgcWSConnectionServer(Connection).Authentication.User로 읽을 수 있습니다.다음 서버는 두 개의 주체만 수락합니다. 이벤트는 주체 이름으로 접근을 제한합니다.
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;
Linux에서는 Authentication.Negotiate.Keytab을 keytab 경로(예: /etc/sgc/http.keytab)로 설정하고, 이벤트에서 alice@EXAMPLE.COM과 같은 Kerberos 주체를 사용하십시오.
WWW-Authenticate: Negotiate와 함께 401을 받으며, Basic도 활성화되어 있으면 Basic realm 챌린지가 추가됩니다.Authorization: Negotiate <token>으로 응답합니다.Authentication.AllowNonAuth가 True이면 자격 증명이 없는 요청은 익명으로 수락되며, Negotiate 토큰을 포함한 요청은 여전히 인증됩니다.curl --negotiate -u : http://host.example.com:8080/
HTTP/host가 필요합니다. 브라우저는 인트라넷 영역 또는 허용 목록에 있는 사이트로만 Negotiate를 보냅니다.Keytab이 이를 가리키도록 설정하십시오.