您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

246 行
13 KiB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>auth — Authentication &mdash; Documentation</title>
  7. <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '',
  12. VERSION: '',
  13. COLLAPSE_MODINDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="_static/jquery.js"></script>
  19. <script type="text/javascript" src="_static/doctools.js"></script>
  20. <link rel="top" title="Documentation" href="index.html" />
  21. <link rel="up" title="Server Side Internals" href="server_side_internals.html" />
  22. <link rel="next" title="webnotes — Webnotes Module" href="webnotes.html" />
  23. <link rel="prev" title="Server Side Internals" href="server_side_internals.html" />
  24. </head>
  25. <body>
  26. <div style="background-color: #FFF; text-align: left; padding: 8px 0px"><img src="_static/banner300910.gif"></div>
  27. <div class="related">
  28. <h3>Navigation</h3>
  29. <ul>
  30. <li class="right" style="margin-right: 10px">
  31. <a href="genindex.html" title="General Index"
  32. accesskey="I">index</a></li>
  33. <li class="right" >
  34. <a href="modindex.html" title="Global Module Index"
  35. accesskey="M">modules</a> |</li>
  36. <li class="right" >
  37. <a href="webnotes.html" title="webnotes — Webnotes Module"
  38. accesskey="N">next</a> |</li>
  39. <li class="right" >
  40. <a href="server_side_internals.html" title="Server Side Internals"
  41. accesskey="P">previous</a> |</li>
  42. <li><a href="index.html">Documentation</a> &raquo;</li>
  43. <li><a href="server_side_api.html" >3. Server Side API</a> &raquo;</li>
  44. <li><a href="server_side_internals.html" accesskey="U">Server Side Internals</a> &raquo;</li>
  45. </ul>
  46. </div>
  47. <div class="sphinxsidebar">
  48. <div class="sphinxsidebarwrapper">
  49. <h3><a href="index.html">Table Of Contents</a></h3>
  50. <ul>
  51. <li><a class="reference external" href=""><tt class="docutils literal"><span class="pre">auth</span></tt> &#8212; Authentication</a><ul>
  52. <li><a class="reference external" href="#authentication-object">Authentication object</a></li>
  53. </ul>
  54. </li>
  55. </ul>
  56. <h4>Previous topic</h4>
  57. <p class="topless"><a href="server_side_internals.html"
  58. title="previous chapter">Server Side Internals</a></p>
  59. <h4>Next topic</h4>
  60. <p class="topless"><a href="webnotes.html"
  61. title="next chapter"><tt class="docutils literal"><span class="pre">webnotes</span></tt> &#8212; Webnotes Module</a></p>
  62. <h3>This Page</h3>
  63. <ul class="this-page-menu">
  64. <li><a href="_sources/auth.txt"
  65. rel="nofollow">Show Source</a></li>
  66. </ul>
  67. <div id="searchbox" style="display: none">
  68. <h3>Quick search</h3>
  69. <form class="search" action="search.html" method="get">
  70. <input type="text" name="q" size="18" />
  71. <input type="submit" value="Go" />
  72. <input type="hidden" name="check_keywords" value="yes" />
  73. <input type="hidden" name="area" value="default" />
  74. </form>
  75. <p class="searchtip" style="font-size: 90%">
  76. Enter search terms or a module, class or function name.
  77. </p>
  78. </div>
  79. <script type="text/javascript">$('#searchbox').show(0);</script>
  80. </div>
  81. </div>
  82. <div class="document">
  83. <div class="documentwrapper">
  84. <div class="bodywrapper">
  85. <div class="body">
  86. <div class="section" id="module-auth">
  87. <h1><tt class="xref docutils literal"><span class="pre">auth</span></tt> &#8212; Authentication<a class="headerlink" href="#module-auth" title="Permalink to this headline">¶</a></h1>
  88. <div class="section" id="authentication-object">
  89. <h2>Authentication object<a class="headerlink" href="#authentication-object" title="Permalink to this headline">¶</a></h2>
  90. <dl class="class">
  91. <dt id="auth.Authentication">
  92. <em class="property">class </em><tt class="descclassname">auth.</tt><tt class="descname">Authentication</tt><big>(</big><em>self</em>, <em>form</em>, <em>in_cookies</em>, <em>out_cookies</em>, <em>out</em><big>)</big><a class="headerlink" href="#auth.Authentication" title="Permalink to this definition">¶</a></dt>
  93. <dd><p>A new Authenticate object is created at the beginning of any request. It will manage login, session and
  94. cookies. <a href="#id1"><span class="problematic" id="id2">:method:`update`</span></a> must be called at the end of the request to update cookies and
  95. session.</p>
  96. <p>The constructor will also set the global <cite>webnotes.conn</cite>, <cite>webnotes.session</cite> and <cite>webnotes.user</cite></p>
  97. <p>To enable a login, the :object:form must have a cmd = &#8220;login&#8221; (see request handling for more details)</p>
  98. <dl class="attribute">
  99. <dt id="auth.Authentication.conn">
  100. <tt class="descname">conn</tt><a class="headerlink" href="#auth.Authentication.conn" title="Permalink to this definition">¶</a></dt>
  101. <dd><cite>webnotes.db.Database</cite> object created after authentication</dd></dl>
  102. <dl class="attribute">
  103. <dt id="auth.Authentication.session">
  104. <tt class="descname">session</tt><a class="headerlink" href="#auth.Authentication.session" title="Permalink to this definition">¶</a></dt>
  105. <dd>session dictionary of the current session</dd></dl>
  106. <dl class="attribute">
  107. <dt id="auth.Authentication.cookies">
  108. <tt class="descname">cookies</tt><a class="headerlink" href="#auth.Authentication.cookies" title="Permalink to this definition">¶</a></dt>
  109. <dd>session dictionary of incoming cookies</dd></dl>
  110. <dl class="attribute">
  111. <dt id="auth.Authentication.domain">
  112. <tt class="descname">domain</tt><a class="headerlink" href="#auth.Authentication.domain" title="Permalink to this definition">¶</a></dt>
  113. <dd>domain name of the request</dd></dl>
  114. <dl class="attribute">
  115. <dt id="auth.Authentication.remote_ip">
  116. <tt class="descname">remote_ip</tt><a class="headerlink" href="#auth.Authentication.remote_ip" title="Permalink to this definition">¶</a></dt>
  117. <dd>IP address of the reqeust</dd></dl>
  118. <dl class="method">
  119. <dt id="auth.Authentication.update">
  120. <tt class="descname">update</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.update" title="Permalink to this definition">¶</a></dt>
  121. <dd><strong>Must be called at the end of the request, to update the session and clear expired sessions</strong></dd></dl>
  122. <dl class="method">
  123. <dt id="auth.Authentication.set_env">
  124. <tt class="descname">set_env</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.set_env" title="Permalink to this definition">¶</a></dt>
  125. <dd>Sets the properties <cite>domain</cite> and <cite>remote_ip</cite> from the environmental variables</dd></dl>
  126. <dl class="method">
  127. <dt id="auth.Authentication.set_db">
  128. <tt class="descname">set_db</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.set_db" title="Permalink to this definition">¶</a></dt>
  129. <dd><p>In case of a multi-database system, this methods sets the correct database connection.</p>
  130. <ul class="simple">
  131. <li>It will first search for cookie <cite>account_id</cite></li>
  132. <li>It will next search for cookies or form variable <cite>__account</cite></li>
  133. <li>It will try and search from the domain mapping table <cite>Account Domain</cite> in the <cite>accounts</cite> database</li>
  134. <li>It will try and use the default</li>
  135. </ul>
  136. </dd></dl>
  137. <dl class="method">
  138. <dt id="auth.Authentication.check_ip">
  139. <tt class="descname">check_ip</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.check_ip" title="Permalink to this definition">¶</a></dt>
  140. <dd>If the current request is from a separate IP than the one which was used to create the session, then
  141. this throws an Exception</dd></dl>
  142. <dl class="method">
  143. <dt id="auth.Authentication.load_session">
  144. <tt class="descname">load_session</tt><big>(</big><em>sid</em><big>)</big><a class="headerlink" href="#auth.Authentication.load_session" title="Permalink to this definition">¶</a></dt>
  145. <dd>Load session from the given session id <cite>sid</cite></dd></dl>
  146. <dl class="method">
  147. <dt id="auth.Authentication.login">
  148. <tt class="descname">login</tt><big>(</big><em>as_guest = 0</em><big>)</big><a class="headerlink" href="#auth.Authentication.login" title="Permalink to this definition">¶</a></dt>
  149. <dd><p>Will login user from <cite>self.form</cite>. If as_guest is true, it will check if Guest profile is enabled</p>
  150. <p>It will also:</p>
  151. <ul class="simple">
  152. <li>validate if approved ips are set in <cite>Profile</cite></li>
  153. <li>start the session</li>
  154. <li>set &#8220;remember me&#8221;</li>
  155. <li>return out.message as &#8220;Logged In&#8221;</li>
  156. </ul>
  157. </dd></dl>
  158. <dl class="method">
  159. <dt id="auth.Authentication.check_password">
  160. <tt class="descname">check_password</tt><big>(</big><em>user</em>, <em>pwd</em><big>)</big><a class="headerlink" href="#auth.Authentication.check_password" title="Permalink to this definition">¶</a></dt>
  161. <dd>Checks if the user has the pwd and is enabled</dd></dl>
  162. <dl class="method">
  163. <dt id="auth.Authentication.validate_ip">
  164. <tt class="descname">validate_ip</tt><big>(</big><em>user</em><big>)</big><a class="headerlink" href="#auth.Authentication.validate_ip" title="Permalink to this definition">¶</a></dt>
  165. <dd>Validates IP address from the ip_address value in the user&#8217;s <cite>Profile</cite></dd></dl>
  166. <dl class="method">
  167. <dt id="auth.Authentication.start_session">
  168. <tt class="descname">start_session</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.start_session" title="Permalink to this definition">¶</a></dt>
  169. <dd>Starts a session, and updates last login details in the users&#8217;s <cite>Profile</cite></dd></dl>
  170. <dl class="method">
  171. <dt id="auth.Authentication.clear_expired">
  172. <tt class="descname">clear_expired</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.clear_expired" title="Permalink to this definition">¶</a></dt>
  173. <dd>Removes old sessions from <cite>tabSessions</cite> that are older than <cite>session_expiry</cite> in <cite>Control Panel</cite> or 24:00 hrs</dd></dl>
  174. <dl class="method">
  175. <dt id="auth.Authentication.set_cookies">
  176. <tt class="descname">set_cookies</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.set_cookies" title="Permalink to this definition">¶</a></dt>
  177. <dd>Sets outgoing cookies</dd></dl>
  178. <dl class="method">
  179. <dt id="auth.Authentication.set_remember_me">
  180. <tt class="descname">set_remember_me</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.set_remember_me" title="Permalink to this definition">¶</a></dt>
  181. <dd>Checks if there is a &#8216;remember_me&#8217; property in <cite>form</cite> with a value and if true, its sets the
  182. expiry of each cookie for <cite>remember_for_days</cite> in <cite>Control Panel</cite> or 7 days</dd></dl>
  183. <dl class="method">
  184. <dt id="auth.Authentication.get_cookies">
  185. <tt class="descname">get_cookies</tt><big>(</big><big>)</big><a class="headerlink" href="#auth.Authentication.get_cookies" title="Permalink to this definition">¶</a></dt>
  186. <dd>Loads incoming cookies in <cite>cookies</cite></dd></dl>
  187. </dd></dl>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. <div class="clearer"></div>
  194. </div>
  195. <div class="related">
  196. <h3>Navigation</h3>
  197. <ul>
  198. <li class="right" style="margin-right: 10px">
  199. <a href="genindex.html" title="General Index"
  200. >index</a></li>
  201. <li class="right" >
  202. <a href="modindex.html" title="Global Module Index"
  203. >modules</a> |</li>
  204. <li class="right" >
  205. <a href="webnotes.html" title="webnotes — Webnotes Module"
  206. >next</a> |</li>
  207. <li class="right" >
  208. <a href="server_side_internals.html" title="Server Side Internals"
  209. >previous</a> |</li>
  210. <li><a href="index.html">Documentation</a> &raquo;</li>
  211. <li><a href="server_side_api.html" >3. Server Side API</a> &raquo;</li>
  212. <li><a href="server_side_internals.html" >Server Side Internals</a> &raquo;</li>
  213. </ul>
  214. </div>
  215. <div class="footer">
  216. &copy; Copyright 2010, Rushabh Mehta.
  217. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
  218. </div>
  219. </body>
  220. </html>