diff --git a/server-ca/chocolate.py b/server-ca/chocolate.py index e29cc9221..55cf9e973 100755 --- a/server-ca/chocolate.py +++ b/server-ca/chocolate.py @@ -422,7 +422,8 @@ class session(object): chall.name = "payment" chall.succeeded = False # In payment, we send address of form to complete this payment - chall.data.append(str("%s/%s" % (payment_uri, self.id))) + abbreviation = sessions.hget(self.id, "shorturl") + chall.data.append(str("%s/%s" % (payment_uri, abbreviation))) def POST(self): web.header("Content-type", "application/x-protobuf+chocolate") diff --git a/server-ca/index.html b/server-ca/index.html new file mode 100644 index 000000000..2a1f7508f --- /dev/null +++ b/server-ca/index.html @@ -0,0 +1,80 @@ + + + + + + Project Chocolate + + + + + + + + + + +
+
+

Payment Required

+ +
+
+ +
+
+ +
+
+
+
+

Payment Form

+
+

+

:

+

+
+

+
+
+
+
+ + + +
+
+ + + + + + diff --git a/server-ca/payment.py b/server-ca/payment.py index b0a09e20d..fd13f95af 100755 --- a/server-ca/payment.py +++ b/server-ca/payment.py @@ -8,36 +8,20 @@ import web, redis urls = ( - '/([a-f0-9]{64})', 'form', + '/([a-f0-9]{10})', 'shortform', '/submit=([a-f0-9]{64})', 'payment' ) r = redis.Redis() -class form(object): +class shortform(object): def GET(self, what): web.header("Content-type", "text/html") - return """ - -

Payment required

- Due to certificate authority policy, issuing this certificate requires a payment. -

-


-

- A payment of 17.00 simoleons is due now. -

- In order to process this payment, please pretend to enter a 16-digit credit-card - number below, and then click the Submit Payment button. -

-

- Credit Card Type
- Credit Card Number
- -
- This payment will appear on your - credit card statement as TRUSTIFIABLE CERTIFICATE SERVICES. - - """ % what + expanded = r.get("shorturl-%s" % what) + if not expanded: + return "

Unknown session ID

" + with open("index.html","r") as f: + return f.read() % expanded def hexdigit(s): return s in "0123456789abcdef" diff --git a/server-ca/testchallenge-daemon.py b/server-ca/testchallenge-daemon.py index a033b48db..c8424622f 100755 --- a/server-ca/testchallenge-daemon.py +++ b/server-ca/testchallenge-daemon.py @@ -92,12 +92,23 @@ def testchallenge(session): # also have implicitly guaranteed this). if policy.payment_required(session): if debug: print "\t** All challenges satisfied; request %s NEEDS PAYMENT" % short(session) + # Try to get a unique abbreviated ID (10 hex digits) + for i in xrange(20): + abbreviation = random()[:10] + if r.get("shorturl-%s" % abbreviation) is None: + break + else: + # Mysteriously unable to get a unique abbreviated session ID! + r.hset(session, "live", "False") + return + r.set("shorturl-%s" % abbreviation, session) + r.expire("shorturl-%s" % abbreviation, 3600) + r.hset(session, "shorturl", abbreviation) r.hset(session, "state", "payment") # According to current practice, there is no pending-payment # queue because sessions can get out of payment state # instantaneously as soon as the payment system sends a "payments" - # pubsub message to - # the payments daemon. + # pubsub message to the payments daemon. else: if debug: print "\t** All challenges satisfied; request %s GRANTED" % short(session) r.hset(session, "state", "issue")