diff --git a/internal/http/services/mailer/mailer.go b/internal/http/services/mailer/mailer.go index 3f47a5f64d..01ce3ae799 100644 --- a/internal/http/services/mailer/mailer.go +++ b/internal/http/services/mailer/mailer.go @@ -42,10 +42,14 @@ import ( "github.com/cs3org/reva/pkg/rgrpc/todo/pool" "github.com/cs3org/reva/pkg/rhttp/global" "github.com/cs3org/reva/pkg/sharedconf" + "github.com/cs3org/reva/pkg/tracing" "github.com/mitchellh/mapstructure" "github.com/rs/zerolog" ) +const serviceName = "mailer" +const tracerName = "mailer" + func init() { global.Register("mailer", New) } @@ -62,6 +66,7 @@ type config struct { } type svc struct { + tracing.HttpMiddleware conf *config client gateway.GatewayAPIClient tplBody *template.Template @@ -70,6 +75,9 @@ type svc struct { // New creates a new mailer service func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error) { + ctx, span := tracing.SpanStart(context.Background(), serviceName, tracerName, "New") + defer span.End() + conf := &config{} if err := mapstructure.Decode(m, conf); err != nil { return nil, err @@ -77,7 +85,7 @@ func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error) conf.init() - client, err := pool.GetGatewayServiceClient(pool.Endpoint(conf.GatewaySVC)) + client, err := pool.GetGatewayServiceClient(ctx, pool.Endpoint(conf.GatewaySVC)) if err != nil { return nil, err } diff --git a/pkg/auth/manager/oidc/oidc.go b/pkg/auth/manager/oidc/oidc.go index 37869028fa..22dd9b22d8 100644 --- a/pkg/auth/manager/oidc/oidc.go +++ b/pkg/auth/manager/oidc/oidc.go @@ -317,7 +317,7 @@ func (am *mgr) getOIDCProvider(ctx context.Context) (*oidc.Provider, error) { func (am *mgr) resolveUser(ctx context.Context, claims map[string]interface{}) error { ctx, span := tracing.SpanStartFromContext(ctx, tracerName, "resolveUser") defer span.End() - + var ( claim string value string @@ -355,44 +355,18 @@ func (am *mgr) resolveUser(ctx context.Context, claims map[string]interface{}) e for _, m := range intersection { value = am.oidcUsersMapping[m.(string)].Username } -<<<<<<< HEAD resolve = true } else if uid == 0 || gid == 0 { claim = "mail" value = claims["email"].(string) resolve = true -======= - - upsc, err := pool.GetUserProviderServiceClient(ctx, pool.Endpoint(am.c.GatewaySvc)) - if err != nil { - return errors.Wrap(err, "error getting user provider grpc client") - } - getUserByClaimResp, err := upsc.GetUserByClaim(ctx, &user.GetUserByClaimRequest{ - Claim: "username", - Value: username, - }) - if err != nil { - return errors.Wrapf(err, "error getting user by username '%v'", username) - } - if getUserByClaimResp.Status.Code != rpc.Code_CODE_OK { - return status.NewErrorFromCode(getUserByClaimResp.Status.Code, "oidc") - } - - // take the properties of the mapped target user to override the claims - claims["preferred_username"] = username - claims[am.c.IDClaim] = getUserByClaimResp.GetUser().GetId().OpaqueId - claims["iss"] = getUserByClaimResp.GetUser().GetId().Idp - claims[am.c.UIDClaim] = getUserByClaimResp.GetUser().UidNumber - claims[am.c.GIDClaim] = getUserByClaimResp.GetUser().GidNumber - appctx.GetLogger(ctx).Debug().Str("username", username).Interface("claims", claims).Msg("resolveUser: claims overridden from mapped user") ->>>>>>> dc7bec30 (tracing: instrument GRPC clients and the share, storage, utils, cbox and auth packages) } if !resolve { return nil } - upsc, err := pool.GetGatewayServiceClient(pool.Endpoint(am.c.GatewaySvc)) + upsc, err := pool.GetGatewayServiceClient(ctx, pool.Endpoint(am.c.GatewaySvc)) if err != nil { return errors.Wrap(err, "error getting user provider grpc client") } diff --git a/pkg/cbox/publicshare/sql/sql.go b/pkg/cbox/publicshare/sql/sql.go index 0b93ec9a7f..796b829560 100644 --- a/pkg/cbox/publicshare/sql/sql.go +++ b/pkg/cbox/publicshare/sql/sql.go @@ -379,7 +379,7 @@ func (m *manager) isProjectAdmin(ctx context.Context, u *user.User) bool { func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []*link.ListPublicSharesRequest_Filter, md *provider.ResourceInfo, sign bool) ([]*link.PublicShare, error) { ctx, span := tracing.SpanStartFromContext(ctx, tracerName, "ListPublicShares") defer span.End() - + query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(token,'') as token, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, id, stime, permissions, quicklink, description FROM oc_share WHERE (orphan = 0 or orphan IS NULL) AND (share_type=?) AND internal=false" var resourceFilters, ownerFilters, creatorFilters string var resourceParams, ownerParams, creatorParams []interface{} diff --git a/pkg/cbox/share/sql/sql.go b/pkg/cbox/share/sql/sql.go index 38cda86d91..e1602e4dbf 100644 --- a/pkg/cbox/share/sql/sql.go +++ b/pkg/cbox/share/sql/sql.go @@ -267,7 +267,7 @@ func (m *mgr) GetShare(ctx context.Context, ref *collaboration.ShareReference) ( func (m *mgr) Unshare(ctx context.Context, ref *collaboration.ShareReference) error { ctx, span := tracing.SpanStartFromContext(ctx, tracerName, "Unshare") defer span.End() - + var query string params := []interface{}{} switch { diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 883c055593..340a2e27c3 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -963,7 +963,7 @@ func encodeLock(l *provider.Lock) (string, error) { func (fs *eosfs) RefreshLock(ctx context.Context, ref *provider.Reference, newLock *provider.Lock, existingLockID string) error { ctx, span := tracing.SpanStartFromContext(ctx, tracerName, "RefreshLock") defer span.End() - + if newLock.Type == provider.LockType_LOCK_TYPE_SHARED { return errtypes.NotSupported("shared lock not yet implemented") }