Pilões e Problema do Authkit OpenId
Pergunta
Tenho problemas para configurar o suporte para autenticação OpenID, usando AuthKit e Pylons. Eu configurei tudo como descrito no livro de receitas, mas ainda receba o seguinte erro:
File "/usr/lib/python2.6/dist-packages/authkit/authenticate/open_id.py", line 480, in __call__
return self.app(environ, start_response)
File "/usr/lib/python2.6/dist-packages/authkit/authenticate/open_id.py", line 218, in __call__
self.session_middleware
AuthKitConfigError: The session middleware 'beaker.session' is not present. Have you set up the session middleware?
(O rastreamento completo é bastante não informativo, apenas uma cadeia de chamadas de middleware)
Minha configuração é o seguinte:
authkit.setup.method = openid, cookie
# TODO authkit.openid.template.file =
authkit.cookie.params.httponly = true
authkit.openid.store.type = file
authkit.openid.store.config = %(here)s/data
authkit.openid.session.middleware = beaker.session
authkit.openid.session.key = authkit_openid
authkit.openid.baseurl = http://mysite.moc
authkit.openid.path.signedin = /main/cabinet
authkit.openid.authenticate.user.encrypt = authkit.users:md5
O middleware do copo está definitivamente carregado, aqui está a minha função make_app (sim, a verificação da versão dos Pylons é verdadeira):
| # Configure the Pylons environment
| load_environment(global_conf, app_conf)
|
| # The Pylons WSGI app
| app = PylonsApp()
| app = UserMiddleware(app)
|
| if pylons.__version__ >= "0.9.7":
|- from beaker.middleware import SessionMiddleware
|| from routes.middleware import RoutesMiddleware
|| app = RoutesMiddleware(app, config['routes.map'])
|| app = SessionMiddleware(app, app_conf)
|
|
| if asbool(full_stack):
| # Handle Python exceptions
|
|- app = authkit.authenticate.middleware(app, app_conf)
|| # Display error documents for 401, 403, 404 status codes (and
|| # 500 when debug is disabled)
|| if pylons.__version__ >= "0.9.7":
||- app = ErrorHandler(app, global_conf,
23- **config['pylons.errorware'])
||| from pylons.middleware import StatusCodeRedirect
||| if asbool(config['debug']):
23- app = StatusCodeRedirect(app)
||| else:
23- app = StatusCodeRedirect(app, [401, 403, 404, 500])
|| else:
||- app = ErrorHandler(app, global_conf, error_template = error_template,
23- **config['pylons.errorware'])
||| app = ErrorDocuments(app, global_conf, mapper=error_mapper, **app_conf)
|
| # Establish the Registry for this application
| app = RegistryManager(app)
|
| # Static files
| javascripts_app = StaticJavascripts()
| static_app = StaticURLParser(config['pylons.paths']['static_files'])
| app = Cascade([static_app, javascripts_app, app])
| return app
Alguém tem alguma ideia, o que está acontecendo aqui?
Solução
Pegue esta linha em seu middleware.py:
app = authkit.authenticate.middleware(app, app_conf)
E mova -o imediatamente abaixo desta linha:
app = PylonsApp()
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow