-
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.
Update username, password & email APIs; X-Ripple-Token authorization (#4
) * Authorized username update API * deploy that shit out * Bugfix * Pull args from body * Fix unmapped codes * Lock name changes to donors * Fix * APIs to update user email & password * Add APIs * Fixes * Edit API * Log validation errors * Fix authorization * Fixes * security irl * fixes & make apis harder to fuck up * Update .github/workflows/production-deploy.yml
- Loading branch information
Showing
10 changed files
with
353 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import hashlib | ||
from app.errors import Error, ErrorCode | ||
from app.repositories import access_tokens | ||
|
||
|
||
async def authorize_request( | ||
*, | ||
user_access_token: str, | ||
expected_user_id: int | None = None, | ||
) -> access_tokens.AccessToken | Error: | ||
hashed_access_token = hashlib.md5( | ||
user_access_token.encode(), | ||
usedforsecurity=False, | ||
).hexdigest() | ||
trusted_access_token = await access_tokens.fetch_one(hashed_access_token) | ||
if trusted_access_token is None: | ||
return Error( | ||
error_code=ErrorCode.INCORRECT_CREDENTIALS, | ||
user_feedback="Unauthorized request", | ||
) | ||
|
||
if ( | ||
expected_user_id is not None | ||
and trusted_access_token.user_id != expected_user_id | ||
): | ||
return Error( | ||
error_code=ErrorCode.INCORRECT_CREDENTIALS, | ||
user_feedback="Unauthorized request", | ||
) | ||
|
||
return trusted_access_token |
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
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.