-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Danangjoyoo/feature/async-rpc-client
[FEATURE] add async client
- Loading branch information
Showing
5 changed files
with
146 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
Security Related Utility | ||
""" | ||
import httpx | ||
|
||
BASIC_AUTH_TOKEN = "44a3f281214d481b8408e7b2355968d1" | ||
|
||
|
||
def validate_rpc_response(response: httpx.Response): | ||
""" | ||
Validate rpc response with defined security basic token | ||
""" | ||
if response.status_code != 200: | ||
return False | ||
|
||
try: | ||
valid_content_type = response.headers.get("content-type", "").lower() == "application/json" | ||
valid_token = response.headers.get("authorization", "").lower() == f"basic {BASIC_AUTH_TOKEN}" | ||
return valid_content_type and valid_token | ||
except: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters