IAuthenticationProvider.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #if !BESTHTTP_DISABLE_SIGNALR_CORE
  2. using System;
  3. namespace BestHTTP.SignalRCore
  4. {
  5. public delegate void OnAuthenticationSuccededDelegate(IAuthenticationProvider provider);
  6. public delegate void OnAuthenticationFailedDelegate(IAuthenticationProvider provider, string reason);
  7. public interface IAuthenticationProvider
  8. {
  9. /// <summary>
  10. /// The authentication must be run before any request made to build up the SignalR protocol
  11. /// </summary>
  12. bool IsPreAuthRequired { get; }
  13. /// <summary>
  14. /// This event must be called when the pre-authentication succeded. When IsPreAuthRequired is false, no-one will subscribe to this event.
  15. /// </summary>
  16. event OnAuthenticationSuccededDelegate OnAuthenticationSucceded;
  17. /// <summary>
  18. /// This event must be called when the pre-authentication failed. When IsPreAuthRequired is false, no-one will subscribe to this event.
  19. /// </summary>
  20. event OnAuthenticationFailedDelegate OnAuthenticationFailed;
  21. /// <summary>
  22. /// This function called once, when the before the SignalR negotiation begins. If IsPreAuthRequired is false, then this step will be skipped.
  23. /// </summary>
  24. void StartAuthentication();
  25. /// <summary>
  26. /// This function will be called for every request before sending it.
  27. /// </summary>
  28. void PrepareRequest(HTTPRequest request);
  29. /// <summary>
  30. /// This function can customize the given uri. If there's no intention to modify the uri, this function should return with the parameter.
  31. /// </summary>
  32. Uri PrepareUri(Uri uri);
  33. /// <summary>
  34. /// Cancel any ongoing authentication.
  35. /// </summary>
  36. void Cancel();
  37. }
  38. }
  39. #endif