Bottle.py HTTP Auth?

前端 未结 2 474
我在风中等你
我在风中等你 2021-02-04 07:57

How can I get my bottle.py app (Running in Paste or Cherrypy) to do HTTP (basic or digest) authentication? - I need to secure it, but cant find a any HOWTOs.

相关标签:
2条回答
  • 2021-02-04 08:42

    bottle has a built in auth_basic decorator that can be used on a view:

    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 }
    
    0 讨论(0)
  • 2021-02-04 08:43

    There are some libraries on GitHub like https://github.com/FedericoCeratto/bottle-cork that should help. It may be easier to integrate than the repoze library suggested in the related post.

    0 讨论(0)
提交回复
热议问题