config

package
v4.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2023 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package config provides tools for managing configurations

Index

Constants

View Source
const (
	// KeyFrontPluginEnabled is the frontend config to enable/disable plugins
	KeyFrontPluginEnabled = "PYDIO_PLUGIN_ENABLED"
	// DefaultOAuthClientID set the default client id to use
	DefaultOAuthClientID = "cells-frontend"
)

Variables

View Source
var (
	DefaultBindingSite = &install.ProxyConfig{
		Binds:       []string{"0.0.0.0:" + runtime.DefaultBindingSitePort},
		TLSConfig:   &install.ProxyConfig_SelfSigned{SelfSigned: &install.TLSSelfSigned{}},
		SSLRedirect: false,
	}
)
View Source
var SampleConfig = `{
	"version": "` + common.Version().String() + `",
	"defaults": {
		"update": {
			"publicKey": "` + common.UpdateDefaultPublicKey + `",
			"updateUrl": "` + common.UpdateDefaultServerUrl + `"
		}
	},
    "ports":{
        "nats": 4222
    },
    "frontend":{
        "secureHeaders":{
			"X-XSS-Protection": "1; mode=block"
		},
        "plugin": {
            "editor.libreoffice": {
                "LIBREOFFICE_HOST": "localhost",
                "LIBREOFFICE_PORT": "9980",
                "LIBREOFFICE_SSL": true
            }
        }
    },
    "services":{
        "pydio.grpc.config":{
            "dsn": "default"
        },
        "pydio.grpc.user":{
            "dsn": "default",
            "tables":{
                "tree": "idm_user_tree",
                "nodes":"idm_user_nodes",
                "roles":"idm_user_roles",
                "attributes":"idm_user_attributes"
            }
        },
		"pydio.grpc.mailer": {
			"queue": {
				"@value": "boltdb"
			},
			"sender": {
				"@value": "disabled"
			}
		},
        "pydio.grpc.role":{
            "dsn": "default"
        },
        "pydio.grpc.workspace":{
            "dsn": "default"
        },
        "pydio.grpc.acl":{
            "dsn": "default"
        },
        "pydio.grpc.tree":{
            "dsn":"default"
        },
        "pydio.grpc.meta":{
            "dsn":"default"
        },
        "pydio.thumbs_store":{
            "datasource" : "default",
            "bucket"     : "thumbs"
        },
        "pydio.docstore-binaries":{
            "datasource" : "default",
            "bucket"     : "binaries"
        },
        "pydio.versions-store":{
            "datasource" : "default",
            "bucket"     : "versions"
        },
        "pydio.grpc.search": {
            "indexContent": false,
			"basenameAnalyzer": "standard",
			"contentAnalyzer": "en"
        },
		"pydio.grpc.policy": {
			"dsn": "databaseParseTime"
		},
        "pydio.grpc.data-key": {
            "dsn": "default"
        },
        "pydio.grpc.user-key": {
            "dsn": "default"
        },
		"pydio.grpc.update" : {
			"channel": "` + common.UpdateDefaultChannel + `"
		},
		"pydio.grpc.user-meta": {
			"dsn": "default"
		},
        "pydio.grpc.tasks": {
            "fork": true
        },
		"pydio.web.oauth":{
			"connectors": [
				{
					"type": "pydio",
					"id"  : "pydio",
					"name": "Pydio Cells"
				}
			],
			"cors": {
				"public": {
					"allowedOrigins": "*"
				}
			},
			"staticClients": [
                {
					"client_id": "` + DefaultOAuthClientID + `",
					"client_name": "CellsFrontend Application",
					"revokeRefreshTokenAfterInactivity": "2h",
					"grant_types": [
						"authorization_code", 
						"refresh_token"
					],
					"redirect_uris": [
						"#default_bind#/auth/callback"
                    ],
                    "post_logout_redirect_uris": [
                        "#default_bind#/auth/logout"
                    ],
					"response_types": ["code", "token", "id_token"],
					"scope": "openid email profile pydio offline"
				},
				{
					"client_id": "cells-sync",
					"client_name": "CellsSync Application",
					"grant_types": [
						"authorization_code", 
						"refresh_token"
					],
					"redirect_uris": [
						"http://localhost:3000/servers/callback",
						"http://localhost:[3636-3666]/servers/callback"
					],
					"response_types": ["code", "token", "id_token"],
					"scope": "openid email profile pydio offline"
				},
				{
					"client_id": "cells-client",
					"client_name": "Cells Client CLI Tool",
					"grant_types": [
						"authorization_code",
						"refresh_token"
					],
					"redirect_uris": [
						"http://localhost:3000/servers/callback",
						"#binds...#/oauth2/oob"
					],
					"response_types": [
						"code",
						"token",
						"id_token"
					],
					"scope": "openid email profile pydio offline"
				},
				{
					"client_id": "cells-mobile",
					"client_name": "Mobile Applications",
					"grant_types": [
						"authorization_code",
						"refresh_token"
					],
					"redirect_uris": [
						"cellsauth://callback"
					],
					"response_types": [
						"code",
						"token",
						"id_token"
					],
					"scope": "openid email profile pydio offline"
				}
			]
		}
    }
}`

