在我的应用程序中,我使用了flask-security来添加身份验证和授权主题。SQLAlchemy 也用作数据提供者(以 MySQL 作为后端)。该应用程序运行良好。
然后,我进行了一些 MySQL 跟踪,日志显示在应用程序上请求的每个 URL 处,flask-security 库都会发送两个数据库查询:
select ... from user where user.id = 'the user identifier'
select ... from role, roles_users ...
我认为这是一个性能问题,我喜欢尽量减少这些查询。我不知道我是否缺少配置功能。