source: TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/config/middleware.py @ 3918

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.server/ndg/security/server/sso/sso/config/middleware.py@3918
Revision 3918, 2.1 KB checked in by pjkersha, 12 years ago (diff)

Initial Integration of Single Sign On Service with OpenID and Pylons AuthKit?:

  • WAYF now contains an OpenID textbox for sign in
  • No role integration carried out yet - OpenID has no better privileges than an anonymous user(!)
  • Integrated into Authkit - requires lots of config settings in pylons ini file
  • HTTP 401 error get redirected automatically to WAYF
  • Need to create an AuthKit? egg from SVN 151 checkout - will put on NDG dist
Line 
1"""Pylons middleware initialization"""
2from paste.cascade import Cascade
3from paste.registry import RegistryManager
4from paste.urlparser import StaticURLParser
5from paste.deploy.converters import asbool
6
7from pylons import config
8from pylons.error import error_template
9from pylons.middleware import error_mapper, ErrorDocuments, ErrorHandler, \
10    StaticJavascripts
11from pylons.wsgiapp import PylonsApp
12
13from sso.config.environment import load_environment
14from sso.config.ssoServiceMiddleware import SSOMiddleware
15import logging
16log = logging.getLogger(__name__)
17
18def make_app(global_conf, full_stack=True, **app_conf):
19    """Create a Pylons WSGI application and return it
20
21    ``global_conf``
22        The inherited configuration for this application. Normally from
23        the [DEFAULT] section of the Paste ini file.
24
25    ``full_stack``
26        Whether or not this application provides a full WSGI stack (by
27        default, meaning it handles its own exceptions and errors).
28        Disable full_stack when this application is "managed" by
29        another WSGI middleware.
30
31    ``app_conf``
32        The application's local configuration. Normally specified in the
33        [app:<name>] section of the Paste ini file (where <name>
34        defaults to main).
35    """
36    # Configure the Pylons environment
37    load_environment(global_conf, app_conf)
38
39    # The Pylons WSGI app
40    app = PylonsApp()
41
42    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
43    app = SSOMiddleware(app, app.globals, app_conf)
44
45    if asbool(full_stack):
46        # Handle Python exceptions
47        app = ErrorHandler(app, global_conf, error_template=error_template,
48                           **config['pylons.errorware'])
49
50        # Display error documents for 401, 403, 404 status codes (and
51        # 500 when debug is disabled)
52        app = ErrorDocuments(app, global_conf, mapper=error_mapper, **app_conf)
53
54    # Establish the Registry for this application
55    app = RegistryManager(app)
56
57    # Static files
58    javascripts_app = StaticJavascripts()
59    static_app = StaticURLParser(config['pylons.paths']['static_files'])
60    app = Cascade([static_app, javascripts_app, app])
61    return app
Note: See TracBrowser for help on using the repository browser.