<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.nginx.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.nginx.org/index.php?title=HttpAuthDigestModule&amp;feed=atom&amp;action=history</id>
		<title>HttpAuthDigestModule - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.nginx.org/index.php?title=HttpAuthDigestModule&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://wiki.nginx.org/index.php?title=HttpAuthDigestModule&amp;action=history"/>
		<updated>2013-05-22T00:07:01Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.19.0</generator>

	<entry>
		<id>http://wiki.nginx.org/index.php?title=HttpAuthDigestModule&amp;diff=1045&amp;oldid=prev</id>
		<title>Cds: rewordings</title>
		<link rel="alternate" type="text/html" href="http://wiki.nginx.org/index.php?title=HttpAuthDigestModule&amp;diff=1045&amp;oldid=prev"/>
				<updated>2011-11-26T02:31:48Z</updated>
		
		<summary type="html">&lt;p&gt;rewordings&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Name =&lt;br /&gt;
&lt;br /&gt;
'''ngx_http_auth_digest''' - HTTP Digest Authentication support for Nginx.&lt;br /&gt;
&lt;br /&gt;
''This module is not distributed with the Nginx source.'' See the  [https://github.com/samizdatco/nginx-http-auth-digest/blob/master/readme.rst installation instructions].&lt;br /&gt;
&lt;br /&gt;
= Status =&lt;br /&gt;
&lt;br /&gt;
The module is feature-complete with respect to the RFC but is in need of broader testing before it can be considered secure enough for use in production. See the [https://github.com/samizdatco/nginx-http-auth-digest/blob/master/bugs.txt &amp;lt;code&amp;gt;bugs.txt&amp;lt;/code&amp;gt;] file and the github [https://github.com/samizdatco/nginx-http-auth-digest/issues issue tracker] for the current set of caveats.&lt;br /&gt;
&lt;br /&gt;
= Synopsis =&lt;br /&gt;
&lt;br /&gt;
You can limit access to a directory tree by adding the following lines into&lt;br /&gt;
a ''server'' section in your Nginx configuration file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi lang=&amp;quot;nginx&amp;quot;&amp;gt;&lt;br /&gt;
  auth_digest_user_file /opt/httpd/conf/passwd.digest; # a file created with htdigest&lt;br /&gt;
  location /private{&lt;br /&gt;
    auth_digest 'this is not for you'; # set the realm for this location block&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other directives control the lifespan defaults for the authentication session. The &lt;br /&gt;
following is equivalent to the previous example but demonstrates all the directives:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi lang=&amp;quot;nginx&amp;quot;&amp;gt;&lt;br /&gt;
  auth_digest_user_file /opt/httpd/conf/passwd.digest;&lt;br /&gt;
  auth_digest_shm_size 4m;   # the storage space allocated for tracking active sessions&lt;br /&gt;
&lt;br /&gt;
  location /private {&lt;br /&gt;
    auth_digest 'this is not for you';&lt;br /&gt;
    auth_digest_timeout 60s; # allow users to wait 1 minute between receiving the&lt;br /&gt;
                             # challenge and hitting send in the browser dialog box&lt;br /&gt;
    auth_digest_expires 10s; # after a successful challenge/response, let the client&lt;br /&gt;
                             # continue to use the same nonce for additional requests&lt;br /&gt;
                             # for 10 seconds before generating a new challenge&lt;br /&gt;
    auth_digest_replays 20;  # also generate a new challenge if the client uses the&lt;br /&gt;
                             # same nonce more than 20 times before the expire time limit&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adding digest authentication to a location will affect any uris that match that block. To&lt;br /&gt;
disable authentication for specific sub-branches off a uri, set &amp;lt;code&amp;gt;auth_digest&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;off&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi lang=&amp;quot;nginx&amp;quot;&amp;gt;&lt;br /&gt;
  location / {&lt;br /&gt;
    auth_digest 'this is not for you';&lt;br /&gt;
    location /pub {&lt;br /&gt;
      auth_digest off; # this sub-tree will be accessible without authentication&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Directives =&lt;br /&gt;
&lt;br /&gt;
== auth_digest ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax:'''  auth_digest [''realm-name'' | &amp;lt;code&amp;gt;off&amp;lt;/code&amp;gt; ]&lt;br /&gt;
&lt;br /&gt;
'''Default:''' &amp;lt;code&amp;gt;off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Context:''' ''server, location''&lt;br /&gt;
&lt;br /&gt;
Enable or disable digest authentication for a server or location block. The realm name&lt;br /&gt;
should correspond to a realm used in the user file. Any user within that realm will be&lt;br /&gt;
able to access files after authenticating.&lt;br /&gt;
&lt;br /&gt;
To selectively disable authentication within a protected uri hierarchy, set &amp;lt;code&amp;gt;auth_digest&amp;lt;/code&amp;gt; &lt;br /&gt;
to “&amp;lt;code&amp;gt;off&amp;lt;/code&amp;gt;” within a more-specific location block (see example).&lt;br /&gt;
== auth_digest_user_file ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' auth_digest_user_file ''/path/to/passwd/file''&lt;br /&gt;
&lt;br /&gt;
'''Default:''' ''none''&lt;br /&gt;
&lt;br /&gt;
'''Context:''' ''server, location''&lt;br /&gt;
&lt;br /&gt;
The password file should be of the form created by the apache &amp;lt;code&amp;gt;htdigest&amp;lt;/code&amp;gt; command (or the &lt;br /&gt;
included &amp;lt;code&amp;gt;[https://github.com/samizdatco/nginx-http-auth-digest/blob/master/htdigest.py htdigest.py]&amp;lt;/code&amp;gt; script). Each line of the file is a colon-separated list composed &lt;br /&gt;
of a username, realm, and md5 hash combining name, realm, and password. For example:&lt;br /&gt;
&lt;br /&gt;
  joi:enfield:ef25e85b34208c246cfd09ab76b01db7  &lt;br /&gt;
== auth_digest_timeout ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' auth_digest_timeout ''delay-time''&lt;br /&gt;
&lt;br /&gt;
'''Default:''' &amp;lt;code&amp;gt;60s&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Context:''' ''server, location''&lt;br /&gt;
&lt;br /&gt;
When a client first requests a protected page, the server returns a 401 status code along with&lt;br /&gt;
a challenge in the &amp;lt;code&amp;gt;WWW-Authenticate&amp;lt;/code&amp;gt; header.&lt;br /&gt;
&lt;br /&gt;
At this point most browsers will present a dialog box to the user prompting them to log in. This&lt;br /&gt;
directive defines how long challenges will remain valid. If the user waits longer than this time&lt;br /&gt;
before submitting their name and password, the challenge will be considered ‘stale’ and they will&lt;br /&gt;
be prompted to log in again.&lt;br /&gt;
== auth_digest_expires ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' auth_digest_expires ''lifetime-in-seconds''&lt;br /&gt;
&lt;br /&gt;
'''Default:''' &amp;lt;code&amp;gt;10s&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Context:''' ''server, location''&lt;br /&gt;
&lt;br /&gt;
Once a digest challenge has been successfully answered by the client, subsequent requests &lt;br /&gt;
will attempt to re-use the ‘nonce’ value from the original challenge. To complicate MitM&lt;br /&gt;
attacks, it's best to limit the number of times a cached nonce will be accepted. This&lt;br /&gt;
directive sets the duration for this re-use period after the first successful authentication.&lt;br /&gt;
== auth_digest_replays ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' auth_digest_replays ''number-of-uses''&lt;br /&gt;
&lt;br /&gt;
'''Default:''' &amp;lt;code&amp;gt;20&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Context:''' ''server, location''&lt;br /&gt;
&lt;br /&gt;
Nonce re-use should also be limited to a fixed number of requests. Note that increasing this&lt;br /&gt;
value will cause a proportional increase in memory usage and the shm_size may have to be&lt;br /&gt;
adjusted to keep up with heavy traffic within the digest-protected location blocks.&lt;br /&gt;
== auth_digest_shm_size ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' auth_digest_shm_size ''size-in-bytes''&lt;br /&gt;
&lt;br /&gt;
'''Default:''' &amp;lt;code&amp;gt;4096k&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Context:''' ''server''&lt;br /&gt;
&lt;br /&gt;
The module maintains a fixed-size cache of active digest sessions to save state between &lt;br /&gt;
authenticated requests. Once this cache is full, no further authentication will be possible&lt;br /&gt;
until active sessions expire. &lt;br /&gt;
&lt;br /&gt;
As a result, choosing the proper size is a little tricky since it depends upon the values set in&lt;br /&gt;
the expiration-related directives. Each stored challenge takes up &amp;lt;code&amp;gt;48 + ceil(auth_digest_replays/8)&amp;lt;/code&amp;gt; bytes&lt;br /&gt;
and will live for up to &amp;lt;code&amp;gt;auth_digest_timeout + auth_digest_expires&amp;lt;/code&amp;gt; seconds. When using the&lt;br /&gt;
default module settings this translates into allowing around 82k non-replay requests every 70&lt;br /&gt;
seconds.&lt;br /&gt;
&lt;br /&gt;
= Source Repository =&lt;br /&gt;
&lt;br /&gt;
Available on github at [https://github.com/samizdatco/nginx-http-auth-digest samizdatco/nginx-http-auth-digest].&lt;br /&gt;
&lt;br /&gt;
= Author =&lt;br /&gt;
&lt;br /&gt;
Christian Swinehart / [http://samizdat.cc Samizdat Drafting Co.]&lt;br /&gt;
&lt;br /&gt;
= Copyright &amp;amp; License =&lt;br /&gt;
&lt;br /&gt;
The basic request-handling and password-file-parsing is based on the &amp;lt;code&amp;gt;ngx_http_auth_basic&amp;lt;/code&amp;gt; module in the Nginx 1.0.8 sources. The original code is copyright Igor Sysoev.&lt;br /&gt;
&lt;br /&gt;
Copyright (c) 2011, Christian Swinehart&lt;br /&gt;
&lt;br /&gt;
This module is licensed under the terms of the [https://github.com/samizdatco/nginx-http-auth-digest/blob/master/LICENSE BSD license].&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* The [http://www.ietf.org/rfc/rfc2617.txt RFC 2617] definition of basic and digest authentication.&lt;br /&gt;
* Shane Holloway's werkzeug [https://bitbucket.org/shanewholloway/werkzeug-main/src/tip/werkzeug/contrib/authdigest.py module] which was used as a reference implementation.&lt;/div&gt;</summary>
		<author><name>Cds</name></author>	</entry>

	</feed>