use opencloudurl

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2025-01-16 10:17:50 +01:00
parent d25e5af0e3
commit db39b8ed3b
21 changed files with 54 additions and 52 deletions

View File

@@ -69,9 +69,9 @@ type Config struct {
HTTPServiceTLS shared.HTTPServiceTLS `yaml:"http_service_tls"`
Reva *shared.Reva `yaml:"reva"`
Mode Mode // DEPRECATED
File string
OcisURL string `yaml:"ocis_url" env:"OC_URL" desc:"URL, where oCIS is reachable for users." introductionVersion:"pre5.0"`
Mode Mode // DEPRECATED
File string
OpenCloudURL string `yaml:"opencloud_url" env:"OC_URL" desc:"URL, where OpenCloudURL is reachable for users." introductionVersion:"pre5.0"`
Registry string `yaml:"registry"`
TokenManager *shared.TokenManager `yaml:"token_manager"`

View File

@@ -48,7 +48,7 @@ import (
func DefaultConfig() *Config {
return &Config{
OcisURL: "https://localhost:9200",
OpenCloudURL: "https://localhost:9200",
Runtime: Runtime{
Port: "9250",
Host: "localhost",

View File

@@ -110,8 +110,8 @@ func EnsureCommons(cfg *config.Config) {
cfg.Commons.AdminUserID = cfg.AdminUserID
}
if cfg.OcisURL != "" {
cfg.Commons.OcisURL = cfg.OcisURL
if cfg.OpenCloudURL != "" {
cfg.Commons.OpenCloudURL = cfg.OpenCloudURL
}
cfg.Commons.Reva = structs.CopyOrZeroValue(cfg.Reva)

View File

@@ -75,7 +75,7 @@ type Commons struct {
GRPCClientTLS *GRPCClientTLS `yaml:"grpc_client_tls"`
GRPCServiceTLS *GRPCServiceTLS `yaml:"grpc_service_tls"`
HTTPServiceTLS HTTPServiceTLS `yaml:"http_service_tls"`
OcisURL string `yaml:"ocis_url" env:"OC_URL" desc:"URL, where oCIS is reachable for users." introductionVersion:"pre5.0"`
OpenCloudURL string `yaml:"opencloud_url" env:"OC_URL" desc:"URL, where OpenCloud is reachable for users." introductionVersion:"pre5.0"`
TokenManager *TokenManager `mask:"struct" yaml:"token_manager"`
Reva *Reva `yaml:"reva"`
MachineAuthAPIKey string `mask:"password" yaml:"machine_auth_api_key" env:"OC_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary for the access to resources from other services." introductionVersion:"pre5.0"`

View File

@@ -735,7 +735,7 @@ func (f *FileConnector) PutRelativeFileSuggested(ctx context.Context, ccs Conten
Str("FinalReference", wopiContext.FileReference.String()).
Msg("PutRelativeFileSuggested: success")
webURL, err := url.Parse(f.cfg.Commons.OcisURL)
webURL, err := url.Parse(f.cfg.Commons.OpenCloudURL)
if err != nil {
return nil, err
}
@@ -827,7 +827,7 @@ func (f *FileConnector) PutRelativeFileRelative(ctx context.Context, ccs Content
}
var newInfo *providerv1beta1.ResourceInfo
webURL, err := url.Parse(f.cfg.Commons.OcisURL)
webURL, err := url.Parse(f.cfg.Commons.OpenCloudURL)
if err != nil {
return nil, err
}
@@ -1215,7 +1215,7 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (*ConnectorResponse,
breadcrumbFolderName = statRes.GetInfo().GetSpace().GetName()
}
ocURL, err := url.Parse(f.cfg.Commons.OcisURL)
ocURL, err := url.Parse(f.cfg.Commons.OpenCloudURL)
if err != nil {
return nil, err
}
@@ -1270,7 +1270,7 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (*ConnectorResponse,
fileinfo.KeyUserFriendlyName: userFriendlyName,
fileinfo.KeyUserID: userId,
fileinfo.KeyPostMessageOrigin: f.cfg.Commons.OcisURL,
fileinfo.KeyPostMessageOrigin: f.cfg.Commons.OpenCloudURL,
fileinfo.KeyLicenseCheckForEditIsEnabled: f.cfg.App.LicenseCheckEnable,
}

View File

@@ -46,7 +46,7 @@ var _ = Describe("FileConnector", func() {
BeforeEach(func() {
cfg = &config.Config{
Commons: &shared.Commons{
OcisURL: "https://cloud.opencloud.test",
OpenCloudURL: "https://cloud.opencloud.test",
},
App: config.App{
Name: "test",

View File

@@ -186,11 +186,11 @@ func EnsureDefaults(cfg *config.Config) {
cfg.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey
}
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
if (cfg.Commons != nil && cfg.Commons.OpenCloudURL != "") &&
(cfg.HTTP.CORS.AllowedOrigins == nil ||
len(cfg.HTTP.CORS.AllowedOrigins) == 1 &&
cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") {
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OpenCloudURL}
}
}

View File

@@ -48,7 +48,7 @@ func NewService(opts ...Option) Service {
if err := createTemporaryClientsConfig(
options.Config.IDP.IdentifierRegistrationConf,
options.Config.Commons.OcisURL,
options.Config.Commons.OpenCloudURL,
options.Config.Clients,
); err != nil {
logger.Fatal().Err(err).Msg("could not create default config")
@@ -141,7 +141,7 @@ type temporaryClientConfig struct {
Clients []config.Client `yaml:"clients"`
}
func createTemporaryClientsConfig(filePath, ocisURL string, clients []config.Client) error {
func createTemporaryClientsConfig(filePath, openCloudURL string, clients []config.Client) error {
folder := path.Dir(filePath)
if _, err := os.Stat(folder); os.IsNotExist(err) {
if err := os.MkdirAll(folder, 0o700); err != nil {
@@ -152,10 +152,10 @@ func createTemporaryClientsConfig(filePath, ocisURL string, clients []config.Cli
for i, client := range clients {
for i, entry := range client.RedirectURIs {
client.RedirectURIs[i] = strings.ReplaceAll(entry, "{{OC_URL}}", strings.TrimRight(ocisURL, "/"))
client.RedirectURIs[i] = strings.ReplaceAll(entry, "{{OC_URL}}", strings.TrimRight(openCloudURL, "/"))
}
for i, entry := range client.Origins {
client.Origins[i] = strings.ReplaceAll(entry, "{{OC_URL}}", strings.TrimRight(ocisURL, "/"))
client.Origins[i] = strings.ReplaceAll(entry, "{{OC_URL}}", strings.TrimRight(openCloudURL, "/"))
}
clients[i] = client
}

View File

@@ -78,11 +78,11 @@ func EnsureDefaults(cfg *config.Config) {
cfg.TokenManager = &config.TokenManager{}
}
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
if (cfg.Commons != nil && cfg.Commons.OpenCloudURL != "") &&
(cfg.HTTP.CORS.AllowedOrigins == nil ||
len(cfg.HTTP.CORS.AllowedOrigins) == 1 &&
cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") {
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OpenCloudURL}
}
}

View File

@@ -53,7 +53,7 @@ func NewEventsNotifier(
logger log.Logger,
gatewaySelector pool.Selectable[gateway.GatewayAPIClient],
valueService settingssvc.ValueService,
serviceAccountID, serviceAccountSecret, emailTemplatePath, defaultLanguage, ocisURL, translationPath, emailSender string,
serviceAccountID, serviceAccountSecret, emailTemplatePath, defaultLanguage, openCloudURL, translationPath, emailSender string,
store store.Store,
historyClient ehsvc.EventHistoryService,
registeredEvents map[string]events.Unmarshaller) Service {
@@ -70,7 +70,7 @@ func NewEventsNotifier(
emailTemplatePath: emailTemplatePath,
defaultLanguage: defaultLanguage,
defaultEmailSender: emailSender,
ocisURL: ocisURL,
openCloudURL: openCloudURL,
translationPath: translationPath,
filter: newNotificationFilter(logger, valueService),
splitter: newIntervalSplitter(logger, valueService),
@@ -90,7 +90,7 @@ type eventsNotifier struct {
translationPath string
defaultLanguage string
defaultEmailSender string
ocisURL string
openCloudURL string
serviceAccountID string
serviceAccountSecret string
filter *notificationFilter

View File

@@ -2,6 +2,7 @@ package service
import (
"context"
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
"github.com/cs3org/reva/v2/pkg/events"
"github.com/cs3org/reva/v2/pkg/utils"
@@ -70,7 +71,7 @@ func (s eventsNotifier) prepareShareCreated(logger zerolog.Logger, e events.Shar
}
shareFolder = resourceInfo.Name
shareLink, err = urlJoinPath(s.ocisURL, "files/shares/with-me")
shareLink, err = urlJoinPath(s.openCloudURL, "files/shares/with-me")
if err != nil {
logger.Error().
Err(err).

View File

@@ -2,6 +2,7 @@ package service
import (
"context"
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
"github.com/cs3org/reva/v2/pkg/events"
"github.com/cs3org/reva/v2/pkg/storagespace"
@@ -85,7 +86,7 @@ func (s eventsNotifier) prepareSpaceShared(logger zerolog.Logger, e events.Space
}
spaceName = resourceInfo.GetSpace().GetName()
shareLink, err = urlJoinPath(s.ocisURL, "f", e.ID.OpaqueId)
shareLink, err = urlJoinPath(s.openCloudURL, "f", e.ID.OpaqueId)
if err != nil {
logger.Error().
Err(err).
@@ -170,7 +171,7 @@ func (s eventsNotifier) prepareSpaceUnshared(logger zerolog.Logger, e events.Spa
}
spaceName = resourceInfo.GetSpace().GetName()
shareLink, err = urlJoinPath(s.ocisURL, "f", e.ID.OpaqueId)
shareLink, err = urlJoinPath(s.openCloudURL, "f", e.ID.OpaqueId)
if err != nil {
logger.Error().
Err(err).

View File

@@ -138,11 +138,11 @@ func EnsureDefaults(cfg *config.Config) {
cfg.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey
}
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
if (cfg.Commons != nil && cfg.Commons.OpenCloudURL != "") &&
(cfg.HTTP.CORS.AllowedOrigins == nil ||
len(cfg.HTTP.CORS.AllowedOrigins) == 1 &&
cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") {
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OpenCloudURL}
}
}

View File

@@ -182,11 +182,11 @@ func EnsureDefaults(cfg *config.Config) {
cfg.GRPC.TLS = structs.CopyOrZeroValue(cfg.Commons.GRPCServiceTLS)
}
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
if (cfg.Commons != nil && cfg.Commons.OpenCloudURL != "") &&
(cfg.HTTP.CORS.AllowedOrigins == nil ||
len(cfg.HTTP.CORS.AllowedOrigins) == 1 &&
cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") {
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OpenCloudURL}
}
}

View File

@@ -13,7 +13,7 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
// Construct the ocm provider domain from the oCIS URL
providerDomain := ""
u, err := url.Parse(cfg.Commons.OcisURL)
u, err := url.Parse(cfg.Commons.OpenCloudURL)
switch {
case err != nil:
logger.Error().Err(err).Msg("could not parse oCIS URL")
@@ -60,7 +60,7 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
"prefix": ".well-known",
"ocmprovider": map[string]interface{}{
"ocm_prefix": cfg.OCMD.Prefix,
"endpoint": cfg.Commons.OcisURL,
"endpoint": cfg.Commons.OpenCloudURL,
"provider": "OpenCloud",
"webdav_root": "/dav/ocm",
"webapp_root": cfg.ScienceMesh.Prefix,
@@ -157,7 +157,7 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
},
"gatewaysvc": cfg.Reva.Address,
"provider_domain": providerDomain,
"webdav_endpoint": cfg.Commons.OcisURL,
"webdav_endpoint": cfg.Commons.OpenCloudURL,
"webapp_template": cfg.OCMShareProvider.WebappTemplate,
"client_insecure": cfg.OCMShareProvider.Insecure,
},

View File

@@ -220,11 +220,11 @@ func EnsureDefaults(cfg *config.Config) {
cfg.Tasks.PurgeTrashBin.UserID = cfg.Commons.AdminUserID
}
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
if (cfg.Commons != nil && cfg.Commons.OpenCloudURL != "") &&
(cfg.HTTP.CORS.AllowedOrigins == nil ||
len(cfg.HTTP.CORS.AllowedOrigins) == 1 &&
cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") {
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OpenCloudURL}
}
}

View File

@@ -156,11 +156,11 @@ func EnsureDefaults(cfg *config.Config) {
cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS
}
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
if (cfg.Commons != nil && cfg.Commons.OpenCloudURL != "") &&
(cfg.HTTP.CORS.AllowedOrigins == nil ||
len(cfg.HTTP.CORS.AllowedOrigins) == 1 &&
cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") {
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OpenCloudURL}
}
}

View File

@@ -132,7 +132,7 @@ func getRelationProviders(cfg *config.Config) (map[string]service.RelationProvid
rels[relationURI] = relations.OpenIDDiscovery(cfg.IDP)
case relations.OwnCloudInstanceRel:
var err error
rels[relationURI], err = relations.OwnCloudInstance(cfg.Instances, cfg.OcisURL)
rels[relationURI], err = relations.OwnCloudInstance(cfg.Instances, cfg.OpenCloudURL)
if err != nil {
return nil, err
}

View File

@@ -18,11 +18,11 @@ type Config struct {
HTTP HTTP `yaml:"http"`
Instances []Instance `yaml:"instances"`
Relations []string `yaml:"relations" env:"WEBFINGER_RELATIONS" desc:"A list of relation URIs or registered relation types to add to webfinger responses. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
IDP string `yaml:"idp" env:"OC_URL;OC_OIDC_ISSUER;WEBFINGER_OIDC_ISSUER" desc:"The identity provider href for the openid-discovery relation." introductionVersion:"pre5.0"`
OcisURL string `yaml:"ocis_url" env:"OC_URL;WEBFINGER_OWNCLOUD_SERVER_INSTANCE_URL" desc:"The URL for the legacy ownCloud server instance relation (not to be confused with the product ownCloud Server). It defaults to the OC_URL but can be overridden to support some reverse proxy corner cases. To shard the deployment, multiple instances can be configured in the configuration file." introductionVersion:"pre5.0"`
Insecure bool `yaml:"insecure" env:"OC_INSECURE;WEBFINGER_INSECURE" desc:"Allow insecure connections to the WEBFINGER service." introductionVersion:"pre5.0"`
Instances []Instance `yaml:"instances"`
Relations []string `yaml:"relations" env:"WEBFINGER_RELATIONS" desc:"A list of relation URIs or registered relation types to add to webfinger responses. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
IDP string `yaml:"idp" env:"OC_URL;OC_OIDC_ISSUER;WEBFINGER_OIDC_ISSUER" desc:"The identity provider href for the openid-discovery relation." introductionVersion:"pre5.0"`
OpenCloudURL string `yaml:"opencloud_url" env:"OC_URL;WEBFINGER_OPENCLOUD_SERVER_INSTANCE_URL" desc:"The URL for the legacy OpenCloud server instance relation (not to be confused with the product OpenCloud Server). It defaults to the OC_URL but can be overridden to support some reverse proxy corner cases. To shard the deployment, multiple instances can be configured in the configuration file." introductionVersion:"pre5.0"`
Insecure bool `yaml:"insecure" env:"OC_INSECURE;WEBFINGER_INSECURE" desc:"Allow insecure connections to the WEBFINGER service." introductionVersion:"pre5.0"`
Context context.Context `yaml:"-"`
}

View File

@@ -37,8 +37,8 @@ func DefaultConfig() *config.Config {
Name: "webfinger",
},
OcisURL: "https://localhost:9200",
Relations: []string{relations.OpenIDConnectRel, relations.OwnCloudInstanceRel},
OpenCloudURL: "https://localhost:9200",
Relations: []string{relations.OpenIDConnectRel, relations.OwnCloudInstanceRel},
Instances: []config.Instance{
{
Claim: "sub",
@@ -83,11 +83,11 @@ func EnsureDefaults(cfg *config.Config) {
cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS
}
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
if (cfg.Commons != nil && cfg.Commons.OpenCloudURL != "") &&
(cfg.HTTP.CORS.AllowedOrigins == nil ||
len(cfg.HTTP.CORS.AllowedOrigins) == 1 &&
cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") {
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OpenCloudURL}
}
}

View File

@@ -25,12 +25,12 @@ type compiledInstance struct {
type ownCloudInstance struct {
instances []compiledInstance
ocisURL string
openCloudURL string
instanceHost string
}
// OwnCloudInstance adds one or more ownCloud instance relations
func OwnCloudInstance(instances []config.Instance, ocisURL string) (service.RelationProvider, error) {
func OwnCloudInstance(instances []config.Instance, openCloudURL string) (service.RelationProvider, error) {
compiledInstances := make([]compiledInstance, 0, len(instances))
var err error
for _, instance := range instances {
@@ -46,13 +46,13 @@ func OwnCloudInstance(instances []config.Instance, ocisURL string) (service.Rela
compiledInstances = append(compiledInstances, compiled)
}
u, err := url.Parse(ocisURL)
u, err := url.Parse(openCloudURL)
if err != nil {
return nil, err
}
return &ownCloudInstance{
instances: compiledInstances,
ocisURL: ocisURL,
openCloudURL: openCloudURL,
instanceHost: u.Host + u.Path,
}, nil
}
@@ -68,7 +68,7 @@ func (l *ownCloudInstance) Add(ctx context.Context, jrd *webfinger.JSONResourceD
jrd.Subject = "mailto:" + value
}
// allow referencing OC_URL in the template
claims["OC_URL"] = l.ocisURL
claims["OC_URL"] = l.openCloudURL
for _, instance := range l.instances {
if value, ok := claims[instance.Claim].(string); ok && instance.compiledRegex.MatchString(value) {
var tmplWriter strings.Builder