From a1445520598320574d55f3a5969774637e400ac2 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 1 Mar 2020 22:55:56 +0100 Subject: [PATCH] providers/oidc: fill claims with userinfo --- passbook/providers/oidc/{lib.py => auth.py} | 0 passbook/providers/oidc/claims.py | 14 ++++++++++++++ passbook/providers/oidc/settings.py | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) rename passbook/providers/oidc/{lib.py => auth.py} (100%) create mode 100644 passbook/providers/oidc/claims.py diff --git a/passbook/providers/oidc/lib.py b/passbook/providers/oidc/auth.py similarity index 100% rename from passbook/providers/oidc/lib.py rename to passbook/providers/oidc/auth.py diff --git a/passbook/providers/oidc/claims.py b/passbook/providers/oidc/claims.py new file mode 100644 index 000000000..8ad905a22 --- /dev/null +++ b/passbook/providers/oidc/claims.py @@ -0,0 +1,14 @@ +"""passbook oidc claim helpers""" +from typing import Any, Dict + +from passbook.core.models import User + + +def userinfo(claims: Dict[str, Any], user: User) -> Dict[str, Any]: + """Populate claims from userdata""" + claims["name"] = user.name + claims["given_name"] = user.name + claims["family_name"] = user.name + claims["email"] = user.email + + return claims diff --git a/passbook/providers/oidc/settings.py b/passbook/providers/oidc/settings.py index 7d22fff0b..d6ce91e0b 100644 --- a/passbook/providers/oidc/settings.py +++ b/passbook/providers/oidc/settings.py @@ -4,5 +4,6 @@ INSTALLED_APPS = [ "oidc_provider", ] -OIDC_AFTER_USERLOGIN_HOOK = "passbook.providers.oidc.lib.check_permissions" +OIDC_AFTER_USERLOGIN_HOOK = "passbook.providers.oidc.auth.check_permissions" OIDC_IDTOKEN_INCLUDE_CLAIMS = True +OIDC_USERINFO = "passbook.providers.oidc.claims.userinfo"