Http get command with admin/pass

  • 143 Views
  • Last Post 06 April 2015
Yokel posted this 04 April 2015

That I'm unsure of. I'll see if I can find out.

Order By: Standard | Newest | Votes
Ryan-Scott posted this 05 April 2015

I'm getting a 401 error when issuing a get command to an eventghost webserver. The requests go through fine when I remove credentials from the webserver. It works with credentials when sending from tasker. Does InControl support admin:pass in the URL?


Do you know what kind of authentication eventghost is expecting?

Yokel posted this 05 April 2015

That I'm unsure of. I'll see if I can find out.

Yokel posted this 06 April 2015

Ryan,

Here's the relevant code for the event ghost webserver plugin.


def Authenticate(self):
# only authenticate, if set
if self.authString is None:
return True

# do Basic HTTP-Authentication
authHeader = self.headers.get('authorization')
if authHeader is not None:
authType, authString = authHeader.split(' ', 2)
if authType.lower() == 'basic' and authString == self.authString:
return True

self.sendresponse(401)
self.send
header('WWW-Authenticate','Basic realm="%s"' % self.authRealm)
self.sendheader('Content-type', 'text/html')
self.end
headers()
return False


def SendContent(self, path):
fsPath = self.translatepath(path)
if isdir(fsPath):
if not path.endswith('/'):
# redirect browser - doing basically what apache does
self.send
response(301)
self.sendheader("Location", path + "/")
self.end
headers()
return None
for index in ("index.html", "index.htm"):
index = join(fsPath, index)
if exists(index):
fsPath = index
break
else:
return self.listdirectory(path)
extension = splitext(fsPath)[1].lower()
if extension not in (".htm", ".html"):
f = self.send
head()
if f:
self.wfile.write(f.read())
f.close()
return
try:
template = self.environment.gettemplate(fsPath)
except TemplateNotFound:
self.send
error(404, "File not found")
return
content = template.render()
self.endrequest(content)


def end
request(self, content, case = 'text/html'):
content=content.encode("UTF-8")
self.sendresponse(200)
self.send
header("Content-type", case)
self.sendheader("Content-Length", len(content))
self.end
headers()
self.wfile.write(content)
self.wfile.close()


def do_POST(self):
"""Serve a POST request."""
# First do Basic HTTP-Authentication, if set
if not self.Authenticate():
return
contentLength = int(self.headers.get('content-length'))
content = self.rfile.read(contentLength)
plugin = self.plugin
try:
data = loads(content)
except:

Close