Python Forum
Problem enabling http auth in a route
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem enabling http auth in a route
#1
Hello, can someone help me with this please?

This route works as expected

@app.route( '/download', method=['GET', 'POST'] )
def download( pymydb ):
while the following, in which iam trying with http auth

@app.route( '/download', method=['GET', 'POST'] )
@auth_basic(counters.is_authenticated_user)
def download( pymydb ):
fails by giving me the error

Error:
TypeError("download() missing 1 required positional argument: 'pymydb'",) Traceback: Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/lib64/python3.6/site-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/usr/lib64/python3.6/site-packages/bottle.py", line 2690, in wrapper return func(*a, **ka) TypeError: download() missing 1 required positional argument: 'pymydb'
Why is that? How will i be able to enable http auth in this route?
Reply
#2
If i swap the 2 decorators i then get an error instead of the basic auth prompt to enter the credentials.

Error:
[Fri Mar 01 11:34:20.522471 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] TypeError("'NoneType' object is not subscriptable",) [Fri Mar 01 11:34:20.522629 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] mod_wsgi (pid=20532): SystemExit exception raised by WSGI script '/home/nikos/wsgi/files.py' ignored. [Fri Mar 01 11:34:20.522823 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] Traceback (most recent call last): [Fri Mar 01 11:34:20.522847 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] File "/home/nikos/wsgi/files.py", line 133, in download [Fri Mar 01 11:34:20.522851 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] ON DUPLICATE KEY UPDATE downloads = %s''', (2, ref, host, location, useros, browser, lastvisit, filename, request.auth[0], filename) ) [Fri Mar 01 11:34:20.522868 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] TypeError: 'NoneType' object is not subscriptable [Fri Mar 01 11:34:20.522875 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] [Fri Mar 01 11:34:20.522878 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] During handling of the above exception, another exception occurred: [Fri Mar 01 11:34:20.522882 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] [Fri Mar 01 11:34:20.522887 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] Traceback (most recent call last): [Fri Mar 01 11:34:20.522912 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] File "/usr/lib/python3.6/site-packages/bottle.py", line 979, in __call__ [Fri Mar 01 11:34:20.522915 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] return self.wsgi(environ, start_response) [Fri Mar 01 11:34:20.522921 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] File "/usr/lib/python3.6/site-packages/bottle.py", line 954, in wsgi [Fri Mar 01 11:34:20.522924 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] out = self._cast(self._handle(environ)) [Fri Mar 01 11:34:20.522930 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] File "/usr/lib/python3.6/site-packages/bottle.py", line 862, in _handle [Fri Mar 01 11:34:20.522933 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] return route.call(**args) [Fri Mar 01 11:34:20.522938 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] File "/usr/lib/python3.6/site-packages/bottle.py", line 1740, in wrapper [Fri Mar 01 11:34:20.522941 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] rv = callback(*a, **ka) [Fri Mar 01 11:34:20.522946 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] File "/usr/lib/python3.6/site-packages/bottle_pymysql.py", line 174, in wrapper [Fri Mar 01 11:34:20.522951 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] rv = callback(*args, **kwargs) [Fri Mar 01 11:34:20.522963 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] File "/home/nikos/wsgi/files.py", line 136, in download [Fri Mar 01 11:34:20.522967 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] sys.exit(0) [Fri Mar 01 11:34:20.522984 2019] [wsgi:error] [pid 20532] [remote 78.87.87.140:4813] SystemExit: 0
Reply
#3
Hello, someone has an idea or is this a bug in Bottle framework?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to POST html data to be handled by a route endpoint nikos 1 2,347 Mar-07-2020, 03:14 PM
Last Post: nikos
  Google calendar pthon flask auth Kireta 0 2,046 Sep-16-2019, 04:50 PM
Last Post: Kireta
  Problem with arguments in route function. darktitan 2 2,955 Aug-26-2019, 04:55 PM
Last Post: snippsat
  Flask tutorial errors in jinja, auth undefined Ecniv 2 2,451 May-03-2019, 02:04 PM
Last Post: Ecniv
  Passing a query value from a Bottle html template to a route with an encoding nikos 0 2,891 Sep-30-2018, 03:29 AM
Last Post: nikos
  Python /Flask Login with LDAP Auth pythonnubie 4 8,532 Apr-16-2018, 03:14 PM
Last Post: nilamo
  Uninitialized ASN.1 value in Flask LDAP3 Auth blueprint zoidberg 1 4,112 Nov-15-2017, 12:29 PM
Last Post: zoidberg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020