Python Forum
Problem enabling http auth in a route - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/Forum-Python-Coding)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/Forum-Web-Scraping-Web-Development)
+--- Thread: Problem enabling http auth in a route (/Thread-Problem-enabling-http-auth-in-a-route)



Problem enabling http auth in a route - nikos - Feb-28-2019

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?


RE: Problem enabling http auth in a route - nikos - Mar-01-2019

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



RE: Problem enabling http auth in a route - nikos - Mar-02-2019

Hello, someone has an idea or is this a bug in Bottle framework?