private void InitExcludes(Configuration.BasicAuthenticationConfigurationSection basicAuth)
        {
            var excludesAsString = new Dictionary <string, string>();

            this.excludes = new Dictionary <Regex, Regex>();
            var allowAnyRegex = AllowAnyRegex.ToString();

            for (int i = 0; i < basicAuth.Excludes.Count; i++)
            {
                var excludeUrl  = basicAuth.Excludes[i].Url;
                var excludeVerb = basicAuth.Excludes[i].Verb;

                if (string.IsNullOrEmpty(excludeUrl))
                {
                    excludeUrl = allowAnyRegex;
                }
                if (string.IsNullOrEmpty(excludeVerb))
                {
                    excludeVerb = allowAnyRegex;
                }

                excludesAsString[excludeUrl] = excludeVerb;
            }

            foreach (var url in excludesAsString.Keys)
            {
                var urlRegex  = url == allowAnyRegex ? AllowAnyRegex : new Regex(url, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                var verbRegex = excludesAsString[url] == allowAnyRegex ? AllowAnyRegex : new Regex(excludesAsString[url], RegexOptions.Compiled | RegexOptions.IgnoreCase);

                excludes[urlRegex] = verbRegex;
            }
        }
Example #2
0
        private void InitCredentials(Configuration.BasicAuthenticationConfigurationSection basicAuth)
        {
            this.activeUsers = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            for (int i = 0; i < basicAuth.Credentials.Count; i++)
            {
                var credential = basicAuth.Credentials[i];
                this.activeUsers.Add(credential.UserName, credential.Password);
            }
        }
        private void InitCredentials(Configuration.BasicAuthenticationConfigurationSection basicAuth)
        {
            this.activeUsers = new Dictionary <string, string>();

            for (int i = 0; i < basicAuth.Credentials.Count; i++)
            {
                var credential = basicAuth.Credentials[i];
                this.activeUsers.Add(credential.UserName.ToLower(), credential.Password);
            }
        }
        private void InitWhiteList(Configuration.BasicAuthenticationConfigurationSection basicAuth)
        {
            var wl = new List <string>();

            if (basicAuth.WhiteList != null)
            {
                for (int i = 0; i < basicAuth.WhiteList.Count; i++)
                {
                    wl.Add(basicAuth.WhiteList[i].Ip);
                }
            }
            whiteList = wl;
        }