<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
 <title>#51: authkit-token-fix.patch - AuthKit - Trac</title><link rel="start" href="/trac/wiki" /><link rel="search" href="/trac/search" /><link rel="help" href="/trac/wiki/TracGuide" /><link rel="stylesheet" href="/trac/chrome/common/css/trac.css" type="text/css" /><link rel="stylesheet" href="/trac/chrome/common/css/diff.css" type="text/css" /><link rel="stylesheet" href="/trac/chrome/common/css/code.css" type="text/css" /><link rel="icon" href="/trac/chrome/common/trac.ico" type="image/x-icon" /><link rel="shortcut icon" href="/trac/chrome/common/trac.ico" type="image/x-icon" /><link rel="up" href="/trac/ticket/51" title="Ticket #51" /><link rel="alternate" href="/trac/attachment/ticket/51/authkit-token-fix.patch?format=raw" title="Original Format" type="text/x-diff" /><style type="text/css">
</style>
 <script type="text/javascript" src="/trac/chrome/common/js/trac.js"></script>
</head>
<body>


<div id="banner">

<div id="header"><a id="logo" href="http://trac.edgewall.com/"><img src="/trac/chrome/common/trac_banner.png" width="236" height="73" alt="Trac" /></a><hr /></div>

<form id="search" action="/trac/search" method="get">
 <div>
  <label for="proj-search">Search:</label>
  <input type="text" id="proj-search" name="q" size="10" accesskey="f" value="" />
  <input type="submit" value="Search" />
  <input type="hidden" name="wiki" value="on" />
  <input type="hidden" name="changeset" value="on" />
  <input type="hidden" name="ticket" value="on" />
 </div>
</form>



<div id="metanav" class="nav"><ul><li class="first"><a href="/trac/login">Login</a></li><li><a href="/trac/settings">Settings</a></li><li><a href="/trac/wiki/TracGuide" accesskey="6">Help/Guide</a></li><li class="last"><a href="/trac/about">About Trac</a></li></ul></div>
</div>

<div id="mainnav" class="nav"><ul><li class="first"><a href="/trac/wiki" accesskey="1">Wiki</a></li><li><a href="/trac/timeline" accesskey="2">Timeline</a></li><li><a href="/trac/roadmap" accesskey="3">Roadmap</a></li><li><a href="/trac/browser">Browse Source</a></li><li><a href="/trac/report">View Tickets</a></li><li><a href="/trac/newticket" accesskey="7">New Ticket</a></li><li class="last"><a href="/trac/search" accesskey="4">Search</a></li></ul></div>
<div id="main">




<div id="ctxtnav" class="nav"></div>

<div id="content" class="attachment">


 <h1><a href="/trac/ticket/51">Ticket #51</a>: authkit-token-fix.patch</h1>
 <div id="preview">
   


<div class="diff"><ul class="entries"><li class="entry">
  <h2>test/test.py</h2>
  <table class="inline" summary="Differences" cellspacing="0">
   <colgroup><col class="lineno" /><col class="lineno" /><col class="content" /></colgroup>
   <thead><tr>
    <th>old</th>
    <th>new</th>
    <th>&nbsp;</th>
   </tr></thead><tbody><tr><th>11</th><th>11</th><td class="l"><span>import os</span>&nbsp;</td></tr><tr><th>12</th><th>12</th><td class="l"><span>import paste.lint</span>&nbsp;</td></tr><tr><th>13</th><th>13</th><td class="l"><span></span>&nbsp;</td></tr></tbody><tbody class="mod"><tr class="first"><th>14</th><th>&nbsp;</th><td class="l">from authkit.authenticate import middleware, sample_app&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>14</th><td class="r">from authkit.authenticate import middleware, sample_app, cookie&nbsp;</td></tr></tbody><tbody><tr><th>15</th><th>15</th><td class="l"><span>from paste.fixture import *</span>&nbsp;</td></tr><tr><th>16</th><th>16</th><td class="l"><span></span>&nbsp;</td></tr><tr><th>17</th><th>17</th><td class="l"><span>sys.path.insert(0, os.getcwd()+'/examples/docs')</span>&nbsp;</td></tr></tbody>
     <tbody class="skipped">
      <tr><th>&hellip;</th><th>&hellip;</th><td>&nbsp;</td></tr>
     </tbody><tbody><tr><th>31</th><th>31</th><td class="l"><span>openid_app = paste.lint.middleware(openid_app)</span>&nbsp;</td></tr><tr><th>32</th><th>32</th><td class="l"><span>redirect_app = paste.lint.middleware(redirect_app)</span>&nbsp;</td></tr><tr><th>33</th><th>33</th><td class="l"><span></span>&nbsp;</td></tr></tbody><tbody class="add"><tr class="first"><th>&nbsp;</th><th>34</th><td class="r"><ins>from Cookie import SimpleCookie</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>35</th><td class="r"><ins>from StringIO import StringIO</ins>&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>36</th><td class="r"><ins></ins>&nbsp;</td></tr></tbody><tbody><tr><th>34</th><th>37</th><td class="l"><span>sys.path.insert(0, os.getcwd()+'/examples/config')</span>&nbsp;</td></tr><tr><th>35</th><th>38</th><td class="l"><span>from digest import app as config_app</span>&nbsp;</td></tr><tr><th>36</th><th>39</th><td class="l"><span></span>&nbsp;</td></tr></tbody>
     <tbody class="skipped">
      <tr><th>&hellip;</th><th>&hellip;</th><td>&nbsp;</td></tr>
     </tbody><tbody><tr><th>69</th><th>72</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertEqual(res.full_status, '200 OK')</span>&nbsp;</td></tr><tr><th>70</th><th>73</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assert 'You Have Access To This Page.' in res</span>&nbsp;</td></tr><tr><th>71</th><th>74</th><td class="l"><span></span>&nbsp;</td></tr></tbody><tbody class="add"><tr class="first"><th>&nbsp;</th><th>75</th><td class="r"><ins>def test_cookie_setter():</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>76</th><td class="r"><ins>&nbsp; &nbsp; set_user_cookie = cookie.CookieUserSetter(basic_app, &#34;&lt;secret-token&gt;&#34;, params={})</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>77</th><td class="r"><ins>&nbsp; &nbsp; def start_response(status, response_headers, exc_info=None):</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>78</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; pass</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>79</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>80</th><td class="r"><ins>&nbsp; &nbsp; authcookie = SimpleCookie()</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>81</th><td class="r"><ins>&nbsp; &nbsp; # replace with a generated object?</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>82</th><td class="r"><ins>&nbsp; &nbsp; authcookie['authkit'] = &#34;b1e992ae0f0510ff8a56674fa9270c5a48c6a998joeuser!&#34;</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>83</th><td class="r"><ins>&nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>84</th><td class="r"><ins>&nbsp; &nbsp; environ = {</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>85</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; # mandatory CGI variables</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>86</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'REQUEST_METHOD': 'GET',&nbsp; &nbsp; &nbsp;# always mandatory</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>87</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'SCRIPT_NAME': '',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# may be empty if app is at the root</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>88</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'PATH_INFO': '',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# may be empty if at root of app</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>89</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'SERVER_NAME': 'localhost',&nbsp; # always mandatory</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>90</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'SERVER_PORT': '80',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# always mandatory </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>91</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'SERVER_PROTOCOL': 'HTTP/1.0',</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>92</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; # mandatory wsgi variables</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>93</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'wsgi.version': (1, 0),</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>94</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'wsgi.url_scheme': 'http',</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>95</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'wsgi.input': StringIO(''),</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>96</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'wsgi.errors': StringIO(),</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>97</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'wsgi.multithread': False,</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>98</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'wsgi.multiprocess': False,</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>99</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'wsgi.run_once': False,</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>100</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; # cookie stuff</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>101</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'HTTP_COOKIE': '&lt;fake-header&gt;', </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>102</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; 'paste.cookies': [authcookie, '&lt;fake-header&gt;']</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>103</th><td class="r"><ins>&nbsp; &nbsp; }</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>104</th><td class="r"><ins>&nbsp; &nbsp; set_user_cookie(environ, start_response)</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>105</th><td class="r"><ins>&nbsp; &nbsp; raise ValueError(&#34;must set a proper cookie value for this test to do anything&#34;)</ins>&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>106</th><td class="r"><ins></ins>&nbsp;</td></tr></tbody><tbody><tr><th>72</th><th>107</th><td class="l"><span>def test_intercept():</span>&nbsp;</td></tr><tr><th>73</th><th>108</th><td class="l"><span>&nbsp; &nbsp; # XXX Note, these tests don't test when the inclusion of a username and only test form</span>&nbsp;</td></tr><tr><th>74</th><th>109</th><td class="l"><span>&nbsp; &nbsp; # should also test all the other methods too for correct behaviour</span>&nbsp;</td></tr></tbody>
  </table>
 </li><li class="entry">
  <h2>authkit/authenticate/cookie.py</h2>
  <table class="inline" summary="Differences" cellspacing="0">
   <colgroup><col class="lineno" /><col class="lineno" /><col class="content" /></colgroup>
   <thead><tr>
    <th>old</th>
    <th>new</th>
    <th>&nbsp;</th>
   </tr></thead><tbody><tr><th>370</th><th>370</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; environ['paste.auth_tkt.timestamp'] = timestamp</span>&nbsp;</td></tr><tr><th>371</th><th>371</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # End changes from the default</span>&nbsp;</td></tr><tr><th>372</th><th>372</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; environ['REMOTE_USER'] = userid</span>&nbsp;</td></tr></tbody><tbody class="add"><tr class="first last"><th>&nbsp;</th><th>373</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tokens = ','.join(tokens)</ins>&nbsp;</td></tr></tbody><tbody><tr><th>373</th><th>374</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if environ.get('REMOTE_USER_TOKENS'):</span>&nbsp;</td></tr><tr><th>374</th><th>375</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # We want to add tokens/roles to what's there:</span>&nbsp;</td></tr><tr><th>375</th><th>376</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tokens = environ['REMOTE_USER_TOKENS'] + ',' + tokens</span>&nbsp;</td></tr></tbody>
  </table>
 </li>
</ul></div>

 </div>
 


</div>
<script type="text/javascript">searchHighlight()</script>
<div id="altlinks"><h3>Download in other formats:</h3><ul><li class="first last"><a href="/trac/attachment/ticket/51/authkit-token-fix.patch?format=raw">Original Format</a></li></ul></div>

</div>

<div id="footer">
 <hr />
 <a id="tracpowered" href="http://trac.edgewall.com/"><img src="/trac/chrome/common/trac_logo_mini.png" height="30" width="107"
   alt="Trac Powered"/></a>
 <p class="left">
  Powered by <a href="/trac/about"><strong>Trac 0.9.3</strong></a><br />
  By <a href="http://www.edgewall.com/">Edgewall Software</a>.
 </p>
 <p class="right">
  Visit the Trac open source project at<br /><a href="http://trac.edgewall.com/">http://trac.edgewall.com/</a>
 </p>
</div>



 </body>
</html>

