From a55ab7836b8330a11447785b9175874506af2c78 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Mon, 23 Dec 2024 17:44:18 +0100 Subject: [PATCH] fix userid generation --- frontend.py | 3 ++- util/sso/__init__.py | 2 ++ util/sso/github.py | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend.py b/frontend.py index 5622fdc..7274669 100644 --- a/frontend.py +++ b/frontend.py @@ -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) @@ -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 diff --git a/util/sso/__init__.py b/util/sso/__init__.py index 5f2954e..e0c0aa5 100644 --- a/util/sso/__init__.py +++ b/util/sso/__init__.py @@ -3,6 +3,7 @@ check_github_allowed_login, check_github_is_admin, check_github_no_limit, + get_github_userid, get_github_username, ) @@ -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, }, }, diff --git a/util/sso/github.py b/util/sso/github.py index 4c624ce..0f51c22 100644 --- a/util/sso/github.py +++ b/util/sso/github.py @@ -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"])