Flask HTTP Basicauth-如何工作? [英] Flask HTTP Basicauth - How does it work?

查看:89
本文介绍了Flask HTTP Basicauth-如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Flask和HTTP Basic Auth创建一个登录系统.我的问题是,从数据库提供用户信息是我的责任,还是basicauth为我创建和访问那些数据库?如果没有,我该怎么做?

I'm trying to create a login system using Flask and HTTP Basic Auth. My question is, is it my responsibility to provide user information from databases, or does basicauth create and access those databases for me? If it doesn't, what can I use to do that?

推荐答案

Werkzeug可以为您将基本授权"标头解码为用户名和密码.其余的工作由您决定是否要处理这些信息.

Werkzeug can decode the Basic Authorization header for you, into the username and password. The rest is up to you to see what you want to do with that information.

request.authorization属性返回<一个href ="http://werkzeug.pocoo.org/docs/datastructures/#werkzeug.datastructures.Authorization" rel ="nofollow noreferrer"> Authorization对象.对于基本身份验证标头,仅设置usernamepassword.

Flask-Login 这样的项目可以帮助您管理更复杂的登录基本授权,并将其与您提供的用户模型联系在一起.该模型可以存储在数据库中,也可以存储在其他任何您想要的地方.

A project like Flask-Login can help you manage more complex logins with Basic Authorization, and tie that in with a user model you provide. That model can be stored in a database or anything else you so desire.

您可以查看 Flask-Security ,了解使用Flask的更加完整的安全软件包-Login和其他软件包,以提供基本身份验证和基于会话的登录.

And you can look at Flask-Security for a more fully integrated security package that uses Flask-Login and other packages to provide Basic Authentication and session based logins.

这篇关于Flask HTTP Basicauth-如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