Adjust new auth method for remote access

Keep old method of auth if remote connection is unsecured
This commit is contained in:
angelblue05 2018-09-10 19:16:11 -05:00
parent 41223da1c1
commit 77ec993f95
2 changed files with 14 additions and 5 deletions

View file

@ -119,7 +119,9 @@ class LoginManual(xbmcgui.WindowXMLDialog):
def _login(self, username, password): def _login(self, username, password):
result = self.connect_manager['login'](self.connect_manager['server-address'], username, password) mode = self.connect_manager['server-mode']
server = self.connect_manager['server-address']
result = self.connect_manager['login'](server, username, password, False if mode == 1 and server.startswith('http://') else True)
if not result: if not result:
self._error(ERROR['Invalid'], _('invalid_auth')) self._error(ERROR['Invalid'], _('invalid_auth'))

View file

@ -98,6 +98,9 @@ class ConnectionManager(object):
return get_server_address(server, server['LastConnectionMode']) return get_server_address(server, server['LastConnectionMode'])
elif key == "revoke-token": elif key == "revoke-token":
return self.revoke_token() return self.revoke_token()
elif key == "server-mode":
server = self.get_server_info(self.server_id)
return server['LastConnectionMode']
return return
@ -188,7 +191,7 @@ class ConnectionManager(object):
return result return result
def login(self, server, username, password="", options={}): def login(self, server, username, password=None, clear=True, options={}):
if not username: if not username:
raise AttributeError("username cannot be empty") raise AttributeError("username cannot be empty")
@ -197,14 +200,18 @@ class ConnectionManager(object):
raise AttributeError("server cannot be empty") raise AttributeError("server cannot be empty")
try: try:
result = self._request_url({ request = {
'type': "POST", 'type': "POST",
'url': self.get_emby_url(server, "Users/AuthenticateByName"), 'url': self.get_emby_url(server, "Users/AuthenticateByName"),
'json': { 'json': {
'username': username, 'username': username,
'pw': password or "" 'password': hashlib.sha1(password or "").hexdigest(),
} }
}, False) }
if clear:
request['json']['pw'] = password or ""
result = self._request_url(request, False)
except Exception as error: # Failed to login except Exception as error: # Failed to login
LOG.error(error) LOG.error(error)
return False return False