mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
0e474769d4
commit
0d96aaacb7
54
daemon.py
54
daemon.py
|
@ -174,6 +174,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _isAuthorized(self) -> bool:
|
||||||
|
if self.headers.get('Authorization'):
|
||||||
|
if authorize(self.server.baseDir,self.path, \
|
||||||
|
self.headers['Authorization'], \
|
||||||
|
self.server.debug):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: GET from '+self.server.baseDir+ \
|
print('DEBUG: GET from '+self.server.baseDir+ \
|
||||||
|
@ -257,25 +265,22 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# get the inbox for a given person
|
# get the inbox for a given person
|
||||||
if self.path.endswith('/inbox'):
|
if self.path.endswith('/inbox'):
|
||||||
if '/users/' in self.path:
|
if '/users/' in self.path:
|
||||||
if self.headers.get('Authorization'):
|
if self._isAuthorized():
|
||||||
if authorize(self.server.baseDir,self.path, \
|
inboxFeed=personBoxJson(self.server.baseDir, \
|
||||||
self.headers['Authorization'], \
|
self.server.domain, \
|
||||||
self.server.debug):
|
self.server.port, \
|
||||||
inboxFeed=personBoxJson(self.server.baseDir, \
|
self.path, \
|
||||||
self.server.domain, \
|
self.server.httpPrefix, \
|
||||||
self.server.port, \
|
maxPostsInFeed, 'inbox')
|
||||||
self.path, \
|
if inboxFeed:
|
||||||
self.server.httpPrefix, \
|
self._set_headers('application/json')
|
||||||
maxPostsInFeed, 'inbox')
|
self.wfile.write(json.dumps(inboxFeed).encode('utf-8'))
|
||||||
if inboxFeed:
|
self.server.GETbusy=False
|
||||||
self._set_headers('application/json')
|
return
|
||||||
self.wfile.write(json.dumps(inboxFeed).encode('utf-8'))
|
else:
|
||||||
self.server.GETbusy=False
|
if self.server.debug:
|
||||||
return
|
print('DEBUG: '+nickname+ \
|
||||||
else:
|
' was not authorized to access '+self.path)
|
||||||
if self.server.debug:
|
|
||||||
print('DEBUG: '+nickname+ \
|
|
||||||
' was not authorized to access '+self.path)
|
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: GET access to inbox is unauthorized')
|
print('DEBUG: GET access to inbox is unauthorized')
|
||||||
self.send_response(405)
|
self.send_response(405)
|
||||||
|
@ -380,13 +385,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
if self.path.endswith('/outbox'):
|
if self.path.endswith('/outbox'):
|
||||||
if '/users/' in self.path:
|
if '/users/' in self.path:
|
||||||
if self.headers.get('Authorization'):
|
if self._isAuthorized():
|
||||||
if authorize(self.server.baseDir,self.path, \
|
self.outboxAuthenticated=True
|
||||||
self.headers['Authorization'], \
|
pathUsersSection=path.split('/users/')[1]
|
||||||
self.server.debug):
|
self.postToNickname=pathUsersSection.split('/')[0]
|
||||||
self.outboxAuthenticated=True
|
|
||||||
pathUsersSection=path.split('/users/')[1]
|
|
||||||
self.postToNickname=pathUsersSection.split('/')[0]
|
|
||||||
if not self.outboxAuthenticated:
|
if not self.outboxAuthenticated:
|
||||||
self.send_response(405)
|
self.send_response(405)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
Loading…
Reference in New Issue