Skip to content

Instantly share code, notes, and snippets.

@brandanmajeske
Forked from SathishN/AuthenticateFilter
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandanmajeske/8559717cf6f7e3a9ef25 to your computer and use it in GitHub Desktop.
Save brandanmajeske/8559717cf6f7e3a9ef25 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