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/payment.py b/server-ca/payment.py index b0a09e20d..b5a888822 100755 --- a/server-ca/payment.py +++ b/server-ca/payment.py @@ -8,12 +8,41 @@ import web, redis urls = ( + '/([a-f0-9]{10})', 'shortform', '/([a-f0-9]{64})', 'form', '/submit=([a-f0-9]{64})', 'payment' ) r = redis.Redis() +class shortform(object): + def GET(self, what): + web.header("Content-type", "text/html") + expanded = r.get("shorturl-%s" % what) + if not expanded: + return "

Unknown session ID

" + 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. + + """ % expanded + class form(object): def GET(self, what): web.header("Content-type", "text/html") diff --git a/server-ca/testchallenge-daemon.py b/server-ca/testchallenge-daemon.py index a033b48db..81ceb26bf 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.hget("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")