Skip to content

Instantly share code, notes, and snippets.

@SathishN
Created September 16, 2014 18:25
Show Gist options
  • Save SathishN/50c5c717028b6bcaf405 to your computer and use it in GitHub Desktop.
Save SathishN/50c5c717028b6bcaf405 to your computer and use it in GitHub Desktop.
using System.Net;
using global::ServiceStack;
using global::ServiceStack.Logging;
using global::ServiceStack.ServiceHost;
public class AuthenticateFilter
{
private static readonly ILog Log = LogManager.GetLogger(typeof(AuthenticateFilter));
public static void Authenticate(IHttpRequest request, IHttpResponse response, object requestDto)
{
if (response.IsClosed) return;
var httpRequest = request.OriginalRequest as HttpRequest;
if (httpRequest == null || !httpRequest.IsAuthenticated)
{
response.StatusCode = (int)HttpStatusCode.Unauthorized;
response.EndRequest();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment