Opened 22 months ago
Last modified 12 months ago
#14087 new defect
Missing 'trac_auth' cookie in request
| Reported by: | Owned by: | Cinc-th | |
|---|---|---|---|
| Priority: | normal | Component: | TracWikiPrintPlugin |
| Severity: | normal | Keywords: | |
| Cc: | Trac Release: | 1.4 |
Description
After installing the plugin, trying to print a wiki page results in a KeyError: 'trac_auth'.
Systeminformation: User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0 Paket Version Trac 1.4.1 Babel 2.8.0 Docutils 0.16 Genshi 0.7.3 (with speedups) Jinja2 2.11.2 mod_python 3.3.1 MySQL server: "5.7.21-1ubuntu1", client: "0.9.3", thread-safe: True Pygments 2.5.2 pymysql 0.9.3 Python 2.7.18 (default, Mar 8 2021, 13:02:45) [GCC 9.3.0] pytz 2020.1 setuptools 44.1.0 Subversion 1.13.0 (r1867053) Textile 3.0.4 jQuery 1.12.4 jQuery UI 1.12.1 jQuery Timepicker 1.6.3 Installierte Plugins Name Version Ort TracCsvPlugin 0.0.1 /usr/local/lib/python2.7/dist-packages/TracCsvPlugin-0.0.1-py2.7.egg TracDragDrop 0.12.0.15 /usr/local/lib/python2.7/dist-packages/TracDragDrop-0.12.0.15-py2.7.egg TracNav 4.1 /usr/local/lib/python2.7/dist-packages TracPdfPreview 0.1.2 /usr/local/lib/python2.7/dist-packages TracPlantUml 2.3 /usr/local/lib/python2.7/dist-packages TracTags 0.12.dev0 /usr/local/lib/python2.7/dist-packages TracWikiAutoComplete 1.4 /usr/local/lib/python2.7/dist-packages/TracWikiAutoComplete-1.4-py2.7.egg TracWikiExtras 1.3.1 /usr/local/lib/python2.7/dist-packages TracWikiPrint 4.0.0.dev0 /usr/local/lib/python2.7/dist-packages/TracWikiPrint-4.0.0.dev0-py2.7.egg TracXMLRPC 1.1.9.dev0 /usr/local/lib/python2.7/dist-packages
Attachments (1)
Change History (6)
Changed 22 months ago by
| Attachment: | 2021-12-02_00-08.png added |
|---|
comment:1 Changed 22 months ago by
comment:2 Changed 22 months ago by
| Component: | TracWikiToPdfPlugin → TracWikiPrintPlugin |
|---|---|
| Keywords: | cookie auth print tracwikitopdfplugin removed |
| Owner: | set to Cinc-th |
| Priority: | high → normal |
| Severity: | critical → normal |
The error is raised from TracWikiPrintPlugin.
comment:3 Changed 15 months ago by
Hi, I have the same issue as his. Moreover, this issue has been appeared when I use Ldap authentication and authorization like that:
<Location /prt/prj>
WSGIApplicationGroup %{GLOBAL}
SSLRequireSSL
Allow from 10.0.0.0/24
AuthType Basic
AuthName "Protected"
AuthBasicProvider "ldap"
AuthLDAPURL "ldap://192.168.1.1/dc=example,dc=com?mail?sub?(&(objectClass=*)(accountstatus=active)(mail=*@example.com))"
AuthLDAPBindDN "cn=manager,dc=example,dc=com"
AuthLDAPBindPassword "password"
Require valid-user
</Location>
</VirtualHost>
but when I use another configuration everything is alright
<Location /pub/prj>
SSLRequireSSL
WSGIApplicationGroup %{GLOBAL}
</Location>
<LocationMatch /pub/prj/[[:alnum:]_]+/login>
Allow from 10.0.0.0/24
AuthType Basic
AuthName "Public area"
AuthBasicProvider "ldap"
AuthLDAPURL "ldap://192.168.1.1/dc=example,dc=com?mail?sub?(&(objectClass=*)(accountstatus=active)(mail=*@example.com))"
AuthLDAPBindDN "cn=manager,dc=example,dc=com"
AuthLDAPBindPassword "password"
Require valid-user
</LocationMatch>
These options are very different. The former requires authorization before the user can access the protected area, the latter has access for anonymous users and the user can log in with their username and password.
Python Traceback
Most recent call last:
File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 639, in dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 250, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/local/lib/python2.7/dist-packages/trac/wiki/web_ui.py", line 186, in process_request
format, versioned_page.name)
File "/usr/local/lib/python2.7/dist-packages/trac/mimeview/api.py", line 1020, in send_converted
iterable=iterable)
File "/usr/local/lib/python2.7/dist-packages/trac/mimeview/api.py", line 705, in convert_content
conversion.key)
File "/usr/local/lib/python2.7/dist-packages/tracpdf/wikiprint.py", line 218, in convert_content
pdfoptions = self.prepare_pdf_options(req, pagename)
File "/usr/local/lib/python2.7/dist-packages/tracpdf/wikiprint.py", line 261, in prepare_pdf_options
('trac_auth', req.incookie['trac_auth'].value),
my system info
System Information
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.49
Package Version
Trac 1.4.3
Genshi 0.7.3 (with speedups)
Jinja2 2.11.3
mod_wsgi 4.3.0 (WSGIProcessGroup wsgitrac_protected WSGIApplicationGroup %{GLOBAL})
pysqlite 2.6.0
Python 2.7.12 (default, Mar 1 2021, 11:38:31) [GCC 5.4.0 20160609]
setuptools 20.7.0
SQLite 3.11.0
Subversion 1.9.3 (r1718519)
jQuery 1.12.4
jQuery UI 1.12.1
jQuery Timepicker 1.6.3
Installed Plugins
Name Version Location
TracArchiveViewer 0.3.dev0 /usr/local/lib/python2.7/dist-packages/TracArchiveViewer-0.3.dev0-py2.7.egg
TracBookmark 1.0.2 /usr/local/lib/python2.7/dist-packages/TracBookmark-1.0.2-py2.7.egg
TracWikiPrint 4.0.0.dev0 /usr/local/lib/python2.7/dist-packages
comment:5 Changed 12 months ago by
The issue occurs when an anonymous user clicks PDF Page download link. It doesn't when an authenticated user clicks the link.
-
tracpdf/wikiprint.py
252 252 :param pagename: name of the current wiki page 253 253 :return: dict with wkhtmltopdf global options 254 254 """ 255 for name in ('trac_auth', 'trac_session'): 256 if name in req.incookie: 257 cookie = [(name, req.incookie[name].value)] 258 break 259 else: 260 cookie = [] 255 261 options = { 256 262 'page-size': req.args.get('pagesize') or self.pagesize, 257 263 'encoding': "UTF-8", 258 264 'outline': None, 259 265 'title': req.args.get('pdftitle') or self.pdftitle or pagename, 260 'cookie': [ 261 ('trac_auth', req.incookie['trac_auth'].value), 262 ] 266 'cookie': cookie, 263 267 } 264 268 self._add_footer(options, pagename, req.args.get('footertext')) 265 269 return options



See attachement.