cdchris12 / UDM-DNS-Fix

A simple script to provide basic DHCP hostname resolution in the latest UniFi Dream Machine Pro firmware.
Apache License 2.0
74 stars 8 forks source link

Login returns 404 #2

Closed patelhiren closed 3 years ago

patelhiren commented 3 years ago

Thanks for sharing this script. I am looking to implement a similar solution where I run a container via podman. Looking at the login api and just trying to Post the request in Postman to see if things are working. I am currently getting a 404 error when posting to /api/auth/login/. Running UDM Pro v 1.8.3. Wondering if this is working for you on that version and if you have any other insights as to what I problem could be.

cdchris12 commented 3 years ago

So, I can confirm this login functionality still works for me in 1.8.3. I did notice a strange quirk in that you cannot POST a login more than once successfully in the same session. The first try will return a 200, and any subsequent retries will return a 404, as shown below:

>>> s = requests.Session()
>>> r = s.post(f'{baseurl}/api/auth/login', json={'username': username, 'password': password}, verify=False)
/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py:842: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn((
>>> r.status_code
200
>>> r = s.post(f'{baseurl}/api/auth/login', json={'username': username, 'password': password}, verify=False)
/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py:842: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn((
>>> r.status_code
404

Maybe this is what's happening to your requests?

patelhiren commented 3 years ago

Thanks for confirming. Looks like subsequent retries is exactly what I am running into. I am able to ignore that call and call the other apis just fine.