SampleConfig is the default config used during the first install

Functions

func DefaultBindOverrideToFlags

func DefaultBindOverrideToFlags() (flags []string)

func Del

func Del(path ...string)

Del value at a certain path

func DelSecret

func DelSecret(uuid string)

DelSecret deletes the value of a uuid in the vault

func EnvOverrideDefaultBind

func EnvOverrideDefaultBind() bool

func ExposedConfigsForService

func ExposedConfigsForService(serviceName string) common.XMLSerializableForm

ExposedConfigsForService returns exposed configs for service

func FactorizeMinioServers

func FactorizeMinioServers(existingConfigs map[string]*object.MinioConfig, newSource *object.DataSource, update bool) (config *object.MinioConfig, e error)

FactorizeMinioServers tries to find exisiting MinioConfig that can be directly reused by the new source, or creates a new one

func Get

func Get(path ...string) configx.Values

Get access to the underlying structure at a certain path

func GetDatabase

func GetDatabase(key string) (string, string)

GetDatabase retrieves the database data from the config

func GetDefaultSiteURL

func GetDefaultSiteURL(sites ...*install.ProxyConfig) string

GetDefaultSiteURL returns the first available bindURL of all available sites

func GetPublicBaseUri

func GetPublicBaseUri() string

GetPublicBaseUri returns the default public uri

func GetSecret

func GetSecret(uuid string) configx.Values

GetSecret returns the non encrypted value for a uuid

func GetSitesAllowedURLs

func GetSitesAllowedURLs() map[string]*url.URL

GetSitesAllowedURLs returns a map of hostname => url for all sites. TODO : this function could switch to a list of specific authorized hostnames

func GetSourceInfoByName

func GetSourceInfoByName(dsName string) (*object.DataSource, error)

func GetStorageDriver

func GetStorageDriver(configKey, serviceName string) (driver string, dsn string, defined bool)

GetStorageDriver looks up for a storage driver/dsn definition It may find databases/[(services/{serviceName}/storage)|{serviceName}|default]

func GetTLSClientConfig

func GetTLSClientConfig(t string) *tls.Config

GetTLSClientConfig returns the configuration ssl for a server handler.

func GetTLSServerConfig

func GetTLSServerConfig(t string) *tls.Config

GetTLSServerConfig returns the configuration ssl for a server handler

func GetUpdatesConfigs

func GetUpdatesConfigs() configx2.Values

GetUpdatesConfigs gather update configs from correct location

func HasDatabase

func HasDatabase(key string) bool

HasDatabase checks if DB key is set

func IndexServiceTableNames

func IndexServiceTableNames(dsName string) map[string]string

IndexServiceTableNames returns table names for indexes

func IsRestEditable

func IsRestEditable(path string) bool

IsRestEditable checks if the given path is allowed to be read/written via the REST API.

func ListMinioConfigsFromConfig

func ListMinioConfigsFromConfig() map[string]*object.MinioConfig

ListMinioConfigsFromConfig scans configs for objects services configs

func ListSourcesFromConfig

func ListSourcesFromConfig() map[string]*object.DataSource

ListSourcesFromConfig scans configs for sync services configs

func LoadSites

func LoadSites(configOnly ...bool) ([]*install.ProxyConfig, error)

LoadSites returns all sites defined by order of preference : - ENV VARS - YAML CONFIG - INTERNAL CONFIG - If none is found, returns a default value If configOnly is set to true, will only return the ones saved in configs

func MinioConfigNamesToConfig

func MinioConfigNamesToConfig(sources map[string]*object.MinioConfig)

MinioConfigNamesToConfig saves objects sources to config

func NewKeyForSecret

func NewKeyForSecret() string

NewKeyForSecret creates a new random key

func Register

func Register(store Store)

Register the default config store

func RegisterExposedConfigs

func RegisterExposedConfigs(serviceName string, form common.XMLSerializableForm)

RegisterExposedConfigs let services register specific forms for configs editions Used by discovery service

func RegisterProxy added in v4.0.1

func RegisterProxy(key string, interceptors ...interface{})

func RegisterRestEditablePath

func RegisterRestEditablePath(segments ...string)

RegisterRestEditablePath registers a config path that can be exposed and modified via the REST API

func RegisterRevisionsStore added in v4.0.1

func RegisterRevisionsStore(store revisions.Store)

RegisterRevisionsStore sets the default version store

func RegisterVault

func RegisterVault(store Store)

RegisterVault sets the default vault

func RegisterVaultKey

func RegisterVaultKey(s ...string)

RegisterVaultKey adds a key to the configuration so that the value associated with the key is swapped to an encrypted value

func ResetTlsConfigs

func ResetTlsConfigs()

func RevisionsStore added in v4.0.1

func RevisionsStore() revisions.Store

func Save

func Save(ctxUser string, ctxMessage string) error

Save the config in the hard store

func SaveSites

