mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 03:41:53 +02:00
process payment request from end-user web browser
This commit is contained in:
+17
-2
@@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# TODO: Is there some way to limit this program's access to the database
|
||||||
|
# so that it cannot change any values, but can still publish pubsub
|
||||||
|
# messages? That would make the security analysis of the system as a
|
||||||
|
# whole clearer.
|
||||||
|
|
||||||
import web, redis
|
import web, redis
|
||||||
|
|
||||||
urls = (
|
urls = (
|
||||||
@@ -8,10 +13,20 @@ urls = (
|
|||||||
|
|
||||||
r = redis.Redis()
|
r = redis.Redis()
|
||||||
|
|
||||||
|
def hexdigit(s):
|
||||||
|
return s in "0123456789abcdef"
|
||||||
|
|
||||||
class payment(object):
|
class payment(object):
|
||||||
def GET(self, stuff):
|
def GET(self, session):
|
||||||
web.header("Content-type", "text/html")
|
web.header("Content-type", "text/html")
|
||||||
return "Hello there! " + stuff
|
if len(session) != 64 or not all(hexdigit(s) for s in session):
|
||||||
|
return "Attempt to process payment for invalid session."
|
||||||
|
if session not in r or r.hget(self.id, "live") != "True":
|
||||||
|
return "Attempt to process payment for invalid session."
|
||||||
|
if r.hget(session, "state") != "payment":
|
||||||
|
return "Attempt to process payment for session not expecting it."
|
||||||
|
r.publish("payments", session)
|
||||||
|
return "<h1>Thank you!</h1> Processed a payment for session ID %s." % session
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = web.application(urls, globals())
|
app = web.application(urls, globals())
|
||||||
|
|||||||
Reference in New Issue
Block a user