Created
October 22, 2012 18:59
-
-
Save superkarn/3933392 to your computer and use it in GitHub Desktop.
This attribute forces a particular request to be secure (over SSL).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SecureRequestFilterAttribute : Attribute, IHasRequestFilter | |
{ | |
public IHasRequestFilter Copy() | |
{ | |
return this; | |
} | |
public int Priority | |
{ | |
// https://github.com/ServiceStack/ServiceStack/issues/119 | |
// By setting priority to -100, this filter will be applied first. | |
get { return -100; } | |
} | |
public void RequestFilter(IHttpRequest req, IHttpResponse res, object requestDto) | |
{ | |
// https://groups.google.com/d/msg/servicestack/7JnQ8eLf36M/JFx2g7xEeEkJ | |
if (!req.IsSecureConnection) | |
{ | |
res.StatusCode = (int)HttpStatusCode.Forbidden; | |
res.Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment