From afb2291eb91812986f8faff2f71f61ad355f2720 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 12 Jun 2020 12:00:21 +0200 Subject: [PATCH] Fix user claims on x-access-token Reva header; initialize cache size --- pkg/middleware/account_uuid.go | 8 +++++--- pkg/middleware/openidconnect.go | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/middleware/account_uuid.go b/pkg/middleware/account_uuid.go index 8f4bfbd6f2..c2abd3512e 100644 --- a/pkg/middleware/account_uuid.go +++ b/pkg/middleware/account_uuid.go @@ -2,8 +2,10 @@ package middleware import ( "context" - "github.com/owncloud/ocis-proxy/pkg/config" "net/http" + "strings" + + "github.com/owncloud/ocis-proxy/pkg/config" revauser "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" "github.com/cs3org/reva/pkg/token/manager/jwt" @@ -103,13 +105,13 @@ func AccountUUID(opts ...AccountMiddlewareOption) func(next http.Handler) http.H } } - l.Debug().Interface("claims", claims).Interface("uuid", uuid).Msgf("Associated claims with uuid") token, err := tokenManager.MintToken(r.Context(), &revauser.User{ Id: &revauser.UserId{ OpaqueId: uuid, }, - Username: claims.Email, + Username: strings.ToLower(claims.Name), + DisplayName: claims.Name, }) if err != nil { diff --git a/pkg/middleware/openidconnect.go b/pkg/middleware/openidconnect.go index 6b3b7a5c9e..c62c757310 100644 --- a/pkg/middleware/openidconnect.go +++ b/pkg/middleware/openidconnect.go @@ -19,7 +19,9 @@ var ( ErrInvalidToken = errors.New("invalid or missing token") // svcCache caches requests for given services to prevent round trips to the service - svcCache = cache.NewCache() + svcCache = cache.NewCache( + cache.Size(256), + ) // ClaimsKey works as a context key for user claims ClaimsKey interface{} = "claims"