Created
October 25, 2013 23:50
-
-
Save priore/7163587 to your computer and use it in GitHub Desktop.
Mashape secret code verification (upd)
This file contains hidden or 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
| // updated: 03-04-2013 | |
| // | |
| using System.Web; | |
| public static class Mashape // www.mashape.com/priore | |
| { | |
| private static string[] VALID_MASHAPE_ADDR = new string[] { "23.21.64.131", "23.21.68.63", "23.23.86.71", "23.23.87.232", "23.23.103.203", "23.23.103.204", "23.23.103.207", "23.23.103.212", "23.23.103.218", "50.17.255.165" }; | |
| public static bool IsValidSecretCode(string secret_code) | |
| { | |
| HttpContext context = HttpContext.Current; | |
| if (context == null) | |
| throw new ArgumentException("Invalid HTTP Context!"); | |
| return IsValidSecretCode(secret_code, context); | |
| } | |
| public static bool IsValidSecretCode(string secret_code, HttpContext context) | |
| { | |
| string keySecret = "HTTP_X_MASHAPE_PROXY_SECRET:" + secret_code; | |
| string tagSubscr = "HTTP_X_MASHAPE_SUBSCRIPTION:"; | |
| HttpRequest request = context.Request; | |
| string remote_addr = request.ServerVariables["REMOTE_ADDR"]; | |
| string all_http = request.ServerVariables["ALL_HTTP"]; | |
| return VALID_MASHAPE_ADDR.Contains(remote_addr) && all_http.Contains(keySecret) && all_http.Contains(tagSubscr); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment