MCPcopy Create free account
hub / github.com/authlib/authlib / create_exists_nonce_func

Function create_exists_nonce_func

authlib/integrations/flask_oauth1/cache.py:57–74  ·  view source on GitHub ↗

Create an ``exists_nonce`` function that can be used in hooks and resource protector. :param cache: Cache instance :param key_prefix: key prefix for temporary credential :param expires: Expire time for nonce

(cache, key_prefix="nonce:", expires=86400)

Source from the content-addressed store, hash-verified

55
56
57def create_exists_nonce_func(cache, key_prefix="nonce:", expires=86400):
58 """Create an ``exists_nonce`` function that can be used in hooks and
59 resource protector.
60
61 :param cache: Cache instance
62 :param key_prefix: key prefix for temporary credential
63 :param expires: Expire time for nonce
64 """
65
66 def exists_nonce(nonce, timestamp, client_id, oauth_token):
67 key = f"{key_prefix}{nonce}-{timestamp}-{client_id}"
68 if oauth_token:
69 key = f"{key}-{oauth_token}"
70 rv = cache.has(key)
71 cache.set(key, 1, timeout=expires)
72 return rv
73
74 return exists_nonce
75
76
77def register_nonce_hooks(

Callers 1

register_nonce_hooksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected