首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Turbogears 2.2.2中的注销失败

Turbogears 2.2.2中的注销失败
EN

Stack Overflow用户
提问于 2014-12-10 10:20:33
回答 1查看 311关注 0票数 18

我用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

代码语言:javascript
复制
# -*- 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'
EN

回答 1

Stack Overflow用户

发布于 2015-12-08 20:49:12

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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27398492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档