source: TI12-security/trunk/NDGSecurity/python/Tests/openidaxtest/openidaxtest/controllers/error.py @ 6440

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/NDGSecurity/python/Tests/openidaxtest/openidaxtest/controllers/error.py@6440
Revision 6440, 1.6 KB checked in by pjkersha, 11 years ago (diff)
  • #1088 Important fix to AuthnRedirectResponseMiddleware? to set redirect ONLY when SSL client authentication has just succeeded in the upstream middleware AuthKitSSLAuthnMiddleware. This bug was causing the browser to redirect to the wrong place following OpenID sign in in the case where the user is already logged into their provider and selects a new relying party to sign into.
    • Improvements to Provider decide page interface: leave out messages about attributes that the provider can't retrieve for the RP. Also included NDG style help icon.
Line 
1import cgi
2
3from paste.urlparser import PkgResourcesParser
4from pylons import request
5from pylons.controllers.util import forward
6from pylons.middleware import error_document_template
7from webhelpers.html.builder import literal
8
9from openidaxtest.lib.base import BaseController
10
11class ErrorController(BaseController):
12
13    """Generates error documents as and when they are required.
14
15    The ErrorDocuments middleware forwards to ErrorController when error
16    related status codes are returned from the application.
17
18    This behaviour can be altered by changing the parameters to the
19    ErrorDocuments middleware in your config/middleware.py file.
20
21    """
22
23    def document(self):
24        """Render the error document"""
25        resp = request.environ.get('pylons.original_response')
26        content = literal(resp.body) or cgi.escape(request.GET.get('message', ''))
27        page = error_document_template % \
28            dict(prefix=request.environ.get('SCRIPT_NAME', ''),
29                 code=cgi.escape(request.GET.get('code', str(resp.status_int))),
30                 message=content)
31        return page
32
33    def img(self, id):
34        """Serve Pylons' stock images"""
35        return self._serve_file('/'.join(['media/img', id]))
36
37    def style(self, id):
38        """Serve Pylons' stock stylesheets"""
39        return self._serve_file('/'.join(['media/style', id]))
40
41    def _serve_file(self, path):
42        """Call Paste's FileApp (a WSGI application) to serve the file
43        at the specified path
44        """
45        request.environ['PATH_INFO'] = '/%s' % path
46        return forward(PkgResourcesParser('pylons', 'pylons'))
Note: See TracBrowser for help on using the repository browser.