-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added incoming requests verification using authorization JWT to…
…kens (#447)
- Loading branch information
Showing
34 changed files
with
1,020 additions
and
216 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,39 @@ | ||
from dataclasses import asdict, dataclass, field | ||
from typing import Any, Dict, List, Literal | ||
|
||
|
||
@dataclass | ||
class BotAPIUnverifiedRequestErrorData: | ||
status_message: str | ||
|
||
|
||
@dataclass | ||
class BotAPIUnverifiedRequestResponse: | ||
"""`Unverified request` response model. | ||
Only `.error_data.status_message` attribute will be displayed to | ||
user. Other attributes will be visible only in BotX logs. | ||
""" | ||
|
||
error_data: BotAPIUnverifiedRequestErrorData | ||
errors: List[str] = field(default_factory=list) | ||
reason: Literal["unverified_request"] = "unverified_request" | ||
|
||
|
||
def build_unverified_request_response(status_message: str) -> Dict[str, Any]: | ||
"""Build `unverified request` response for BotX. | ||
It should be sent if the header with the authorization token is missing or | ||
the authorization token is invalid. | ||
If you would like to build complex response, see `BotAPIUnverifiedRequestResponse`. | ||
:param status_message: Status message. | ||
:return: Built `unverified request` response. | ||
""" | ||
|
||
response = BotAPIUnverifiedRequestResponse( | ||
error_data=BotAPIUnverifiedRequestErrorData(status_message=status_message), | ||
) | ||
|
||
return asdict(response) |
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
Oops, something went wrong.