Skip to content

Commit

Permalink
Restrict OAUTH Username Length
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGrubba committed Sep 3, 2024
1 parent 314e6ce commit 1d596de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/api/oauth_providers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ async def oauth_callback(
break
username = rsp["login"]
# Validate Username
if len(username) > 20:
username = username[:20]
if len(username) < 4 or re.search("[^a-zA-Z0-9]", username) is not None:
username = primary_email.split("@")[0]

Expand Down
2 changes: 2 additions & 0 deletions src/api/oauth_providers/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ async def oauth_callback(

username = jwt_decoded["name"].replace(" ", "")
# Validate Username
if len(username) > 20:
username = username[:20]
if len(username) < 4 or re.search("[^a-zA-Z0-9]", username) is not None:
username = jwt_decoded["email"].split("@")[0]

Expand Down

0 comments on commit 1d596de

Please sign in to comment.