From 45f25ee845d84ef340f82d933c96fe56c037ece1 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Thu, 7 Jul 2022 15:29:06 +0200 Subject: [PATCH] remove unused `GRAPH_SPACES_INSECURE` --- .../fix-remove-unused-GRAPH_SPACES_INSECURE.md | 5 +++++ services/graph/pkg/config/config.go | 1 - services/graph/pkg/config/defaults/defaultconfig.go | 1 - services/graph/pkg/service/v0/graph.go | 6 ------ services/graph/pkg/service/v0/graph_test.go | 3 --- services/graph/pkg/service/v0/option.go | 8 -------- services/graph/pkg/service/v0/password_test.go | 3 --- services/graph/pkg/service/v0/service.go | 9 --------- 8 files changed, 5 insertions(+), 31 deletions(-) create mode 100644 changelog/unreleased/fix-remove-unused-GRAPH_SPACES_INSECURE.md diff --git a/changelog/unreleased/fix-remove-unused-GRAPH_SPACES_INSECURE.md b/changelog/unreleased/fix-remove-unused-GRAPH_SPACES_INSECURE.md new file mode 100644 index 000000000..6b442414a --- /dev/null +++ b/changelog/unreleased/fix-remove-unused-GRAPH_SPACES_INSECURE.md @@ -0,0 +1,5 @@ +Bugfix: Fix unused config option `GRAPH_SPACES_INSECURE` + +We've removed the unused config option `GRAPH_SPACES_INSECURE` from the GRAPH service. + +https://github.com/owncloud/ocis/pull/55555 diff --git a/services/graph/pkg/config/config.go b/services/graph/pkg/config/config.go index 73b2fe9a1..d279a991c 100644 --- a/services/graph/pkg/config/config.go +++ b/services/graph/pkg/config/config.go @@ -32,7 +32,6 @@ type Spaces struct { WebDavBase string `yaml:"webdav_base" env:"OCIS_URL;GRAPH_SPACES_WEBDAV_BASE" desc:"The public facing URL of WebDAV."` WebDavPath string `yaml:"webdav_path" env:"GRAPH_SPACES_WEBDAV_PATH" desc:"The WebDAV subpath for spaces."` DefaultQuota string `yaml:"default_quota" env:"GRAPH_SPACES_DEFAULT_QUOTA" desc:"The default quota in bytes."` - Insecure bool `yaml:"insecure" env:"OCIS_INSECURE;GRAPH_SPACES_INSECURE" desc:"Allow insecure connetctions to the spaces."` ExtendedSpacePropertiesCacheTTL int `yaml:"extended_space_properties_cache_ttl" env:"GRAPH_SPACES_EXTENDED_SPACE_PROPERTIES_CACHE_TTL" desc:"Max TTL for the spaces property cache."` } diff --git a/services/graph/pkg/config/defaults/defaultconfig.go b/services/graph/pkg/config/defaults/defaultconfig.go index 47379b777..da9ef0ede 100644 --- a/services/graph/pkg/config/defaults/defaultconfig.go +++ b/services/graph/pkg/config/defaults/defaultconfig.go @@ -36,7 +36,6 @@ func DefaultConfig() *config.Config { WebDavBase: "https://localhost:9200", WebDavPath: "/dav/spaces/", DefaultQuota: "1000000000", - Insecure: false, }, Identity: config.Identity{ Backend: "ldap", diff --git a/services/graph/pkg/service/v0/graph.go b/services/graph/pkg/service/v0/graph.go index 9117b56b1..6853754a5 100644 --- a/services/graph/pkg/service/v0/graph.go +++ b/services/graph/pkg/service/v0/graph.go @@ -75,7 +75,6 @@ type Graph struct { logger *log.Logger identityBackend identity.Backend gatewayClient GatewayClient - httpClient HTTPClient roleService settingssvc.RoleService spacePropertiesCache *ttlcache.Cache eventsPublisher events.Publisher @@ -91,11 +90,6 @@ func (g Graph) GetGatewayClient() GatewayClient { return g.gatewayClient } -// GetClient returns a gateway client to talk to reva -func (g Graph) GetHTTPClient() HTTPClient { - return g.httpClient -} - func (g Graph) publishEvent(ev interface{}) { if err := events.Publish(g.eventsPublisher, ev); err != nil { g.logger.Error(). diff --git a/services/graph/pkg/service/v0/graph_test.go b/services/graph/pkg/service/v0/graph_test.go index a119713c3..9354449d7 100644 --- a/services/graph/pkg/service/v0/graph_test.go +++ b/services/graph/pkg/service/v0/graph_test.go @@ -29,7 +29,6 @@ var _ = Describe("Graph", func() { var ( svc service.Service gatewayClient *mocks.GatewayClient - httpClient *mocks.HTTPClient eventsPublisher mocks.Publisher ctx context.Context cfg *config.Config @@ -42,12 +41,10 @@ var _ = Describe("Graph", func() { cfg.TokenManager.JWTSecret = "loremipsum" gatewayClient = &mocks.GatewayClient{} - httpClient = &mocks.HTTPClient{} eventsPublisher = mocks.Publisher{} svc = service.NewService( service.Config(cfg), service.WithGatewayClient(gatewayClient), - service.WithHTTPClient(httpClient), service.EventsPublisher(&eventsPublisher), ) }) diff --git a/services/graph/pkg/service/v0/option.go b/services/graph/pkg/service/v0/option.go index 90a2b1b72..752c7de3c 100644 --- a/services/graph/pkg/service/v0/option.go +++ b/services/graph/pkg/service/v0/option.go @@ -21,7 +21,6 @@ type Options struct { Middleware []func(http.Handler) http.Handler GatewayClient GatewayClient IdentityBackend identity.Backend - HTTPClient HTTPClient RoleService settingssvc.RoleService RoleManager *roles.Manager EventsPublisher events.Publisher @@ -73,13 +72,6 @@ func WithIdentityBackend(val identity.Backend) Option { } } -// WithHTTPClient provides a function to set the http client option. -func WithHTTPClient(val HTTPClient) Option { - return func(o *Options) { - o.HTTPClient = val - } -} - // RoleService provides a function to set the RoleService option. func RoleService(val settingssvc.RoleService) Option { return func(o *Options) { diff --git a/services/graph/pkg/service/v0/password_test.go b/services/graph/pkg/service/v0/password_test.go index e26242ca7..a31f7775e 100644 --- a/services/graph/pkg/service/v0/password_test.go +++ b/services/graph/pkg/service/v0/password_test.go @@ -36,7 +36,6 @@ var _ = Describe("Users changing their own password", func() { var ( svc service.Service gatewayClient *mocks.GatewayClient - httpClient *mocks.HTTPClient ldapClient *mocks.Client ldapConfig config.LDAP identityBackend identity.Backend @@ -70,13 +69,11 @@ var _ = Describe("Users changing their own password", func() { identityBackend, err = identity.NewLDAPBackend(ldapClient, ldapConfig, &loggger) Expect(err).To(BeNil()) - httpClient = &mocks.HTTPClient{} eventsPublisher = mocks.Publisher{} svc = service.NewService( service.Config(cfg), service.WithGatewayClient(gatewayClient), service.WithIdentityBackend(identityBackend), - service.WithHTTPClient(httpClient), service.EventsPublisher(&eventsPublisher), ) user = &userv1beta1.User{ diff --git a/services/graph/pkg/service/v0/service.go b/services/graph/pkg/service/v0/service.go index 75066e61d..4f6799339 100644 --- a/services/graph/pkg/service/v0/service.go +++ b/services/graph/pkg/service/v0/service.go @@ -136,15 +136,6 @@ func NewService(opts ...Option) Service { svc.identityBackend = options.IdentityBackend } - if options.HTTPClient == nil { - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ - InsecureSkipVerify: options.Config.Spaces.Insecure, //nolint:gosec - } - svc.httpClient = &http.Client{} - } else { - svc.httpClient = options.HTTPClient - } - if options.RoleService == nil { svc.roleService = settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient) } else {