在Turbogears 2.2.2中注销失败

tom*_*mis 18 python pylons turbogears2

我有使用默认身份验证在TG 2.2.2中编写的应用程序.最后几天,我有登录和退出的问题.在safari中,创建了两个authtkt cookie,一个是"beta.domain.com",另一个是".beta.domain.com".在调用/ logout_handler之后,域"beta.domain.com"的cookie仅被删除,但野生域仍然存在.因此,在重新加载页面后,用户仍然登录.本地主机以及生产时出现问题.

有趣的是,相同的lib版本上的其他应用程序正常工作,以及其他浏览器,没有使用virtualenv.

我真的不知道问题在哪里,所以我会在请求时包含任何配置文件.在开始时,包含app_config.

app_cfg.py

# -*- coding: utf-8 -*-
from tg.configuration import AppConfig

import cafeteria
from cafeteria import model
from cafeteria.lib import app_globals, helpers

base_config = AppConfig()
base_config.renderers = []
base_config.prefer_toscawidgets2 = True

base_config.package = cafeteria

base_config.renderers.append('json')

base_config.renderers.append('mako')
base_config.default_renderer = 'mako'

base_config.use_sqlalchemy = True
base_config.model = cafeteria.model
base_config.DBSession = cafeteria.model.DBSession
# Configure the authentication backend

# YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP
base_config.sa_auth.cookie_secret = "SOMESECRET"

base_config.auth_backend = 'sqlalchemy'

from tg.configuration.auth import TGAuthMetadata

# This tells to TurboGears how to retrieve the data for your user
class ApplicationAuthMetadata(TGAuthMetadata):
    def __init__(self, sa_auth):
        self.sa_auth = sa_auth
    def get_user(self, identity, userid):
        return self.sa_auth.dbsession.query(self.sa_auth.user_class).filter_by(user_name = userid).first()
    def get_groups(self, identity, userid):
        return (identity['user'].group.name,) if identity['user'].group_id else []
    def get_permissions(self, identity, userid):
        return [p.name for p in identity['user'].group.permissions] if identity['user'].group_id else []


base_config.sa_auth.dbsession = model.DBSession
base_config.sa_auth.user_class = model.User
# base_config.sa_auth.group_class = model.Group
# base_config.sa_auth.permission_class = model.Permission

base_config.sa_auth.translations.group_name = 'name'
base_config.sa_auth.translations.permission_name = 'name'

base_config.sa_auth.authmetadata = ApplicationAuthMetadata(base_config.sa_auth)

# base_config.sa_auth.authenticators = [('myauth', SomeAuthenticator()]
# base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()]

base_config.sa_auth.form_plugin = None
base_config.sa_auth.charset = 'utf-8'
base_config.sa_auth.post_login_url = '/post_login'
base_config.sa_auth.post_logout_url = '/post_logout'
Run Code Online (Sandbox Code Playgroud)

Ali*_*han 1

  1. 删除您域的所有cookie。当您更改域名时,旧的 cookie 仍然存在,并可能导致此问题。
  2. 为什么同时使用beta.domain.com.beta.domain.com?如果您不需要在子域中使用此 cookie,请删除第二个,否则只需使用.beta.domain.com.

如果这没有帮助,请附加请求和响应标头。