diff --git a/certapi/authentication.py b/certapi/authentication.py index b138f213bceca095335385f1d305a87b71cdf0ee..1f328b535372b7ec0bcaab401b5faad8856a69ff 100644 --- a/certapi/authentication.py +++ b/certapi/authentication.py @@ -13,7 +13,9 @@ Note on logging: - CertAPISystemError should be logged centrally in one place with levels 'error' for most cases and 'critical' when the application needs to stop """ + import json +import time from flask import current_app, request @@ -106,7 +108,7 @@ def get_mailpass_key(sn): def create_auth_session(req, action, r, extra_params=()): """ This function is called in case of `certs` when no certificate with - matching private key is found in redis or in case of `mailpass` at + matching public key is found in redis or in case of `mailpass` at the beginning of each session. Parameters "sn", "flags", "auth_type" and extra_params are required in @@ -243,9 +245,15 @@ def store_auth_params(sn, sid, session, queue_name, r, extra_params=()): Parameters "nonce", "signature", "flags", "auth_type" and extra_params are required in the session (the param) dictionary. """ + timestamp = int(time.time()) + params = ("nonce", "signature", "flags", "auth_type") + extra_params request = {i: session[i] for i in params} - request.update({"sn": sn, "sid": sid}) + request.update({ + "sn": sn, + "ts": timestamp, + "sid": sid + }) pipe = r.pipeline(transaction=True) pipe.delete(get_session_key(sn, sid))