Permalink
Browse files

Add timestamp and nonce.

  • Loading branch information...
lepture committed Nov 20, 2013
1 parent 860850e commit 679d9a614cf10b5769f63ac76c45fd9aecb27181
Showing with 36 additions and 0 deletions.
  1. +36 −0 app.py
View
36 app.py
@@ -84,6 +84,20 @@ def realms(self):
return []
class Nonce(db.Model):
id = db.Column(db.Integer, primary_key=True)
timestamp = db.Column(db.Integer)
nonce = db.Column(db.String(40))
client_key = db.Column(
db.String(40), db.ForeignKey('client.client_key'),
nullable=False,
)
client = db.relationship('Client')
request_token = db.Column(db.String(50))
access_token = db.Column(db.String(50))
def current_user():
if 'id' in session:
uid = session['id']
@@ -169,6 +183,28 @@ def save_verifier(token, verifier, *args, **kwargs):
return tok
@oauth.noncegetter
def load_nonce(client_key, timestamp, nonce, request_token, access_token):
return Nonce.query.filter_by(
client_key=client_key, timestamp=timestamp, nonce=nonce,
request_token=request_token, access_token=access_token,
).first()
@oauth.noncesetter
def save_nonce(client_key, timestamp, nonce, request_token, access_token):
nonce = Nonce(
client_key=client_key,
timestamp=timestamp,
nonce=nonce,
request_token=request_token,
access_token=access_token,
)
db.session.add(nonce)
db.session.commit()
return nonce
if __name__ == '__main__':
db.create_all()
app.run()

0 comments on commit 679d9a6

Please sign in to comment.