From fba174641b152fde2b75efa2ea979a2544098820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 11 Aug 2020 10:23:46 +0200 Subject: [PATCH] lookup user by id as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/middleware/account_uuid.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/middleware/account_uuid.go b/pkg/middleware/account_uuid.go index 6639ad722..74d453e6b 100644 --- a/pkg/middleware/account_uuid.go +++ b/pkg/middleware/account_uuid.go @@ -112,7 +112,8 @@ func AccountUUID(opts ...Option) func(next http.Handler) http.Handler { if claims.Email != "" { account, status = getAccount(l, opt.AccountsClient, fmt.Sprintf("mail eq '%s'", strings.ReplaceAll(claims.Email, "'", "''"))) } else if claims.PreferredUsername != "" { - account, status = getAccount(l, opt.AccountsClient, fmt.Sprintf("preferred_name eq '%s'", strings.ReplaceAll(claims.PreferredUsername, "'", "''"))) + usernameOrID := strings.ReplaceAll(claims.PreferredUsername, "'", "''") + account, status = getAccount(l, opt.AccountsClient, fmt.Sprintf("preferred_name eq '%s' or id eq '%s'", usernameOrID, usernameOrID)) } else { // TODO allow lookup by custom claim, eg an id ... or sub l.Error().Err(err).Msgf("Could not lookup account, no mail or preferred_username claim set")