IAuthenticationProvider.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #if !BESTHTTP_DISABLE_SIGNALR_CORE && !BESTHTTP_DISABLE_WEBSOCKET
  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
  31. /// should return with the parameter.
  32. /// </summary>
  33. Uri PrepareUri(Uri uri);
  34. }
  35. }
  36. #endif