【问题标题】:Is Flask-Cache's filesystem cache secure?Flask-Cache 的文件系统缓存安全吗?
【发布时间】:2016-09-23 15:59:32
【问题描述】:

我想使用 cache.memoize 装饰器缓存认证函数的结果。

但是身份验证功能需要用户名和密码作为参数,我需要维护安全性。

Cache(config={'CACHE_TYPE': 'filesystem'})

@cache.memoize
def authenticate(username, password)
    # some logic
    return True/False

Flask-Cache 的文件系统缓存安全吗?有没有办法通过模块设置烧瓶缓存文件的所有权/权限?

【问题讨论】:

    标签: python caching flask flask-cache


    【解决方案1】:

    在任何地方存储原始密码一段时间听起来是个坏主意。

    根据您检查密码的方式以及瓶颈所在,您可以缓存密码哈希值,然后再进行检查。

    例如,如果您将密码哈希存储在数据库中,而检索是瓶颈:

    def authenticate(username, password):
        hash = get_password_hash()
        return check_password(password, hash)
    
    @cache.memoize
    def get_password_hash(username):
        return retrieve_hash_from_database()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-20
      • 1970-01-01
      • 2020-03-20
      • 1970-01-01
      • 1970-01-01
      • 2016-07-10
      • 2017-11-23
      相关资源
      最近更新 更多