mirror of
https://github.com/nikdoof/test-auth.git
synced 2026-01-30 16:08:14 +00:00
Allow for service names to propagate to the log
This commit is contained in:
@@ -23,6 +23,7 @@ class APIKeyAuthentication(object):
|
|||||||
url = request.path
|
url = request.path
|
||||||
AuthAPILog(key=keyobj, access_datetime=datetime.utcnow(), url=url).save()
|
AuthAPILog(key=keyobj, access_datetime=datetime.utcnow(), url=url).save()
|
||||||
request.user = AnonymousUser()
|
request.user = AnonymousUser()
|
||||||
|
request.api_key = keyobj
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class EveAPIProxyHandler(BaseHandler):
|
|||||||
params['apikey'] = obj.api_key
|
params['apikey'] = obj.api_key
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cached_doc = CachedDocument.objects.api_query(url_path, params)
|
cached_doc = CachedDocument.objects.api_query(url_path, params, service=request.api_key.description)
|
||||||
except DocumentRetrievalError, exc:
|
except DocumentRetrievalError, exc:
|
||||||
return HttpResponse(exc, status=500)
|
return HttpResponse(exc, status=500)
|
||||||
else:
|
else:
|
||||||
@@ -130,7 +130,7 @@ class OpTimerHandler(BaseHandler):
|
|||||||
error_doc = {'ops': [{'startsIn': -1, 'eventID': 0, 'ownerName': '', 'eventDate': '', 'eventTitle': '<div style="text-align:center">The EVE API calendar is unavailable</div>', 'duration': 0, 'isImportant': 0, 'eventText': 'Fuck CCP tbqh imho srsly', 'endsIn':-1, 'forumLink': ''}]}
|
error_doc = {'ops': [{'startsIn': -1, 'eventID': 0, 'ownerName': '', 'eventDate': '', 'eventTitle': '<div style="text-align:center">The EVE API calendar is unavailable</div>', 'duration': 0, 'isImportant': 0, 'eventText': 'Fuck CCP tbqh imho srsly', 'endsIn':-1, 'forumLink': ''}]}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cached_doc = CachedDocument.objects.api_query('/char/UpcomingCalendarEvents.xml.aspx', params)
|
cached_doc = CachedDocument.objects.api_query('/char/UpcomingCalendarEvents.xml.aspx', params, service="Optimer")
|
||||||
except DocumentRetrievalError:
|
except DocumentRetrievalError:
|
||||||
return error_doc
|
return error_doc
|
||||||
dom = minidom.parseString(cached_doc.body.encode('utf-8'))
|
dom = minidom.parseString(cached_doc.body.encode('utf-8'))
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class CachedDocumentManager(models.Manager):
|
|||||||
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
def api_query(self, url_path, params={}, no_cache=False, exceptions=True):
|
def api_query(self, url_path, params={}, no_cache=False, exceptions=True, service="Auth"):
|
||||||
"""
|
"""
|
||||||
Transparently handles querying EVE API or retrieving the document from
|
Transparently handles querying EVE API or retrieving the document from
|
||||||
the cache.
|
the cache.
|
||||||
@@ -104,7 +104,7 @@ class CachedDocumentManager(models.Manager):
|
|||||||
for k in params:
|
for k in params:
|
||||||
if not k in ['userid', 'apikey', 'vcode', 'keyid']: fparams[k] = params[k]
|
if not k in ['userid', 'apikey', 'vcode', 'keyid']: fparams[k] = params[k]
|
||||||
|
|
||||||
ApiAccessLog(userid=v, service='Unknown', time_access=doc.time_retrieved, document=self.construct_url(url_path, fparams)).save()
|
ApiAccessLog(userid=v, service=service, time_access=doc.time_retrieved, document=self.construct_url(url_path, fparams)).save()
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user