trace proxie middlewares (#6313)
* trace proxie middlewares Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * Update ocis-pkg/service/grpc/client.go Co-authored-by: Christian Richter <1058116+dragonchaser@users.noreply.github.com> * default tls is off Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> --------- Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> Co-authored-by: Christian Richter <1058116+dragonchaser@users.noreply.github.com>
This commit is contained in:
co-authored by
Christian Richter
parent
12dff34442
commit
632b206675
@@ -18,7 +18,6 @@ import (
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/keycloak"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
|
||||
ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/service/http"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||
ehsvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/eventhistory/v0"
|
||||
@@ -26,6 +25,7 @@ import (
|
||||
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
|
||||
graphMiddleware "github.com/owncloud/ocis/v2/services/graph/pkg/middleware"
|
||||
svc "github.com/owncloud/ocis/v2/services/graph/pkg/service/v0"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/tracing"
|
||||
"github.com/pkg/errors"
|
||||
"go-micro.dev/v4"
|
||||
"go-micro.dev/v4/events"
|
||||
@@ -115,13 +115,17 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
var requireAdminMiddleware func(stdhttp.Handler) stdhttp.Handler
|
||||
var roleService svc.RoleService
|
||||
var gatewayClient gateway.GatewayAPIClient
|
||||
grpcClient, err := grpc.NewClient(append(grpc.GetClientOptions(options.Config.GRPCClientTLS), grpc.WithTraceProvider(tracing.TraceProvider))...)
|
||||
if err != nil {
|
||||
return http.Service{}, err
|
||||
}
|
||||
if options.Config.HTTP.APIToken == "" {
|
||||
middlewares = append(middlewares,
|
||||
graphMiddleware.Auth(
|
||||
account.Logger(options.Logger),
|
||||
account.JWTSecret(options.Config.TokenManager.JWTSecret),
|
||||
))
|
||||
roleService = settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient())
|
||||
roleService = settingssvc.NewRoleService("com.owncloud.api.settings", grpcClient)
|
||||
gatewayClient, err = pool.GetGatewayServiceClient(options.Config.Reva.Address, options.Config.Reva.GetRevaOptions()...)
|
||||
if err != nil {
|
||||
return http.Service{}, errors.Wrap(err, "could not initialize gateway client")
|
||||
@@ -145,7 +149,7 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
keyCloakClient = keycloak.New(kcc.BasePath, kcc.ClientID, kcc.ClientSecret, kcc.ClientRealm, kcc.InsecureSkipVerify)
|
||||
}
|
||||
|
||||
hClient := ehsvc.NewEventHistoryService("com.owncloud.api.eventhistory", ogrpc.DefaultClient())
|
||||
hClient := ehsvc.NewEventHistoryService("com.owncloud.api.eventhistory", grpcClient)
|
||||
|
||||
var handle svc.Service
|
||||
handle, err = svc.NewService(
|
||||
@@ -156,7 +160,7 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
svc.WithRoleService(roleService),
|
||||
svc.WithRequireAdminMiddleware(requireAdminMiddleware),
|
||||
svc.WithGatewayClient(gatewayClient),
|
||||
svc.WithSearchService(searchsvc.NewSearchProviderService("com.owncloud.api.search", grpc.DefaultClient())),
|
||||
svc.WithSearchService(searchsvc.NewSearchProviderService("com.owncloud.api.search", grpcClient)),
|
||||
svc.KeycloakClient(keyCloakClient),
|
||||
svc.EventHistoryClient(hClient),
|
||||
)
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
v0 "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/settings/v0"
|
||||
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/service/v0/errorcode"
|
||||
gtracing "github.com/owncloud/ocis/v2/services/graph/pkg/tracing"
|
||||
settingsServiceExt "github.com/owncloud/ocis/v2/services/settings/pkg/store/defaults"
|
||||
"github.com/pkg/errors"
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
@@ -582,13 +583,17 @@ func (g Graph) formatDrives(ctx context.Context, baseURL *url.URL, storageSpaces
|
||||
func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*storageprovider.ListStorageSpacesRequest_Filter, unrestricted bool) (*storageprovider.ListStorageSpacesResponse, error) {
|
||||
client := g.GetGatewayClient()
|
||||
|
||||
permissions := make(map[string]struct{}, 1)
|
||||
s := settingssvc.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient())
|
||||
grpcClient, err := grpc.NewClient(append(grpc.GetClientOptions(g.config.GRPCClientTLS), grpc.WithTraceProvider(gtracing.TraceProvider))...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s := settingssvc.NewPermissionService("com.owncloud.api.settings", grpcClient)
|
||||
|
||||
_, err := s.GetPermissionByID(ctx, &settingssvc.GetPermissionByIDRequest{
|
||||
_, err = s.GetPermissionByID(ctx, &settingssvc.GetPermissionByIDRequest{
|
||||
PermissionId: settingsServiceExt.ListAllSpacesPermissionID,
|
||||
})
|
||||
|
||||
permissions := make(map[string]struct{}, 1)
|
||||
// No error means the user has the permission
|
||||
if err == nil {
|
||||
permissions[settingsServiceExt.ListAllSpacesPermissionName] = struct{}{}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
|
||||
"github.com/owncloud/ocis/v2/services/graph/mocks"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/config/defaults"
|
||||
@@ -44,6 +45,7 @@ var _ = Describe("Users changing their own password", func() {
|
||||
ctx = context.Background()
|
||||
cfg = defaults.FullDefaultConfig()
|
||||
cfg.TokenManager.JWTSecret = "loremipsum"
|
||||
cfg.GRPCClientTLS = &shared.GRPCClientTLS{}
|
||||
|
||||
gatewayClient = &cs3mocks.GatewayAPIClient{}
|
||||
ldapClient = mockedLDAPClient()
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/identity"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/identity/ldap"
|
||||
graphm "github.com/owncloud/ocis/v2/services/graph/pkg/middleware"
|
||||
gtracing "github.com/owncloud/ocis/v2/services/graph/pkg/tracing"
|
||||
microstore "go-micro.dev/v4/store"
|
||||
)
|
||||
|
||||
@@ -155,7 +156,11 @@ func NewService(opts ...Option) (Graph, error) {
|
||||
}
|
||||
|
||||
if options.PermissionService == nil {
|
||||
svc.permissionsService = settingssvc.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient())
|
||||
grpcClient, err := grpc.NewClient(append(grpc.GetClientOptions(options.Config.GRPCClientTLS), grpc.WithTraceProvider(gtracing.TraceProvider))...)
|
||||
if err != nil {
|
||||
return svc, err
|
||||
}
|
||||
svc.permissionsService = settingssvc.NewPermissionService("com.owncloud.api.settings", grpcClient)
|
||||
} else {
|
||||
svc.permissionsService = options.PermissionService
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user