mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-27 15:09:31 -06:00
gateway config docs
This commit is contained in:
@@ -21,29 +21,30 @@ type Config struct {
|
||||
|
||||
SkipUserGroupsInToken bool `yaml:"-"`
|
||||
|
||||
CommitShareToStorageGrant bool `yaml:"commit_share_to_storage_grant"`
|
||||
CommitShareToStorageRef bool `yaml:"commit_share_to_storage_ref"`
|
||||
ShareFolder string `yaml:"share_folder"`
|
||||
DisableHomeCreationOnLogin bool `yaml:"disable_home_creation_on_login"`
|
||||
TransferSecret string `yaml:"transfer_secret" env:"STORAGE_TRANSFER_SECRET"`
|
||||
TransferExpires int `yaml:"transfer_expires"`
|
||||
HomeMapping string `yaml:"home_mapping"`
|
||||
EtagCacheTTL int `yaml:"etag_cache_ttl"`
|
||||
CommitShareToStorageGrant bool `yaml:"commit_share_to_storage_grant" env:"GATEWAY_COMMIT_SHARE_TO_STORAGE_GRANT"`
|
||||
CommitShareToStorageRef bool `yaml:"commit_share_to_storage_ref" env:"GATEWAY_COMMIT_SHARE_TO_STORAGE_REF"`
|
||||
ShareFolder string `yaml:"share_folder_name" env:"GATEWAY_SHARE_FOLDER_NAME"`
|
||||
DisableHomeCreationOnLogin bool `yaml:"disable_home_creation_on_login" env:"GATEWAY_DISABLE_HOME_CREATION_ON_LOGIN"`
|
||||
TransferSecret string `yaml:"transfer_secret" env:"STORAGE_TRANSFER_SECRET"` // TODO: how to name the env
|
||||
TransferExpires int `yaml:"transfer_expires" env:"GATEWAY_TRANSFER_EXPIRES"`
|
||||
HomeMapping string `yaml:"home_mapping" env:"GATEWAY_HOME_MAPPIN"`
|
||||
EtagCacheTTL int `yaml:"etag_cache_ttl" env:"GATEWAY_ETAG_CACHE_TTL"`
|
||||
|
||||
UsersEndpoint string `yaml:"users_endpoint"`
|
||||
GroupsEndpoint string `yaml:"groups_endpoint"`
|
||||
PermissionsEndpoint string `yaml:"permissions_endpoint"`
|
||||
SharingEndpoint string `yaml:"sharing_endpoint"`
|
||||
FrontendPublicURL string `yaml:"frontend_public_url" env:"OCIS_URL;GATEWAY_FRONTEND_PUBLIC_URL"`
|
||||
AuthBasicEndpoint string `yaml:"auth_basic_endpoint"`
|
||||
AuthBearerEndpoint string `yaml:"auth_bearer_endpoint"`
|
||||
AuthMachineEndpoint string `yaml:"auth_machine_endpoint"`
|
||||
StoragePublicLinkEndpoint string `yaml:"storage_public_link_endpoint"`
|
||||
StorageUsersEndpoint string `yaml:"storage_users_endpoint"`
|
||||
StorageSharesEndpoint string `yaml:"storage_shares_endpoint"`
|
||||
FrontendPublicURL string `yaml:"frontend_public_url" env:"OCIS_URL;GATEWAY_FRONTEND_PUBLIC_URL"`
|
||||
|
||||
StorageRegistry StorageRegistry `yaml:"storage_registry"`
|
||||
AppRegistry AppRegistry `yaml:"app_registry"`
|
||||
UsersEndpoint string `yaml:"users_endpoint" env:"GATEWAY_USERS_ENDPOINT"`
|
||||
GroupsEndpoint string `yaml:"groups_endpoint" env:"GATEWAY_GROUPS_ENDPOINT"`
|
||||
PermissionsEndpoint string `yaml:"permissions_endpoint" env:"GATEWAY_PERMISSIONS_ENDPOINT"`
|
||||
SharingEndpoint string `yaml:"sharing_endpoint" env:"GATEWAY_SHARING_ENDPOINT"`
|
||||
AuthBasicEndpoint string `yaml:"auth_basic_endpoint" env:"GATEWAY_AUTH_BASIC_ENDPOINT"`
|
||||
AuthBearerEndpoint string `yaml:"auth_bearer_endpoint" env:"GATEWAY_AUTH_BEARER_ENDPOINT"`
|
||||
AuthMachineEndpoint string `yaml:"auth_machine_endpoint" env:"GATEWAY_AUTH_MACHINE_ENDPOINT"`
|
||||
StoragePublicLinkEndpoint string `yaml:"storage_public_link_endpoint" env:"GATEWAY_STORAGE_PUBLIC_LINK_ENDPOINT"`
|
||||
StorageUsersEndpoint string `yaml:"storage_users_endpoint" env:"GATEWAY_STORAGE_USERS_ENDPOINT"`
|
||||
StorageSharesEndpoint string `yaml:"storage_shares_endpoint" env:"GATEWAY_STORAGE_SHARES_ENDPOINT"`
|
||||
AppRegistryEndpoint string `yaml:"app_registry_endpoint" env:"GATEWAY_APP_REGISTRY_ENDPOINT"`
|
||||
|
||||
StorageRegistry StorageRegistry `yaml:"storage_registry"` //TODO: should we even support switching this?
|
||||
|
||||
Supervised bool `yaml:"-"`
|
||||
Context context.Context `yaml:"-"`
|
||||
@@ -80,11 +81,7 @@ type GRPCConfig struct {
|
||||
}
|
||||
|
||||
type StorageRegistry struct {
|
||||
Driver string
|
||||
Rules []string
|
||||
JSON string
|
||||
}
|
||||
|
||||
type AppRegistry struct {
|
||||
MimetypesJSON string
|
||||
Driver string `yaml:"driver"` //TODO: configure via env?
|
||||
Rules []string `yaml:"rules"` //TODO: configure via env?
|
||||
JSON string `yaml:"json"` //TODO: configure via env?
|
||||
}
|
||||
|
||||
@@ -39,25 +39,24 @@ func DefaultConfig() *config.Config {
|
||||
HomeMapping: "",
|
||||
EtagCacheTTL: 0,
|
||||
|
||||
UsersEndpoint: "localhost:9144",
|
||||
GroupsEndpoint: "localhost:9160",
|
||||
PermissionsEndpoint: "localhost:9191",
|
||||
SharingEndpoint: "localhost:9150",
|
||||
FrontendPublicURL: "https://localhost:9200",
|
||||
FrontendPublicURL: "https://localhost:9200",
|
||||
|
||||
AppRegistryEndpoint: "localhost:9222",
|
||||
AuthBasicEndpoint: "localhost:9146",
|
||||
AuthBearerEndpoint: "localhost:9148",
|
||||
AuthMachineEndpoint: "localhost:9166",
|
||||
GroupsEndpoint: "localhost:9160",
|
||||
PermissionsEndpoint: "localhost:9191",
|
||||
SharingEndpoint: "localhost:9150",
|
||||
StoragePublicLinkEndpoint: "localhost:9178",
|
||||
StorageUsersEndpoint: "localhost:9157",
|
||||
StorageSharesEndpoint: "localhost:9154",
|
||||
StorageUsersEndpoint: "localhost:9157",
|
||||
UsersEndpoint: "localhost:9144",
|
||||
|
||||
StorageRegistry: config.StorageRegistry{
|
||||
Driver: "spaces",
|
||||
JSON: "",
|
||||
},
|
||||
AppRegistry: config.AppRegistry{
|
||||
MimetypesJSON: "",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/utils"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/owncloud/ocis/extensions/gateway/pkg/config"
|
||||
)
|
||||
|
||||
@@ -35,7 +34,7 @@ func GatewayConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]i
|
||||
// registries is located on the gateway
|
||||
"authregistrysvc": cfg.Reva.Address,
|
||||
"storageregistrysvc": cfg.Reva.Address,
|
||||
"appregistrysvc": cfg.Reva.Address,
|
||||
"appregistrysvc": cfg.AppRegistryEndpoint,
|
||||
// user metadata is located on the users services
|
||||
"preferencessvc": cfg.UsersEndpoint,
|
||||
"userprovidersvc": cfg.UsersEndpoint,
|
||||
@@ -69,14 +68,6 @@ func GatewayConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]i
|
||||
},
|
||||
},
|
||||
},
|
||||
"appregistry": map[string]interface{}{
|
||||
"driver": "static",
|
||||
"drivers": map[string]interface{}{
|
||||
"static": map[string]interface{}{
|
||||
"mime_types": mimetypes(cfg, logger),
|
||||
},
|
||||
},
|
||||
},
|
||||
"storageregistry": map[string]interface{}{
|
||||
"driver": cfg.StorageRegistry.Driver,
|
||||
"drivers": map[string]interface{}{
|
||||
@@ -168,115 +159,3 @@ func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[strin
|
||||
// medatada storage not part of the global namespace
|
||||
}
|
||||
}
|
||||
|
||||
func mimetypes(cfg *config.Config, logger log.Logger) []map[string]interface{} {
|
||||
|
||||
type mimeTypeConfig struct {
|
||||
MimeType string `json:"mime_type" mapstructure:"mime_type"`
|
||||
Extension string `json:"extension" mapstructure:"extension"`
|
||||
Name string `json:"name" mapstructure:"name"`
|
||||
Description string `json:"description" mapstructure:"description"`
|
||||
Icon string `json:"icon" mapstructure:"icon"`
|
||||
DefaultApp string `json:"default_app" mapstructure:"default_app"`
|
||||
AllowCreation bool `json:"allow_creation" mapstructure:"allow_creation"`
|
||||
}
|
||||
var mimetypes []mimeTypeConfig
|
||||
var m []map[string]interface{}
|
||||
|
||||
// load default app mimetypes from a json file
|
||||
if cfg.AppRegistry.MimetypesJSON != "" {
|
||||
data, err := ioutil.ReadFile(cfg.AppRegistry.MimetypesJSON)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("Failed to read app registry mimetypes from JSON file: " + cfg.AppRegistry.MimetypesJSON)
|
||||
return nil
|
||||
}
|
||||
if err = json.Unmarshal(data, &mimetypes); err != nil {
|
||||
logger.Error().Err(err).Msg("Failed to unmarshal storage registry rules")
|
||||
return nil
|
||||
}
|
||||
if err := mapstructure.Decode(mimetypes, &m); err != nil {
|
||||
logger.Error().Err(err).Msg("Failed to decode defaultapp registry mimetypes to mapstructure")
|
||||
return nil
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
logger.Info().Msg("No app registry mimetypes JSON file provided, loading default configuration")
|
||||
|
||||
mimetypes = []mimeTypeConfig{
|
||||
{
|
||||
MimeType: "application/pdf",
|
||||
Extension: "pdf",
|
||||
Name: "PDF",
|
||||
Description: "PDF document",
|
||||
},
|
||||
{
|
||||
MimeType: "application/vnd.oasis.opendocument.text",
|
||||
Extension: "odt",
|
||||
Name: "OpenDocument",
|
||||
Description: "OpenDocument text document",
|
||||
AllowCreation: true,
|
||||
},
|
||||
{
|
||||
MimeType: "application/vnd.oasis.opendocument.spreadsheet",
|
||||
Extension: "ods",
|
||||
Name: "OpenSpreadsheet",
|
||||
Description: "OpenDocument spreadsheet document",
|
||||
AllowCreation: true,
|
||||
},
|
||||
{
|
||||
MimeType: "application/vnd.oasis.opendocument.presentation",
|
||||
Extension: "odp",
|
||||
Name: "OpenPresentation",
|
||||
Description: "OpenDocument presentation document",
|
||||
AllowCreation: true,
|
||||
},
|
||||
{
|
||||
MimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
Extension: "docx",
|
||||
Name: "Microsoft Word",
|
||||
Description: "Microsoft Word document",
|
||||
AllowCreation: true,
|
||||
},
|
||||
{
|
||||
MimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
Extension: "xlsx",
|
||||
Name: "Microsoft Excel",
|
||||
Description: "Microsoft Excel document",
|
||||
AllowCreation: true,
|
||||
},
|
||||
{
|
||||
MimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
Extension: "pptx",
|
||||
Name: "Microsoft PowerPoint",
|
||||
Description: "Microsoft PowerPoint document",
|
||||
AllowCreation: true,
|
||||
},
|
||||
{
|
||||
MimeType: "application/vnd.jupyter",
|
||||
Extension: "ipynb",
|
||||
Name: "Jupyter Notebook",
|
||||
Description: "Jupyter Notebook",
|
||||
},
|
||||
{
|
||||
MimeType: "text/markdown",
|
||||
Extension: "md",
|
||||
Name: "Markdown file",
|
||||
Description: "Markdown file",
|
||||
AllowCreation: true,
|
||||
},
|
||||
{
|
||||
MimeType: "application/compressed-markdown",
|
||||
Extension: "zmd",
|
||||
Name: "Compressed markdown file",
|
||||
Description: "Compressed markdown file",
|
||||
},
|
||||
}
|
||||
|
||||
if err := mapstructure.Decode(mimetypes, &m); err != nil {
|
||||
logger.Error().Err(err).Msg("Failed to decode defaultapp registry mimetypes to mapstructure")
|
||||
return nil
|
||||
}
|
||||
return m
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user