Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bottle.py HTTP Auth?

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.

like image 343
James Bennet Avatar asked Nov 07 '12 15:11

James Bennet


2 Answers

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 }
like image 107
M Somerville Avatar answered Oct 04 '22 07:10

M Somerville


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.

like image 32
Brian Cajes Avatar answered Oct 04 '22 06:10

Brian Cajes