TsgcHTTPServer › Propriedades › Authentication

Authentication Property

Habilita e configura a autenticação de usuário/senha para conexões HTTP de entrada.

Sintaxe

property Authentication: TsgcWSAuthenticationServer_Options read FAuthentication write SetAuthentication;

Valor Padrão

Enabled=False

Observações

Quando Authentication.Enabled é True, o servidor autentica cada conexão de entrada com a lista AuthUsers (formato user=password por linha) utilizando o esquema Basic (HTTP Basic Access Authentication). Os esquemas Session e URL documentados em TsgcWebSocketHTTPServer anexam credenciais ao handshake WebSocket e não têm efeito no TsgcHTTPServer, já que este componente nunca faz upgrade de uma conexão. O evento OnAuthentication permite que você insira sua própria verificação de credenciais; OnUnknownAuthentication trata esquemas não padrão, como Bearer/JWT/OAuth2/WebAuthn. Utilize CustomHeaders para adicionar cabeçalhos HTTP extras retornados em erros de autenticação.

Exemplo


oServer := TsgcHTTPServer.Create(nil);
oServer.Authentication.Enabled := true;
oServer.Authentication.Basic.Enabled := true;
oServer.Authentication.AuthUsers.Add('user=secret');
oServer.Active := true;

Voltar para Propriedades