Skip to content

Commit

Permalink
Remove extra logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Apr 30, 2021
1 parent 4d5948d commit 01b01b6
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 26 deletions.
13 changes: 3 additions & 10 deletions internal/grpc/interceptors/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ func NewUnary(m map[string]interface{}, unprotected []string) (grpc.UnaryServerI
return handler(ctx, req)
}

log.Info().Msgf("GRPC unary interceptor %s, %+v", info.FullMethod, req)

span.AddAttributes(trace.BoolAttribute("auth_enabled", true))

tkn, ok := token.ContextGetToken(ctx)
Expand Down Expand Up @@ -165,7 +163,6 @@ func NewStream(m map[string]interface{}, unprotected []string) (grpc.StreamServe
interceptor := func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
ctx := ss.Context()
log := appctx.GetLogger(ctx)
log.Info().Msgf("GRPC stream interceptor %s, %+v", info.FullMethod, unprotected)

if utils.Skip(info.FullMethod, unprotected) {
log.Debug().Str("method", info.FullMethod).Msg("skipping auth")
Expand Down Expand Up @@ -221,12 +218,9 @@ func (ss *wrappedServerStream) Context() context.Context {

func dismantleToken(ctx context.Context, tkn string, req interface{}, mgr token.Manager, gatewayAddr string) (*userpb.User, error) {
u, scope, err := mgr.DismantleToken(ctx, tkn, req)
log := appctx.GetLogger(ctx)
log.Info().Msgf("scope: %+v, req: %+v", scope["publicshare"], req)

// Check if the err returned is PermissionDenied
if _, ok := err.(errtypes.PermissionDenied); ok {
log.Info().Msgf("resolving ref %+v", req)
// Check if req is of type *provider.Reference_Path
// If yes, the request might be coming from a share where the accessor is
// trying to impersonate the owner, since the share manager doesn't know the
Expand All @@ -237,6 +231,8 @@ func dismantleToken(ctx context.Context, tkn string, req interface{}, mgr token.
// Try to extract the resource ID from the scope resource.
// Currently, we only check for public shares, but this will be extended
// for OCM shares, guest accounts, etc.
log := appctx.GetLogger(ctx)
log.Info().Msgf("resolving path reference to ID to check token scope %+v", ref.GetPath())
var share link.PublicShare
err = utils.UnmarshalJSONToProtoV1(scope["publicshare"].Resource.Value, &share)
if err != nil {
Expand Down Expand Up @@ -280,10 +276,7 @@ func dismantleToken(ctx context.Context, tkn string, req interface{}, mgr token.
if err != nil {
return nil, err
}
u, _, err = mgr.DismantleToken(ctx, tkn, req)
if err != nil {
return nil, err
}
return dismantleToken(ctx, tkn, req, mgr, gatewayAddr)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion internal/grpc/services/authprovider/authprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func (s *service) Authenticate(ctx context.Context, req *provider.AuthenticateRe
switch v := err.(type) {
case nil:
log.Info().Msgf("user %s authenticated", u.String())
log.Info().Msgf("authprovider scope %+v", scope)
return &provider.AuthenticateResponse{
Status: status.NewOK(ctx),
User: u,
Expand Down
4 changes: 1 addition & 3 deletions internal/grpc/services/gateway/authprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ func (s *svc) Authenticate(ctx context.Context, req *gateway.AuthenticateRequest
Status: status.NewInternal(ctx, err, "user is nil"),
}, nil
}
log.Info().Msgf("gateway scope %+v", res.TokenScope)

uid := res.User.Id
if uid == nil {
if res.User.Id == nil {
err := errors.New("gateway: uid after Authenticate is nil")
log.Err(err).Msg("user id is nil")
return &gateway.AuthenticateResponse{
Expand Down
2 changes: 0 additions & 2 deletions internal/http/interceptors/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func New(m map[string]interface{}, unprotected []string) (global.Middleware, err
}

log := appctx.GetLogger(ctx)
log.Info().Msgf("HTTP interceptor %s, %+v", r.URL.Path, unprotected)

// skip auth for urls set in the config.
// TODO(labkode): maybe use method:url to bypass auth.
Expand Down Expand Up @@ -234,7 +233,6 @@ func New(m map[string]interface{}, unprotected []string) (global.Middleware, err
}

// validate token
// TODO(ishank011): resolve resourceID/path and check
u, _, err := tokenManager.DismantleToken(r.Context(), tkn, r.URL.Path)
if err != nil {
log.Error().Err(err).Msg("error dismantling token")
Expand Down
3 changes: 0 additions & 3 deletions pkg/auth/manager/publicshares/publicshares.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/auth"
"github.com/cs3org/reva/pkg/auth/manager/registry"
"github.com/cs3org/reva/pkg/errtypes"
Expand Down Expand Up @@ -132,8 +131,6 @@ func (m *manager) Authenticate(ctx context.Context, token, secret string) (*user
if err != nil {
return nil, nil, err
}
log := appctx.GetLogger(ctx)
log.Info().Msgf("publichare scope: %+v", scope)

return getUserResponse.GetUser(), scope, nil
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/publicshare/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,6 @@ func (m *manager) getByToken(ctx context.Context, token string) (*link.PublicSha

// GetPublicShareByToken gets a public share by its opaque token.
func (m *manager) GetPublicShareByToken(ctx context.Context, token string, auth *link.PublicShareAuthentication, sign bool) (*link.PublicShare, error) {
log := appctx.GetLogger(ctx)
log.Info().Msgf("GetPublicShareByToken %s %+v", token, auth)
db, err := m.readDb()
if err != nil {
return nil, err
Expand All @@ -524,7 +522,6 @@ func (m *manager) GetPublicShareByToken(ctx context.Context, token string, auth
if err := utils.UnmarshalJSONToProtoV1([]byte(v.(map[string]interface{})["share"].(string)), &local); err != nil {
return nil, err
}
log.Info().Msgf("GetPublicShareByToken listing keys %s", local.Token)

if local.Token == token {
if !notExpired(&local) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/token/manager/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

auth "github.com/cs3org/go-cs3apis/cs3/auth/provider/v1beta1"
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/auth/scope"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/sharedconf"
Expand Down Expand Up @@ -120,10 +119,7 @@ func (m *manager) DismantleToken(ctx context.Context, tkn string, resource inter
}

if claims, ok := token.Claims.(*claims); ok && token.Valid {
log := appctx.GetLogger(ctx)
log.Info().Msgf("jwt scope: %+v", claims.Scope)
ok, err = scope.VerifyScope(claims.Scope, resource)
log.Info().Msgf("jwt ok: %+v, err %+v", ok, err)
if err != nil {
return nil, nil, errtypes.InternalError("error verifying scope of access token")
}
Expand Down

0 comments on commit 01b01b6

Please sign in to comment.