Fix HA addon auth using HA credentials (#3758)

This commit is contained in:
Jesse Hills 2022-09-06 16:41:23 +12:00 committed by GitHub
parent 89fd367297
commit 635851807a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -816,15 +816,16 @@ class LoginHandler(BaseHandler):
import requests import requests
headers = { headers = {
"Authentication": f"Bearer {os.getenv('SUPERVISOR_TOKEN')}", "X-Supervisor-Token": os.getenv("SUPERVISOR_TOKEN"),
} }
data = { data = {
"username": self.get_argument("username", ""), "username": self.get_argument("username", ""),
"password": self.get_argument("password", ""), "password": self.get_argument("password", ""),
} }
try: try:
req = requests.post( req = requests.post(
"http://supervisor/auth", headers=headers, data=data, timeout=30 "http://supervisor/auth", headers=headers, json=data, timeout=30
) )
if req.status_code == 200: if req.status_code == 200:
self.set_secure_cookie("authenticated", cookie_authenticated_yes) self.set_secure_cookie("authenticated", cookie_authenticated_yes)