public void CreateSdkEventWithoutUserIdThrowTest()
        {
            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder().Build();
            var e       = new EventOptions(EventTypes.LOG_IN.ToString());

            var _ = new SdkEvent(e, options);
        }
        public void CreateSdkEventWithoutEventTypeThrowTest()
        {
            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder().Build();
            var e       = new EventOptions("");

            var _ = new SdkEvent(e, options);
        }
        public void ExtractIpUsingXForwardedForHeaderMultipleIp()
        {
            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder().Build();

            var headers = new WebHeaderCollection
            {
                { "x-forwarded-for", "141.246.115.116, 203.0.113.1, 12.34.56.3" }
            };

            var uri     = new Uri("http://www.securenative.com/login");
            var request = WebRequest.Create(uri);

            request.Headers = headers;

            var clientIp = RequestUtils.GetClientIpFromRequest((HttpWebRequest)request, options);

            Assert.AreEqual("141.246.115.116", clientIp);
        }
        public void ExtractIpUsingXForwardedForHeaderIpv6()
        {
            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder().Build();

            var headers = new WebHeaderCollection
            {
                { "x-forwarded-for", "f71f:5bf9:25ff:1883:a8c4:eeff:7b80:aa2d" }
            };

            var uri     = new Uri("http://www.securenative.com/login");
            var request = WebRequest.Create(uri);

            request.Headers = headers;

            var clientIp = RequestUtils.GetClientIpFromRequest((HttpWebRequest)request, options);

            Assert.AreEqual("f71f:5bf9:25ff:1883:a8c4:eeff:7b80:aa2d", clientIp);
        }
Esempio n. 5
0
        public static Client Init(string value)
        {
            if (value.Contains("/") || value.Contains("\""))
            {
                var secureNativeOptions = ConfigurationManager.LoadConfig(value);
                return(Init(secureNativeOptions));
            }
            else
            {
                if (string.IsNullOrEmpty(value))
                {
                    throw new SecureNativeConfigException("You must pass your SecureNative api key");
                }

                var builder             = SecureNativeConfigurationBuilder.DefaultConfigBuilder();
                var secureNativeOptions = builder.WithApiKey(value).Build();
                return(Init(secureNativeOptions));
            }
        }
        public void ExtractRequestWithProxyHeadersMultipleIps()
        {
            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder()
                          .WithProxyHeaders(new[] { "CF-Connecting-IP" }).Build();

            var headers = new WebHeaderCollection
            {
                { "CF-Connecting-IP", "141.246.115.116, 203.0.113.1, 12.34.56.3" }
            };

            var uri     = new Uri("http://www.securenative.com/login");
            var request = WebRequest.Create(uri);

            request.Headers = headers;

            var clientIp = RequestUtils.GetClientIpFromRequest((HttpWebRequest)request, options);

            Assert.AreEqual("141.246.115.116", clientIp);
        }
        public void ExtractIpUsingPriorityWithoutXForwardedFor()
        {
            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder().Build();

            var headers = new WebHeaderCollection
            {
                { "x-real-ip", "98.51.100.101" },
                { "x-client-ip", "203.0.113.1, 141.246.115.116, 12.34.56.3" }
            };

            var uri     = new Uri("http://www.securenative.com/login");
            var request = WebRequest.Create(uri);

            request.Headers = headers;

            var clientIp = RequestUtils.GetClientIpFromRequest((HttpWebRequest)request, options);

            Assert.AreEqual("203.0.113.1", clientIp);
        }
        public void ExtractPiiDataFromRegexPattern()
        {
            var headers = new WebHeaderCollection
            {
                { "Host", "net.example.com" },
                { "User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)" },
                { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" },
                { "Accept-Language", "en-us,en;q=0.5" },
                { "Accept-Encoding", "gzip,deflate" },
                { "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7" },
                { "Keep-Alive", "300" },
                { "Connection", "keep-alive" },
                { "Cookie", "PHPSESSID=r2t5uvjq435r4q7ib3vtdjq120" },
                { "Pragma", "no-cache" },
                { "Cache-Control", "no-cache" },
                { "http_auth_authorization", "ylSkZIjbdWybfs4fUQe9BqP0LH5Z" },
                { "http_auth_access_token", "ylSkZIjbdWybfs4fUQe9BqP0LH5Z" },
                { "http_auth_apikey", "ylSkZIjbdWybfs4fUQe9BqP0LH5Z" },
                { "http_auth_password", "ylSkZIjbdWybfs4fUQe9BqP0LH5Z" },
                { "http_auth_passwd", "ylSkZIjbdWybfs4fUQe9BqP0LH5Z" },
                { "http_auth_secret", "ylSkZIjbdWybfs4fUQe9BqP0LH5Z" },
                { "http_auth_api_key", "ylSkZIjbdWybfs4fUQe9BqP0LH5Z" },
            };

            var uri     = new Uri("http://www.securenative.com/login");
            var request = WebRequest.Create(uri);

            request.Headers = headers;

            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder().Build();

            options.SetPiiRegexPattern(@"((?i)(http_auth_)(\w+)?)");
            var h = RequestUtils.GetHeadersFromRequest((HttpWebRequest)request, options);

            Assert.IsFalse(h.Keys.Contains("http_auth_authorization"));
            Assert.IsFalse(h.Keys.Contains("http_auth_access_token"));
            Assert.IsFalse(h.Keys.Contains("http_auth_apikey"));
            Assert.IsFalse(h.Keys.Contains("http_auth_password"));
            Assert.IsFalse(h.Keys.Contains("http_auth_passwd"));
            Assert.IsFalse(h.Keys.Contains("http_auth_secret"));
            Assert.IsFalse(h.Keys.Contains("http_auth_api_key"));
        }
Esempio n. 9
0
 public static SecureNativeConfigurationBuilder ConfigBuilder()
 {
     return(SecureNativeConfigurationBuilder.DefaultConfigBuilder());
 }