mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-31 01:11:23 -05:00
* refactor middleware options Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * use ocmemstore micro store implementaiton for token cache Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * refactor ocis store options, support redis sentinel Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * align cache configuration Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * database and tabe are used to build prefixes for inmemory stores Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add global persistent store options to userlog config Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * log cache errors but continue Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * drup unnecessary type conversion Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * Better description for the default userinfo ttl Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * use global cache options for even more caches Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * don't log userinfo cache misses Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * default to stock memory store Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * use correct mem store typo string Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * split cache options, doc cleanup Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * mint and write userinfo to cache async Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * use hashed token as key Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * go mod tidy Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * update docs Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * update cache store naming Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * bring back depreceted ocis-pkg/store package for backwards compatability Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * update changelog Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * Apply suggestions from code review Co-authored-by: kobergj <jkoberg@owncloud.com> * revert ocis-pkg/cache to store rename Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add waiting for each step 50 milliseconds * starlack check --------- Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> Co-authored-by: kobergj <jkoberg@owncloud.com> Co-authored-by: Viktor Scharf <scharf.vi@gmail.com>
167 lines
5.1 KiB
Go
167 lines
5.1 KiB
Go
package defaults
|
|
|
|
import (
|
|
"path"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/config/defaults"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/structs"
|
|
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
|
|
)
|
|
|
|
// FullDefaultConfig returns a fully initialized default configuration
|
|
func FullDefaultConfig() *config.Config {
|
|
cfg := DefaultConfig()
|
|
EnsureDefaults(cfg)
|
|
Sanitize(cfg)
|
|
return cfg
|
|
}
|
|
|
|
// DefaultConfig returns a basic default configuration
|
|
func DefaultConfig() *config.Config {
|
|
return &config.Config{
|
|
Debug: config.Debug{
|
|
Addr: "127.0.0.1:9124",
|
|
Token: "",
|
|
},
|
|
HTTP: config.HTTP{
|
|
Addr: "127.0.0.1:9120",
|
|
Namespace: "com.owncloud.graph",
|
|
Root: "/graph",
|
|
},
|
|
Service: config.Service{
|
|
Name: "graph",
|
|
},
|
|
Application: config.Application{
|
|
DisplayName: "ownCloud Infinite Scale",
|
|
},
|
|
API: config.API{
|
|
GroupMembersPatchLimit: 20,
|
|
UsernameMatch: "default",
|
|
AssignDefaultUserRole: true,
|
|
},
|
|
Reva: shared.DefaultRevaConfig(),
|
|
Spaces: config.Spaces{
|
|
WebDavBase: "https://localhost:9200",
|
|
WebDavPath: "/dav/spaces/",
|
|
DefaultQuota: "1000000000",
|
|
// 30 minutes
|
|
GroupsCacheTTL: 1800,
|
|
// 30 minutes
|
|
UsersCacheTTL: 1800,
|
|
},
|
|
Identity: config.Identity{
|
|
Backend: "ldap",
|
|
LDAP: config.LDAP{
|
|
URI: "ldaps://localhost:9235",
|
|
Insecure: false,
|
|
CACert: path.Join(defaults.BaseDataPath(), "idm", "ldap.crt"),
|
|
BindDN: "uid=libregraph,ou=sysusers,o=libregraph-idm",
|
|
UseServerUUID: false,
|
|
UsePasswordModExOp: true,
|
|
WriteEnabled: true,
|
|
UserBaseDN: "ou=users,o=libregraph-idm",
|
|
UserSearchScope: "sub",
|
|
UserFilter: "",
|
|
UserObjectClass: "inetOrgPerson",
|
|
UserEmailAttribute: "mail",
|
|
UserDisplayNameAttribute: "displayName",
|
|
UserNameAttribute: "uid",
|
|
// FIXME: switch this to some more widely available attribute by default
|
|
// ideally this needs to be constant for the lifetime of a users
|
|
UserIDAttribute: "owncloudUUID",
|
|
UserTypeAttribute: "ownCloudUserType",
|
|
UserEnabledAttribute: "ownCloudUserEnabled",
|
|
DisableUserMechanism: "attribute",
|
|
LdapDisabledUsersGroupDN: "cn=DisabledUsersGroup,ou=groups,o=libregraph-idm",
|
|
GroupBaseDN: "ou=groups,o=libregraph-idm",
|
|
GroupSearchScope: "sub",
|
|
GroupFilter: "",
|
|
GroupObjectClass: "groupOfNames",
|
|
GroupNameAttribute: "cn",
|
|
GroupIDAttribute: "owncloudUUID",
|
|
EducationResourcesEnabled: false,
|
|
},
|
|
},
|
|
Cache: &config.Cache{
|
|
Store: "memory",
|
|
Database: "graph",
|
|
Table: "roles",
|
|
TTL: time.Hour * 336,
|
|
},
|
|
Events: config.Events{
|
|
Endpoint: "127.0.0.1:9233",
|
|
Cluster: "ocis-cluster",
|
|
EnableTLS: false,
|
|
},
|
|
}
|
|
}
|
|
|
|
// EnsureDefaults adds default values to the configuration if they are not set yet
|
|
func EnsureDefaults(cfg *config.Config) {
|
|
// provide with defaults for shared logging, since we need a valid destination address for "envdecode".
|
|
if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil {
|
|
cfg.Log = &config.Log{
|
|
Level: cfg.Commons.Log.Level,
|
|
Pretty: cfg.Commons.Log.Pretty,
|
|
Color: cfg.Commons.Log.Color,
|
|
File: cfg.Commons.Log.File,
|
|
}
|
|
} else if cfg.Log == nil {
|
|
cfg.Log = &config.Log{}
|
|
}
|
|
// provide with defaults for shared tracing, since we need a valid destination address for "envdecode".
|
|
if cfg.Tracing == nil && cfg.Commons != nil && cfg.Commons.Tracing != nil {
|
|
cfg.Tracing = &config.Tracing{
|
|
Enabled: cfg.Commons.Tracing.Enabled,
|
|
Type: cfg.Commons.Tracing.Type,
|
|
Endpoint: cfg.Commons.Tracing.Endpoint,
|
|
Collector: cfg.Commons.Tracing.Collector,
|
|
}
|
|
} else if cfg.Tracing == nil {
|
|
cfg.Tracing = &config.Tracing{}
|
|
}
|
|
|
|
if cfg.Cache == nil && cfg.Commons != nil && cfg.Commons.Cache != nil {
|
|
cfg.Cache = &config.Cache{
|
|
Store: cfg.Commons.Cache.Store,
|
|
Nodes: cfg.Commons.Cache.Nodes,
|
|
Size: cfg.Commons.Cache.Size,
|
|
}
|
|
} else if cfg.Cache == nil {
|
|
cfg.Cache = &config.Cache{}
|
|
}
|
|
|
|
if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil {
|
|
cfg.TokenManager = &config.TokenManager{
|
|
JWTSecret: cfg.Commons.TokenManager.JWTSecret,
|
|
}
|
|
} else if cfg.TokenManager == nil {
|
|
cfg.TokenManager = &config.TokenManager{}
|
|
}
|
|
|
|
if cfg.GRPCClientTLS == nil && cfg.Commons != nil {
|
|
cfg.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS)
|
|
}
|
|
|
|
if cfg.Commons != nil {
|
|
cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS
|
|
}
|
|
}
|
|
|
|
// Sanitize sanitized the configuration
|
|
func Sanitize(cfg *config.Config) {
|
|
// sanitize config
|
|
if cfg.HTTP.Root != "/" {
|
|
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
|
|
}
|
|
|
|
// convert ttl to millisecond
|
|
// the config is in seconds, therefore we need multiply it.
|
|
cfg.Spaces.ExtendedSpacePropertiesCacheTTL = cfg.Spaces.ExtendedSpacePropertiesCacheTTL * int(time.Second)
|
|
cfg.Spaces.GroupsCacheTTL = cfg.Spaces.GroupsCacheTTL * int(time.Second)
|
|
cfg.Spaces.UsersCacheTTL = cfg.Spaces.UsersCacheTTL * int(time.Second)
|
|
}
|