Skip to content

Commit

Permalink
fix userid generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunsi committed Dec 23, 2024
1 parent 7da6e43 commit a55ab78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def before_request():
if not provider or not userinfo:
return

userid = SSO_CONFIG[provider]["functions"]["userid"](userinfo)
username = SSO_CONFIG[provider]["functions"]["username"](userinfo)
user_is_admin = SSO_CONFIG[provider]["functions"]["is_admin"](userinfo)
user_without_limits = SSO_CONFIG[provider]["functions"]["no_limit"](userinfo)
Expand All @@ -135,7 +136,7 @@ def before_request():

g.user_is_admin = user_is_admin
g.user_without_limits = user_without_limits
g.userid = f"{provider}:{username}"
g.userid = userid
g.username = username


Expand Down
2 changes: 2 additions & 0 deletions util/sso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
check_github_allowed_login,
check_github_is_admin,
check_github_no_limit,
get_github_userid,
get_github_username,
)

Expand All @@ -17,6 +18,7 @@
"is_admin": check_github_is_admin,
"login_allowed": check_github_allowed_login,
"no_limit": check_github_no_limit,
"userid": get_github_userid,
"username": get_github_username,
},
},
Expand Down
4 changes: 4 additions & 0 deletions util/sso/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
LOG = getLogger("SSO-Github")


def get_github_userid(userinfo_json):
return userinfo_json["login"]


def get_github_username(userinfo_json):
return "{} (GitHub)".format(userinfo_json["login"])

Expand Down

0 comments on commit a55ab78

Please sign in to comment.