1
0
mirror of https://github.com/owncloud/ocis.git synced 2026-10-25 11:39:24 +03:00
Files
ocis/ocis-pkg/config/parser/parse.go
Roman Perekhod 9143307b70 fix: [ocisdev-1433] fix public share, add The grpc clients keepalive and more (#13020) (#13068)
* fix: the public share configuration and fixed graceful shutdown

* fix: [OCISDEV-1433] remove GRPC_MAX_CONNECTION_AGE

The setting closed healthy grpc connections on a timer so that clients would redo
their DNS lookup. It never helped against the failure it was reached for - a
connection whose peer stopped answering - because the age limit is enforced by
the server, the grace period was left at infinity so a request already in flight
was never ended, and any value without a unit suffix silently disabled it again.

Detecting a peer that stops answering is now the job of the grpc clients, which
ping the peer while a request is in flight. The servers here got the matching
enforcement policy so they accept those pings; the client side arrives with the
next reva bump.

* fix: Added the new variable OCDAV_DISABLE_PROPFIND_PUBLIC_LINK_RESOLUTION that disable the resolution of public link shares when answering PROPFIND requests.

* chore: bump reva

* fix: The keepalive added to grpc clinet

* chore: bump reva

* build(deps): bump go 1.26.8, grpc-go dependency

---------

(cherry picked from commit e86eb4d210)

For the 9.0 branch, the reva dependency was pointed at reva's main-branch
merge of PR #748 (commit 373f9509a, pseudo-version
v2.0.0-20261005091647-373f9509a363) instead of the 8.2-targeted
e0beaa380005, since the 8.2 merge predates the VaultMode/UploadSessionFilter.Orphaned
APIs already present on the 9.0 reva lineage.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

# Conflicts:
#	changelog/unreleased/security-bump-grpc.md
#	go.mod
#	go.sum
#	vendor/google.golang.org/grpc/server.go
#	vendor/google.golang.org/grpc/stream.go
#	vendor/google.golang.org/grpc/version.go
#	vendor/modules.txt
2026-10-06 17:21:46 +02:00

148 lines
3.6 KiB
Go

package parser
import (
"errors"
"github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
"github.com/owncloud/ocis/v2/ocis-pkg/structs"
)
// ParseConfig loads the ocis configuration and
// copies applicable parts into the commons part, from
// where the services can copy it into their own config
func ParseConfig(cfg *config.Config, skipValidate bool) error {
err := config.BindSourcesToStructs("ocis", cfg)
if err != nil {
return err
}
EnsureDefaults(cfg)
// load all env variables relevant to the config in the current context.
if err := envdecode.Decode(cfg); err != nil {
// no environment variable set for this config is an expected "error"
if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) {
return err
}
}
EnsureCommons(cfg)
if skipValidate {
return nil
}
return Validate(cfg)
}
// EnsureDefaults ensures that all pointers in the
// oCIS config (not the services configs) are initialized
func EnsureDefaults(cfg *config.Config) {
if cfg.Tracing == nil {
cfg.Tracing = &shared.Tracing{}
}
if cfg.Log == nil {
cfg.Log = &shared.Log{}
}
if cfg.TokenManager == nil {
cfg.TokenManager = &shared.TokenManager{}
}
if cfg.Cache == nil {
cfg.Cache = &shared.Cache{}
}
if cfg.GRPCClientTLS == nil {
cfg.GRPCClientTLS = &shared.GRPCClientTLS{}
}
if cfg.GRPCClientOptions == nil {
cfg.GRPCClientOptions = &shared.GRPCClientOptions{}
}
if cfg.GRPCServiceTLS == nil {
cfg.GRPCServiceTLS = &shared.GRPCServiceTLS{}
}
if cfg.Reva == nil {
cfg.Reva = &shared.Reva{}
}
}
// EnsureCommons copies applicable parts of the oCIS config into the commons part
func EnsureCommons(cfg *config.Config) {
// ensure the commons part is initialized
if cfg.Commons == nil {
cfg.Commons = &shared.Commons{}
}
cfg.Commons.Log = structs.CopyOrZeroValue(cfg.Log)
cfg.Commons.Tracing = structs.CopyOrZeroValue(cfg.Tracing)
cfg.Commons.Cache = structs.CopyOrZeroValue(cfg.Cache)
if cfg.GRPCClientTLS != nil {
cfg.Commons.GRPCClientTLS = cfg.GRPCClientTLS
}
if cfg.GRPCClientOptions != nil {
cfg.Commons.GRPCClientOptions = cfg.GRPCClientOptions
}
if cfg.GRPCServiceTLS != nil {
cfg.Commons.GRPCServiceTLS = cfg.GRPCServiceTLS
}
cfg.Commons.HTTPServiceTLS = cfg.HTTPServiceTLS
cfg.Commons.TokenManager = structs.CopyOrZeroValue(cfg.TokenManager)
// copy machine auth api key to the commons part if set
if cfg.MachineAuthAPIKey != "" {
cfg.Commons.MachineAuthAPIKey = cfg.MachineAuthAPIKey
}
if cfg.SystemUserAPIKey != "" {
cfg.Commons.SystemUserAPIKey = cfg.SystemUserAPIKey
}
// copy transfer secret to the commons part if set
if cfg.TransferSecret != "" {
cfg.Commons.TransferSecret = cfg.TransferSecret
}
// copy metadata user id to the commons part if set
if cfg.SystemUserID != "" {
cfg.Commons.SystemUserID = cfg.SystemUserID
}
// copy admin user id to the commons part if set
if cfg.AdminUserID != "" {
cfg.Commons.AdminUserID = cfg.AdminUserID
}
if cfg.OcisURL != "" {
cfg.Commons.OcisURL = cfg.OcisURL
}
cfg.Commons.Reva = structs.CopyOrZeroValue(cfg.Reva)
}
// Validate checks that all required configs are set. If a required config value
// is missing an error will be returned.
func Validate(cfg *config.Config) error {
if cfg.TokenManager.JWTSecret == "" {
return shared.MissingJWTTokenError("ocis")
}
if cfg.TransferSecret == "" {
return shared.MissingRevaTransferSecretError("ocis")
}
if cfg.MachineAuthAPIKey == "" {
return shared.MissingMachineAuthApiKeyError("ocis")
}
if cfg.SystemUserID == "" {
return shared.MissingSystemUserID("ocis")
}
return nil
}