TsgcHTTPServer › Propriétés › Authentication

Authentication Propriété

Active et configure l'authentification utilisateur/mot de passe pour les connexions HTTP entrantes.

Syntaxe

property Authentication: TsgcWSAuthenticationServer_Options read FAuthentication write SetAuthentication;

Valeur par défaut

Enabled=False

Remarques

Lorsque Authentication.Enabled est True, le serveur authentifie chaque connexion entrante par rapport à la liste AuthUsers (format user=password par ligne) en utilisant le schéma Basic (authentification d'accès HTTP Basic). Les schémas Session et URL documentés sur TsgcWebSocketHTTPServer associent les informations d'identification au handshake WebSocket et n'ont aucun effet sur TsgcHTTPServer, puisque ce composant ne fait jamais évoluer une connexion. L'événement OnAuthentication vous permet d'intégrer votre propre vérification des informations d'identification ; OnUnknownAuthentication gère les schémas non standard tels que Bearer/JWT/OAuth2/WebAuthn. Utilisez CustomHeaders pour ajouter des en-têtes HTTP supplémentaires retournés lors des erreurs d'authentification.

Exemple


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

Retour aux propriétés