func SaveSites(sites []*install.ProxyConfig, user, msg string) error

SaveSites saves a list of sites inside configuration

func Set

func Set(val interface{}, path ...string) error

Set new values at a certain path

func SetDatabase

func SetDatabase(key string, driver string, dsn string, defaultsKey string) error

SetDatabase adds a database entry, plus an optional reference in the defaults

func SetSecret

func SetSecret(uuid string, val string)

SetSecret set the value for a uuid in the vault TODO error handling ?

func SourceNamesFiltered

func SourceNamesFiltered(names []string) []string

SourceNamesFiltered excludes the timestamp key from a slice of source names

func SourceNamesForDataServices

func SourceNamesForDataServices(dataSrvType string) []string

SourceNamesForDataServices list sourceNames from the config, excluding the timestamp key

func SourceNamesFromDataConfigs

func SourceNamesFromDataConfigs(values configx.Values) []string

SourceNamesFromDataConfigs list sourceNames from the config, excluding the timestamp key

func SourceNamesToConfig

func SourceNamesToConfig(sources map[string]*object.DataSource)

SourceNamesToConfig saves index and sync sources to configs

func TouchSourceNamesForDataServices

func TouchSourceNamesForDataServices(dataSrvType string)

TouchSourceNamesForDataServices update the timestamp set with the source list

func UnusedMinioServers

func UnusedMinioServers(minios map[string]*object.MinioConfig, sources map[string]*object.DataSource) []string

UnusedMinioServers searches for existing minio configs that are not used anywhere in datasources

func Vault

func Vault() configx.Entrypoint

Vault returns the default vault

func Watch

func Watch(opts ...configx.WatchOption) (configx.Receiver, error)

Watch for config changes for a specific path or underneath

Types

type DistributedStore added in v4.0.6

type DistributedStore interface {
	NewLocker(name string) sync.Locker
}

type ProxyDeleter added in v4.0.1

type ProxyDeleter func(Store, ...string) error

type ProxyGetter added in v4.0.1

type ProxyGetter func(Store, ...string) configx.Values

type ProxySetter added in v4.0.1

type ProxySetter func(Store, interface{}, ...string) error

type RevisionsProvider added in v4.0.1

type RevisionsProvider interface {
	AsRevisionsStore(...RevisionsStoreOption) (Store, revisions.Store)
}

type RevisionsStoreOption added in v4.0.1

type RevisionsStoreOption func(o *RevisionsStoreOptions)

func WithDebounce added in v4.0.1

func WithDebounce(d time.Duration) RevisionsStoreOption

type RevisionsStoreOptions added in v4.0.1

type RevisionsStoreOptions struct {
	Debounce time.Duration
}

type Saver

type Saver interface {
	Save(string, string) error
}

type Store

type Store interface {
	configx.Entrypoint
	configx.Watcher
	Close() error
	Done() <-chan struct{}
	Saver
	sync.Locker
}

Store defines the functionality a config must provide

func NewVault

func NewVault(vaultStore, configStore Store) Store

NewVault creates a new vault with a standard config store and a vault store

func NewVersionStore

func NewVersionStore(vs revisions.Store, store Store) Store

NewVersionStore based on a file Version Store and a store

func OpenStore

func OpenStore(ctx context.Context, urlstr string) (Store, error)

OpenStore opens the Store identified by the URL given. See the URLOpener documentation in driver subpackages for details on supported URL formats, and https://gocloud.dev/concepts/urls for more information.

func Proxy added in v4.0.1

func Proxy(store Store) Store

type URLMux

type URLMux struct {
	// contains filtered or unexported fields
}

URLMux is a URL opener multiplexer. It matches the scheme of the URLs against a set of registered schemes and calls the opener that matches the URL's scheme. See https://gocloud.dev/concepts/urls/ for more information.

The zero value is a multiplexer with no registered schemes.

func DefaultURLMux

func DefaultURLMux() *URLMux

DefaultURLMux returns the URLMux used by OpenTopic and OpenSubscription.

Driver packages can use this to register their TopicURLOpener and/or SubscriptionURLOpener on the mux.

func (*URLMux) OpenStore

func (mux *URLMux) OpenStore(ctx context.Context, urlstr string) (Store, error)

OpenStore calls OpenURL with the URL parsed from urlstr. OpenStore is safe to call from multiple goroutines.

func (*URLMux) Register

func (mux *URLMux) Register(scheme string, opener URLOpener)

Register registers the opener with the given scheme. If an opener already exists for the scheme, Register panics.

func (*URLMux) Schemes

func (mux *URLMux) Schemes() []string

Schemes returns a sorted slice of the registered schemes.

func (*URLMux) ValidScheme

func (mux *URLMux) ValidScheme(scheme string) bool

ValidScheme returns true if scheme has been registered.

type URLOpener

type URLOpener interface {
	OpenURL(ctx context.Context, u *url.URL) (Store, error)
}

URLOpener represents types than can open Registries based on a URL. The opener must not modify the URL argument. OpenURL must be safe to call from multiple goroutines.

This interface is generally implemented by types in driver packages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL