11# Http Auth Module
22This is Simple Http Authentication HttpModule for ASP.NET (MVC).
33- Basic Authentication
4- - Digest Authentication
4+ - Digest Authentication
55- Restrict IP Address (ip4 or ip6)
66- Basic or Digest Authentication don't tounch HttpContext.Current.User.
77- Ignore Path Regex.(specified path skip authentication)
@@ -15,13 +15,18 @@ https://www.nuget.org/packages/HttpAuthModule/
1515
1616```
1717PM> Install-Package HttpAuthModule
18- ```
18+ ```
1919
2020After Getting, configure Web.config file.
2121It's all you do for using HttpAuthModule.
2222
2323# Configuration
24- Modify Web.config file.
24+ Modify Web.config file.
25+
26+ Configure on httpAuthModule section or appSettings section.
27+ ** appSetting section is prior to httpAuthModule section. **
28+
29+ ## configure on httpAuthModule section
2530
2631``` XML
2732<configuration >
@@ -51,12 +56,12 @@ Modify Web.config file.
5156 - 127.0.0.1 (equals to 127.0.0.1/32)
5257 - 2001:0db8:bd05:01d2:288a:1fc0:0001:0000/16
5358 - ::1 (equals to ::1/128)
54-
59+
5560 e.g) 127.0.0.1;182.249.0.0/16;182.248.112.128/26;::1 -->
5661 <add key =" RestrictIPAddresses" value =" 127.0.0.1;::1" />
5762 <!-- [optional] If set, specified pattern url request skip http auth and IP Restriction. -->
5863 <add key =" IgnorePathRegex" value =" ^/Home/Ignore$|^/Ignore\.aspx$" />
59- <!--
64+ <!--
6065 [optional] If set,specified IPs requests skip http auth Restriction.
6166 value format is same as 'RestrictIPAddresses'
6267 -->
@@ -66,18 +71,41 @@ Modify Web.config file.
6671 <system .webServer>
6772 <modules >
6873 <add type =" HttpAuthModule.HttpAuthModule" name =" HttpAuthModule" />
69- </modules >
74+ </modules >
7075 </system .webServer>
7176</configuration >
7277```
7378
79+ ## configure on appSettings section
7480
75- If you apply only http requests for ASP.NET Resource(default.aspx /controller/action, but image.gif, index.html), change "modules -> add" element.
81+ ``` XML
82+ <configuration >
83+ <appSettings >
84+ <add key =" HttpAuthModule.AuthMode" value =" Digest" />
85+ <add key =" HttpAuthModule.Realm" value =" SecureZone" />
86+ <add key =" HttpAuthModule.Credentials" value =" hoge:hogepass;foo:foopass;" />
87+ <add key =" HttpAuthModule.DigestNonceValidDuration" value =" 120" />
88+ <add key =" HttpAuthModule.DigestNonceSalt" value =" uht9987bbbSAX" />
89+ <add key =" HttpAuthModule.RestrictIPAddresses" value =" 127.0.0.1;::1" />
90+ <add key =" HttpAuthModule.IgnorePathRegex" value =" ^/Home/Ignore$|^/Ignore\.aspx$" />
91+ <add key =" HttpAuthModule.RestrictIPAddresses" value =" 127.0.0.1;::1" />
92+ </appSettings >
93+
94+ <system .webServer>
95+ <modules >
96+ <add type =" HttpAuthModule.HttpAuthModule" name =" HttpAuthModule" />
97+ </modules >
98+ </system .webServer>
99+ </configuration >
100+ ```
101+
102+
103+ If you apply only http requests for ASP.NET Resource(default.aspx /controller/action, but image.gif, index.html), change "modules -> add" element.
76104``` XML
77105 <modules >
78106 <!-- add preCondition="managedHandler" -->
79107 <add type =" HttpAuthModule.HttpAuthModule" name =" HttpAuthModule" preCondition =" managedHandler" />
80- </modules >
108+ </modules >
81109```
82110
83111# Disable HttpAuthModule by AppSettings
@@ -98,4 +126,3 @@ if you add HttpAuthModuleEnabled=false to appSettings, HttpAUthModule doesn't ru
98126HttpAuthModule.dll and Web.config is here, https://github.com/nabehiro/HttpAuthModule/PHPResources
99127
100128please see detail, http://blogs.gine.jp/taka/archives/2753
101-
0 commit comments