执行Hawk身份验证服务器端的实用程序功能
hawk-server-asyncio的Python项目详细描述
Hawk服务器异步
执行Hawk身份验证服务器端的实用程序功能
安装
pip install hawk-server-asyncio
用法
fromhawkserverimportauthenticate_hawk_headerasyncdeflookup_credentials(id):# Return {'id': 'some-id', 'key': 'some-secret'} matching credentials,# or None if credentials can't be foundasyncdefseen_nonce(nonce,id):# Store nonce, return True if nonce previously seenis_authenticated,error_message,credentials=awaitauthenticate_hawk_header(lookup_credentials,seen_nonce,max_skew,header,method,host,port,path,content_type,content,)ifnotis_authenticated:# Return error or raise exception as needed