diff --git a/changelog/unreleased/enhancement-add-open-with-web-endpoint.md b/changelog/unreleased/enhancement-add-open-with-web-endpoint.md new file mode 100644 index 000000000..551041057 --- /dev/null +++ b/changelog/unreleased/enhancement-add-open-with-web-endpoint.md @@ -0,0 +1,7 @@ +Enhancement: Add /app/open-with-web endpoint + +We've added an /app/open-with-web endpoint to the app provider, so that +clients that are no browser or have only limited browser access can also open apps with the help of a Web URL. + +https://github.com/owncloud/ocis/pull/4376 +https://github.com/cs3org/reva/pull/3143 diff --git a/changelog/unreleased/update-reva-beta.7.md b/changelog/unreleased/update-reva-beta.7.md new file mode 100644 index 000000000..b81c362c0 --- /dev/null +++ b/changelog/unreleased/update-reva-beta.7.md @@ -0,0 +1,7 @@ +Enhancement: update reva to vx.x.x + +Updated reva to version x.x.x. This update includes: + +* TODO: + +https://github.com/owncloud/ocis/pull/4376 diff --git a/docs/services/app-registry/apps.md b/docs/services/app-registry/apps.md index 39f01d65c..e9726849c 100644 --- a/docs/services/app-registry/apps.md +++ b/docs/services/app-registry/apps.md @@ -22,9 +22,10 @@ The capabilities endpoint (e.g. `https://localhost:9200/ocs/v1.php/cloud/capabil "app_providers": [ { "enabled": true, - "version": "1.0.0", + "version": "1.1.0", "apps_url": "/app/list", "open_url": "/app/open", + "open_web_url": "/app/open-with-web", "new_url": "/app/new" } ] @@ -178,6 +179,48 @@ HTTP status code: 200 } ``` +### Open a file with the ownCloud Web + +**Endpoint**: specified in the capabilities in `open_web_url`, currently `/app/open-with-web` + +**Method**: HTTP POST + +**Authentication** (one of them): + +- `Authorization` header with OIDC Bearer token for authenticated users or basic auth credentials (if enabled in oCIS) +- `X-Access-Token` header with a REVA token for authenticated users + +**Query parameters**: + +- `file_id` (mandatory): id of the file to be opened +- `app_name` (optional) + - default (not given): default app for mime type + - possible values depend on the app providers for a mimetype from the `/app/open` endpoint + +**Request examples**: + +```bash +curl -X POST 'https://ocis.test/app/open?file_id=ZmlsZTppZAo=' + +curl -X POST 'https://ocis.test/app/open?file_id=ZmlsZTppZAo=&app_name=Collabora' +``` + +**Response examples**: + +The URI from the response JSON is intended to be opened with a GET request in a browser. If the user has not yet a session in the browser, a login flow is handled by ownCloud Web. + +HTTP status code: 200 + +```json +{ + "uri": "https://....." +} +``` + +**Example responses (error case)**: + +See error cases for [Open a file with the app provider](#open-a-file-with-the-app-provider) + ### Open a file with the app provider **Endpoint**: specified in the capabilities in `open_url`, currently `/app/open` diff --git a/go.mod b/go.mod index c9217507b..6d2350d95 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/blevesearch/bleve_index_api v1.0.2 github.com/coreos/go-oidc/v3 v3.2.0 github.com/cs3org/go-cs3apis v0.0.0-20220719130120-361e9f987d64 - github.com/cs3org/reva/v2 v2.7.4 + github.com/cs3org/reva/v2 v2.7.5-0.20220817100552-b0f72d755620 github.com/disintegration/imaging v1.6.2 github.com/ggwhite/go-masker v1.0.9 github.com/go-chi/chi/v5 v5.0.7 @@ -142,6 +142,7 @@ require ( github.com/dlclark/regexp2 v1.4.0 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/emirpasic/gods v1.12.0 // indirect + github.com/emvi/iso-639-1 v1.0.1 // indirect github.com/eternnoir/gncp v0.0.0-20170707042257-c70df2d0cd68 // indirect github.com/evanphx/json-patch/v5 v5.5.0 // indirect github.com/fatih/color v1.13.0 // indirect diff --git a/go.sum b/go.sum index 26b180c9d..61ac75368 100644 --- a/go.sum +++ b/go.sum @@ -291,8 +291,8 @@ github.com/crewjam/saml v0.4.6 h1:XCUFPkQSJLvzyl4cW9OvpWUbRf0gE7VUpU8ZnilbeM4= github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD96t1A= github.com/cs3org/go-cs3apis v0.0.0-20220719130120-361e9f987d64 h1:cFnankJOCWndnOns4sKRG7yzH61ammK2Am6rEGWCK40= github.com/cs3org/go-cs3apis v0.0.0-20220719130120-361e9f987d64/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva/v2 v2.7.4 h1:hmx3qtBsLG1ijwAM4wwBcB4ozqu5jDW9UNFGukKtHRw= -github.com/cs3org/reva/v2 v2.7.4/go.mod h1:AKcCJX2IWLxKGA60eaM7A43nB6urQYuE9phbJabKkm0= +github.com/cs3org/reva/v2 v2.7.5-0.20220817100552-b0f72d755620 h1:OZc0njRbjujMofFuhF3DYpZ+0k29jZJ0S7Ft8A/0xQM= +github.com/cs3org/reva/v2 v2.7.5-0.20220817100552-b0f72d755620/go.mod h1:AfRiy0Uu9OR0rqZKMMlMvAkrlEC6yppfJTa+mJ2LNhI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= @@ -326,6 +326,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/emvi/iso-639-1 v1.0.1 h1:4s6P8Uxc/RDkwCpxAr4NHOT/15a1swy9IQkB8PJCWVI= +github.com/emvi/iso-639-1 v1.0.1/go.mod h1:mghC4MDFyszxzH98ujf/K5whvB6B0nV4qCa5u94dP84= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index 20719e36c..91fcdf1fc 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -48,7 +48,10 @@ func Server(cfg *config.Config) *cli.Command { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") - rcfg := revaconfig.FrontendConfigFromStruct(cfg) + rcfg, err := revaconfig.FrontendConfigFromStruct(cfg) + if err != nil { + return err + } gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) diff --git a/services/frontend/pkg/revaconfig/config.go b/services/frontend/pkg/revaconfig/config.go index 29bcdc1c0..a247f7b5b 100644 --- a/services/frontend/pkg/revaconfig/config.go +++ b/services/frontend/pkg/revaconfig/config.go @@ -1,6 +1,7 @@ package revaconfig import ( + "net/url" "path" "strconv" @@ -9,7 +10,15 @@ import ( ) // FrontendConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. -func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { +func FrontendConfigFromStruct(cfg *config.Config) (map[string]interface{}, error) { + + webURL, err := url.Parse(cfg.PublicURL) + if err != nil { + return nil, err + } + webURL.Path = path.Join(webURL.Path, "external") + webOpenInAppURL := webURL.String() + archivers := []map[string]interface{}{ { "enabled": true, @@ -23,11 +32,12 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { appProviders := []map[string]interface{}{ { - "enabled": true, - "version": "1.0.0", - "apps_url": "/app/list", - "open_url": "/app/open", - "new_url": "/app/new", + "enabled": true, + "version": "1.1.0", + "apps_url": "/app/list", + "open_url": "/app/open", + "open_web_url": "/app/open-with-web", + "new_url": "/app/new", }, } @@ -88,6 +98,18 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { "transfer_shared_secret": cfg.TransferSecret, "timeout": 86400, "insecure": cfg.AppHandler.Insecure, + "webbaseuri": webOpenInAppURL, + "web": map[string]interface{}{ + "urlparamsmapping": map[string]string{ + // param -> value mapper + // these mappers are static and are only subject to change when changed in oC Web + "fileId": "fileid", + "app": "appname", + }, + "staticurlparams": map[string]string{ + "contextRouteName": "files-spaces-personal", // TODO: remove when https://github.com/owncloud/web/pull/7437 arrived in oCIS + }, + }, }, "archiver": map[string]interface{}{ "prefix": cfg.Archiver.Prefix, @@ -227,5 +249,5 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { }, }, }, - } + }, nil }