How to use auth_basic with bottle?

1,369 views
Skip to first unread message

Team AIGD

unread,
Oct 14, 2013, 12:59:09 PM10/14/13
to bott...@googlegroups.com

I am running a bottle-based server application, for which I want to protect some of the routes with basic authentication. Thus I added the bottle.auth_basic decorator like this:

def auth_check(username, password):
    return username == USERNAME and password == PASSWORD

def setRoutes():
    self.route('/admin', 'GET', route_admin)

@bottle.auth_basic(auth_check)
def route_admin():
    print "Admin called."

So when I start the server and connect to it on the same machine (localhost), then its working fine. As soon as I try to access the /admin page I see the proper authentication dialog and I can only access that page when I enter the correct authentication credentials.

However, it does not work when I try to connect to that page from a remote machine. In that case I do not even see the auth. dialog, instead I directly get a 401 page from bottle.

The IP addresses etc. are exactly the same in both cases. In the second case I simply connect from a remote machine instead of the same machine.

Any ideas what I could be missing here?

PS: I am running bottle version 0.11.6

詹青朋

unread,
Oct 14, 2013, 11:57:37 PM10/14/13
to bott...@googlegroups.com
It used to be a bug  https://github.com/defnull/bottle/issues/396


Try to update you bottle.py :D


2013/10/15 Team AIGD <te...@aigamedev.com>

--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
 
---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Team AIGD

unread,
Oct 15, 2013, 4:58:33 AM10/15/13
to bott...@googlegroups.com
Great, that fixed it, thanks!
Reply all
Reply to author
Forward
0 new messages