This file is indexed.

/usr/share/doc/python-paste/docs/modules/auth.cookie.html is in python-paste 1.7.5.1-4ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>paste.auth.cookie – Cookie-based authentication &mdash; Paste v1.7.5.1 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.7.5.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="Paste v1.7.5.1 documentation" href="../index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../index.html">Paste v1.7.5.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-paste.auth.cookie">
<span id="paste-auth-cookie-cookie-based-authentication"></span><h1><a class="reference internal" href="#module-paste.auth.cookie" title="paste.auth.cookie"><tt class="xref py py-mod docutils literal"><span class="pre">paste.auth.cookie</span></tt></a> &#8211; Cookie-based authentication<a class="headerlink" href="#module-paste.auth.cookie" title="Permalink to this headline"></a></h1>
<p>Cookie &#8220;Saved&#8221; Authentication</p>
<p>This authentication middleware saves the current REMOTE_USER,
REMOTE_SESSION, and any other environment variables specified in a
cookie so that it can be retrieved during the next request without
requiring re-authentication. This uses a session cookie on the client
side (so it goes away when the user closes their window) and does
server-side expiration.</p>
<p>Following is a very simple example where a form is presented asking for
a user name (no actual checking), and dummy session identifier (perhaps
corresponding to a database session id) is stored in the cookie.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">paste.httpserver</span> <span class="kn">import</span> <span class="n">serve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">paste.fileapp</span> <span class="kn">import</span> <span class="n">DataApp</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">paste.httpexceptions</span> <span class="kn">import</span> <span class="o">*</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">paste.auth.cookie</span> <span class="kn">import</span> <span class="n">AuthCookieHandler</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">paste.wsgilib</span> <span class="kn">import</span> <span class="n">parse_querystring</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">testapp</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">user</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">parse_querystring</span><span class="p">(</span><span class="n">environ</span><span class="p">))</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;user&#39;</span><span class="p">,</span><span class="s">&#39;&#39;</span><span class="p">)</span>
<span class="gp">... </span>    <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
<span class="gp">... </span>        <span class="n">environ</span><span class="p">[</span><span class="s">&#39;REMOTE_USER&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">user</span>
<span class="gp">... </span>        <span class="n">environ</span><span class="p">[</span><span class="s">&#39;REMOTE_SESSION&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;a-session-id&#39;</span>
<span class="gp">... </span>    <span class="k">if</span> <span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;REMOTE_USER&#39;</span><span class="p">):</span>
<span class="gp">... </span>        <span class="n">page</span> <span class="o">=</span> <span class="s">&#39;&lt;html&gt;&lt;body&gt;Welcome </span><span class="si">%s</span><span class="s"> (</span><span class="si">%s</span><span class="s">)&lt;/body&gt;&lt;/html&gt;&#39;</span>
<span class="gp">... </span>        <span class="n">page</span> <span class="o">%=</span> <span class="p">(</span><span class="n">environ</span><span class="p">[</span><span class="s">&#39;REMOTE_USER&#39;</span><span class="p">],</span> <span class="n">environ</span><span class="p">[</span><span class="s">&#39;REMOTE_SESSION&#39;</span><span class="p">])</span>
<span class="gp">... </span>    <span class="k">else</span><span class="p">:</span>
<span class="gp">... </span>        <span class="n">page</span> <span class="o">=</span> <span class="p">(</span><span class="s">&#39;&lt;html&gt;&lt;body&gt;&lt;form&gt;&lt;input name=&quot;user&quot; /&gt;&#39;</span>
<span class="gp">... </span>                <span class="s">&#39;&lt;input type=&quot;submit&quot; /&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;&#39;</span><span class="p">)</span>
<span class="gp">... </span>    <span class="k">return</span> <span class="n">DataApp</span><span class="p">(</span><span class="n">page</span><span class="p">,</span> <span class="n">content_type</span><span class="o">=</span><span class="s">&quot;text/html&quot;</span><span class="p">)(</span>
<span class="gp">... </span>                   <span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">serve</span><span class="p">(</span><span class="n">AuthCookieHandler</span><span class="p">(</span><span class="n">testapp</span><span class="p">))</span>
<span class="go">serving on...</span>
</pre></div>
</div>
<div class="section" id="module-contents">
<h2>Module Contents<a class="headerlink" href="#module-contents" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="paste.auth.cookie.AuthCookieSigner">
<em class="property">class </em><tt class="descclassname">paste.auth.cookie.</tt><tt class="descname">AuthCookieSigner</tt><big>(</big><em>secret=None</em>, <em>timeout=None</em>, <em>maxlen=None</em><big>)</big><a class="headerlink" href="#paste.auth.cookie.AuthCookieSigner" title="Permalink to this definition"></a></dt>
<dd><p>save/restore <tt class="docutils literal"><span class="pre">environ</span></tt> entries via digially signed cookie</p>
<p>This class converts content into a timed and digitally signed
cookie, as well as having the facility to reverse this procedure.
If the cookie, after the content is encoded and signed exceeds the
maximum length (4096), then CookieTooLarge exception is raised.</p>
<p>The timeout of the cookie is handled on the server side for a few
reasons.  First, if a &#8216;Expires&#8217; directive is added to a cookie, then
the cookie becomes persistent (lasting even after the browser window
has closed). Second, the user&#8217;s clock may be wrong (perhaps
intentionally). The timeout is specified in minutes; and expiration
date returned is rounded to one second.</p>
<p>Constructor Arguments:</p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">secret</span></tt></p>
<blockquote>
<div>This is a secret key if you want to syncronize your keys so
that the cookie will be good across a cluster of computers.
It is recommended via the HMAC specification (RFC 2104) that
the secret key be 64 bytes since this is the block size of
the hashing.  If you do not provide a secret key, a random
one is generated each time you create the handler; this
should be sufficient for most cases.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">timeout</span></tt></p>
<blockquote>
<div>This is the time (in minutes) from which the cookie is set
to expire.  Note that on each request a new (replacement)
cookie is sent, hence this is effectively a session timeout
parameter for your entire cluster.  If you do not provide a
timeout, it is set at 30 minutes.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">maxlen</span></tt></p>
<blockquote>
<div>This is the maximum size of the <em>signed</em> cookie; hence the
actual content signed will be somewhat less.  If the cookie
goes over this size, a <tt class="docutils literal"><span class="pre">CookieTooLarge</span></tt> exception is
raised so that unexpected handling of cookies on the client
side are avoided.  By default this is set at 4k (4096 bytes),
which is the standard cookie size limit.</div></blockquote>
</div></blockquote>
</dd></dl>

<dl class="class">
<dt id="paste.auth.cookie.AuthCookieHandler">
<em class="property">class </em><tt class="descclassname">paste.auth.cookie.</tt><tt class="descname">AuthCookieHandler</tt><big>(</big><em>application</em>, <em>cookie_name=None</em>, <em>scanlist=None</em>, <em>signer=None</em>, <em>secret=None</em>, <em>timeout=None</em>, <em>maxlen=None</em><big>)</big><a class="headerlink" href="#paste.auth.cookie.AuthCookieHandler" title="Permalink to this definition"></a></dt>
<dd><p>the actual handler that should be put in your middleware stack</p>
<p>This middleware uses cookies to stash-away a previously authenticated
user (and perhaps other variables) so that re-authentication is not
needed.  This does not implement sessions; and therefore N servers
can be syncronized to accept the same saved authentication if they
all use the same cookie_name and secret.</p>
<p>By default, this handler scans the <cite>environ</cite> for the REMOTE_USER
and REMOTE_SESSION key; if found, it is stored. It can be
configured to scan other <cite>environ</cite> keys as well &#8211; but be careful
not to exceed 2-3k (so that the encoded and signed cookie does not
exceed 4k). You can ask it to handle other environment variables
by doing:</p>
<blockquote>
<div><tt class="docutils literal"><span class="pre">environ['paste.auth.cookie'].append('your.environ.variable')</span></tt></div></blockquote>
<p>Constructor Arguments:</p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">application</span></tt></p>
<blockquote>
<div>This is the wrapped application which will have access to
the <tt class="docutils literal"><span class="pre">environ['REMOTE_USER']</span></tt> restored by this middleware.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">cookie_name</span></tt></p>
<blockquote>
<div>The name of the cookie used to store this content, by default
it is <tt class="docutils literal"><span class="pre">PASTE_AUTH_COOKIE</span></tt>.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">scanlist</span></tt></p>
<blockquote>
<div>This is the initial set of <tt class="docutils literal"><span class="pre">environ</span></tt> keys to
save/restore to the signed cookie.  By default is consists
only of <tt class="docutils literal"><span class="pre">REMOTE_USER</span></tt> and <tt class="docutils literal"><span class="pre">REMOTE_SESSION</span></tt>; any tuple
or list of environment keys will work.  However, be
careful, as the total saved size is limited to around 3k.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">signer</span></tt></p>
<blockquote>
<div>This is the signer object used to create the actual cookie
values, by default, it is <tt class="docutils literal"><span class="pre">AuthCookieSigner</span></tt> and is passed
the remaining arguments to this function: <tt class="docutils literal"><span class="pre">secret</span></tt>,
<tt class="docutils literal"><span class="pre">timeout</span></tt>, and <tt class="docutils literal"><span class="pre">maxlen</span></tt>.</div></blockquote>
</div></blockquote>
<p>At this time, each cookie is individually signed.  To store more
than the 4k of data; it is possible to sub-class this object to
provide different <tt class="docutils literal"><span class="pre">environ_name</span></tt> and <tt class="docutils literal"><span class="pre">cookie_name</span></tt></p>
</dd></dl>

<dl class="class">
<dt id="paste.auth.cookie.AuthCookieEnviron">
<em class="property">class </em><tt class="descclassname">paste.auth.cookie.</tt><tt class="descname">AuthCookieEnviron</tt><big>(</big><em>handler</em>, <em>scanlist</em><big>)</big><a class="headerlink" href="#paste.auth.cookie.AuthCookieEnviron" title="Permalink to this definition"></a></dt>
<dd><p>a list of environment keys to be saved via cookie</p>
<p>An instance of this object, found at <tt class="docutils literal"><span class="pre">environ['paste.auth.cookie']</span></tt>
lists the <cite>environ</cite> keys that were restored from or will be added
to the digially signed cookie.  This object can be accessed from an
<cite>environ</cite> variable by using this module&#8217;s name.</p>
</dd></dl>

<dl class="function">
<dt id="paste.auth.cookie.make_auth_cookie">
<tt class="descclassname">paste.auth.cookie.</tt><tt class="descname">make_auth_cookie</tt><big>(</big><em>app</em>, <em>global_conf</em>, <em>cookie_name='PASTE_AUTH_COOKIE'</em>, <em>scanlist=('REMOTE_USER'</em>, <em>'REMOTE_SESSION')</em>, <em>secret=None</em>, <em>timeout=30</em>, <em>maxlen=4096</em><big>)</big><a class="headerlink" href="#paste.auth.cookie.make_auth_cookie" title="Permalink to this definition"></a></dt>
<dd><p>This middleware uses cookies to stash-away a previously
authenticated user (and perhaps other variables) so that
re-authentication is not needed.  This does not implement
sessions; and therefore N servers can be syncronized to accept the
same saved authentication if they all use the same cookie_name and
secret.</p>
<p>By default, this handler scans the <cite>environ</cite> for the REMOTE_USER
and REMOTE_SESSION key; if found, it is stored. It can be
configured to scan other <cite>environ</cite> keys as well &#8211; but be careful
not to exceed 2-3k (so that the encoded and signed cookie does not
exceed 4k). You can ask it to handle other environment variables
by doing:</p>
<blockquote>
<div><tt class="docutils literal"><span class="pre">environ['paste.auth.cookie'].append('your.environ.variable')</span></tt></div></blockquote>
<p>Configuration:</p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">cookie_name</span></tt></p>
<blockquote>
<div>The name of the cookie used to store this content, by
default it is <tt class="docutils literal"><span class="pre">PASTE_AUTH_COOKIE</span></tt>.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">scanlist</span></tt></p>
<blockquote>
<div>This is the initial set of <tt class="docutils literal"><span class="pre">environ</span></tt> keys to
save/restore to the signed cookie.  By default is consists
only of <tt class="docutils literal"><span class="pre">REMOTE_USER</span></tt> and <tt class="docutils literal"><span class="pre">REMOTE_SESSION</span></tt>; any
space-separated list of environment keys will work.
However, be careful, as the total saved size is limited to
around 3k.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">secret</span></tt></p>
<blockquote>
<div>The secret that will be used to sign the cookies.  If you
don&#8217;t provide one (and none is set globally) then a random
secret will be created.  Each time the server is restarted
a new secret will then be created and all cookies will
become invalid!  This can be any string value.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">timeout</span></tt></p>
<blockquote>
<div>The time to keep the cookie, expressed in minutes.  This
is handled server-side, so a new cookie with a new timeout
is added to every response.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">maxlen</span></tt></p>
<blockquote>
<div>The maximum length of the cookie that is sent (default 4k,
which is a typical browser maximum)</div></blockquote>
</div></blockquote>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><tt class="docutils literal"><span class="pre">paste.auth.cookie</span></tt> &#8211; Cookie-based authentication</a><ul>
<li><a class="reference internal" href="#module-contents">Module Contents</a></li>
</ul>
</li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/modules/auth.cookie.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../index.html">Paste v1.7.5.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2008, Ian Bicking.
      Last updated on Dec 31, 2011.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
    </div>
  </body>
</html>