+import logging
+import pyramid.httpexceptions
import re
from colorsys import rgb_to_hls, hls_to_rgb
from cgi import escape as html_escape
from datetime import datetime, timedelta
from decimal import Decimal
from collections import namedtuple
+from xonstat.d0_blind_id import d0_blind_id_verify
+
+
+log = logging.getLogger(__name__)
+
# Map of special chars to ascii from Darkplace's console.c.
_qfont_table = [
cake_day = True
return cake_day
+
+
+def verify_request(request):
+ """Verify requests using the d0_blind_id library"""
+
+ # first determine if we should be verifying or not
+ val_verify_requests = request.registry.settings.get('xonstat.verify_requests', 'true')
+ if val_verify_requests == "true":
+ flg_verify_requests = True
+ else:
+ flg_verify_requests = False
+
+ try:
+ (idfp, status) = d0_blind_id_verify(
+ sig=request.headers['X-D0-Blind-Id-Detached-Signature'],
+ querystring='',
+ postdata=request.body)
+
+ log.debug('\nidfp: {0}\nstatus: {1}'.format(idfp, status))
+ except:
+ idfp = None
+ status = None
+
+ if flg_verify_requests and not idfp:
+ log.debug("ERROR: Unverified request")
+ raise pyramid.httpexceptions.HTTPUnauthorized("Unverified request")
+
+ return (idfp, status)
from pyramid.response import Response\r
from sqlalchemy import Sequence\r
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\r
-from xonstat.d0_blind_id import d0_blind_id_verify\r
from xonstat.elo import process_elos\r
from xonstat.models import *\r
-from xonstat.util import strip_colors, qfont_decode\r
+from xonstat.util import strip_colors, qfont_decode, verify_request\r
\r
\r
log = logging.getLogger(__name__)\r
return is_supported\r
\r
\r
-def verify_request(request):\r
- """Verify requests using the d0_blind_id library"""\r
-\r
- # first determine if we should be verifying or not\r
- val_verify_requests = request.registry.settings.get('xonstat.verify_requests', 'true')\r
- if val_verify_requests == "true":\r
- flg_verify_requests = True\r
- else:\r
- flg_verify_requests = False\r
-\r
- try:\r
- (idfp, status) = d0_blind_id_verify(\r
- sig=request.headers['X-D0-Blind-Id-Detached-Signature'],\r
- querystring='',\r
- postdata=request.body)\r
-\r
- log.debug('\nidfp: {0}\nstatus: {1}'.format(idfp, status))\r
- except:\r
- idfp = None\r
- status = None\r
-\r
- if flg_verify_requests and not idfp:\r
- log.debug("ERROR: Unverified request")\r
- raise pyramid.httpexceptions.HTTPUnauthorized("Unverified request")\r
-\r
- return (idfp, status)\r
-\r
-\r
def do_precondition_checks(request, game_meta, raw_players):\r
"""Precondition checks for ALL gametypes.\r
These do not require a database connection."""\r