mirror of
https://github.com/certbot/certbot.git
synced 2026-06-06 07:12:54 -04:00
process payment request from end-user web browser
This commit is contained in:
parent
f3935fac9e
commit
b3be68ba67
1 changed files with 17 additions and 2 deletions
|
|
@ -1,5 +1,10 @@
|
|||
#!/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
|
||||
|
||||
urls = (
|
||||
|
|
@ -8,10 +13,20 @@ urls = (
|
|||
|
||||
r = redis.Redis()
|
||||
|
||||
def hexdigit(s):
|
||||
return s in "0123456789abcdef"
|
||||
|
||||
class payment(object):
|
||||
def GET(self, stuff):
|
||||
def GET(self, session):
|
||||
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__":
|
||||
app = web.application(urls, globals())
|
||||
|
|
|
|||
Loading…
Reference in a new issue