AuthenticatedAttribute.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using ServiceStack.Web;
  2. using System;
  3. namespace MediaBrowser.Controller.Net
  4. {
  5. public class AuthenticatedAttribute : Attribute, IHasRequestFilter
  6. {
  7. public IAuthService AuthService { get; set; }
  8. /// <summary>
  9. /// The request filter is executed before the service.
  10. /// </summary>
  11. /// <param name="request">The http request wrapper</param>
  12. /// <param name="response">The http response wrapper</param>
  13. /// <param name="requestDto">The request DTO</param>
  14. public void RequestFilter(IRequest request, IResponse response, object requestDto)
  15. {
  16. AuthService.Authenticate(request, response, requestDto);
  17. }
  18. /// <summary>
  19. /// A new shallow copy of this filter is used on every request.
  20. /// </summary>
  21. /// <returns>IHasRequestFilter.</returns>
  22. public IHasRequestFilter Copy()
  23. {
  24. return this;
  25. }
  26. /// <summary>
  27. /// Order in which Request Filters are executed.
  28. /// &lt;0 Executed before global request filters
  29. /// &gt;0 Executed after global request filters
  30. /// </summary>
  31. /// <value>The priority.</value>
  32. public int Priority
  33. {
  34. get { return 0; }
  35. }
  36. }
  37. }