简体   繁体   English

Bottle.py HTTP Auth?

[英]Bottle.py HTTP Auth?

How can I get my bottle.py app (Running in Paste or Cherrypy) to do HTTP (basic or digest) authentication? 如何让我的bottle.py应用程序(在Paste或Cherrypy中运行)进行HTTP(基本或摘要)身份验证? - I need to secure it, but cant find a any HOWTOs. - 我需要保护它,但无法找到任何HOWTO。

bottle has a built in auth_basic decorator that can be used on a view: bottle有一个内置的auth_basic装饰器,可以在视图上使用:

from bottle import auth_basic, request, route

def check(user, pw):
    # Check user/pw here and return True/False

@route('/')
@auth_basic(check)
def home():
    return { 'data': request.auth }

There are some libraries on GitHub like https://github.com/FedericoCeratto/bottle-cork that should help. GitHub上有一些库,比如https://github.com/FedericoCeratto/bottle-cork应该有所帮助。 It may be easier to integrate than the repoze library suggested in the related post. 它可能比相关帖子中建议的repoze库更容易集成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM