如何在 Bottle 框架中执行基本身份验证?在烧瓶中我曾经:
def check( username, password ):
# This function is called to check if a username/password combination is valid
return username == 'nikos' and password == '******'
def authenticate():
# Sends a 401 response that enables basic auth
return Response( 'Credentials of a registered user required!', 401, {'WWW-Authenticate': 'Basic realm="User!"'} )
Run Code Online (Sandbox Code Playgroud)
并称为:
auth = request.authorization
if not auth or not counters.check( auth.username, auth.password ):
return counters.authenticate()
Run Code Online (Sandbox Code Playgroud)
我如何在 Bottle 框架中实现相同的目标?
可能重复:对
瓶子友好的WSGI身份验证库/中间件
我正在使用Python和Bottle创建一个简单的Web应用程序.将此用户身份验证/会话添加到此设置的简单方法是什么?