import sys; sys.path.append('../') from web.wsgi import * def simpleApp(environ, start_response): if not environ.has_key('web.auth.user'): # No user signed in start_response('403 User not signed in', []) return [] elif not environ['web.auth.user'].authorise(app='app', level=1): start_response('403 The user does not have permission to access this application', []) return [] else: start_response('200 OK', [('Content-type','text/html')]) if environ['web.cgi'].has_key('mode') and environ['web.cgi']['mode'].value == 'signOut': environ['web.auth'].signOut() return [""" Auth Example

Signed Out

Sign in

"""] else: return [""" Auth Example

Congratulations!

Signed in!

Sign out, Visit again

"""] # Middleware Setup application = error.Error( database.Database( session.Session( cgi.CGI( auth.Auth( simpleApp, driver='database', autoCreate=1, expire=0, idle=10, template = """ Auth Example

Sign In

%(form)s

%(message)s

""", redirectMethod='metaRefresh' ), ), expire = 1000, autoCreate = 1, driver='database', ), adapter = 'snakesql', database = 'wsgi-auth', autoCreate = 1 ), )