Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take care of trailing slashes in OCM package #1024

Merged
merged 3 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/ocm-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Take care of trailing slashes in OCM package

Previously, we assumed that the OCM endpoints would have trailing
slashes, failing in case they didn't. This PR fixes that.

https://github.com/cs3org/reva/pull/1024
12 changes: 6 additions & 6 deletions examples/meshdirectory/providers.demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "cernbox",
"full_name": "CERNBox",
"organization": "CERN",
"domain": "https://cern.ch",
"domain": "cern.ch",
"homepage": "https://cernbox.web.cern.ch",
"description": "CERNBox provides cloud data storage to all CERN users.",
"services": [
Expand All @@ -26,7 +26,7 @@
"name": "oc-cesnet",
"full_name": "ownCloud@CESNET",
"organization": "CESNET",
"domain": "https://cesnet.cz",
"domain": "cesnet.cz",
"homepage": "https://owncloud.cesnet.cz",
"description": "OwnCloud has been designed for individual users.",
"services": [
Expand All @@ -49,7 +49,7 @@
"name": "uni-muenster",
"full_name": "WWU University of Muenster",
"organization": "University of Muenster",
"domain": "https://uni-muenster.de",
"domain": "uni-muenster.de",
"homepage": "https://uni-muenster.de",
"description": "WWU provides cloud storage to its students, faculty and researchers.",
"services": [
Expand All @@ -72,7 +72,7 @@
"name": "cubbit",
"full_name": "Cubbit",
"organization": "Cubbit",
"domain": "https://cubbit.io",
"domain": "cubbit.io",
"homepage": "https://cubbit.io",
"description": "Cubbit provides distributed storage over a P2P network.",
"services": [
Expand All @@ -95,7 +95,7 @@
"name": "ailleron",
"full_name": "Ailleron - Software Mind",
"organization": "Ailleron",
"domain": "https://ailleron.com",
"domain": "ailleron.com",
"homepage": "https://ailleron.com",
"description": "Ailleron is a Polish IT company providing software and storage solutions to its clients.",
"services": [
Expand All @@ -118,7 +118,7 @@
"name": "surfsara",
"full_name": "Surfsara",
"organization": "Surfsara",
"domain": "https://surfsara.nl",
"domain": "surfsara.nl",
"homepage": "https://surfsara.nl",
"description": "OwnCloud has been designed for individual users.",
"services": [
Expand Down
8 changes: 4 additions & 4 deletions examples/oc-phoenix/providers.demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "cernbox",
"full_name": "CERNBox",
"organization": "CERN",
"domain": "http://cernbox.cern.ch",
"domain": "cernbox.cern.ch",
"homepage": "https://cernbox.web.cern.ch",
"description": "CERNBox provides cloud data storage to all CERN users.",
"services": [
Expand Down Expand Up @@ -39,7 +39,7 @@
"name": "oc-cesnet",
"full_name": "ownCloud@CESNET",
"organization": "CESNET",
"domain": "http://cesnet.cz",
"domain": "cesnet.cz",
"homepage": "https://owncloud.cesnet.cz",
"description": "OwnCloud has been designed for individual users.",
"services": [
Expand Down Expand Up @@ -75,7 +75,7 @@
"name": "example",
"full_name": "ownCloud@Example",
"organization": "Example",
"domain": "http://example.org",
"domain": "example.org",
"homepage": "http://example.org",
"description": "Example cloud storage.",
"services": [
Expand Down Expand Up @@ -111,7 +111,7 @@
"name": "test",
"full_name": "ownCloud@Test",
"organization": "Test",
"domain": "http://test.org",
"domain": "test.org",
"homepage": "http://test.org",
"description": "Test cloud storage.",
"services": [
Expand Down
6 changes: 3 additions & 3 deletions examples/oc-phoenix/users.demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": {
"opaque_id": "4c510ada-c86b-4815-8820-42cdf82c3d51",
"idp": "http://localhost:20080"
"idp": "localhost:20080"
},
"username": "einstein",
"secret": "relativity",
Expand All @@ -13,7 +13,7 @@
{
"id": {
"opaque_id": "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
"idp": "http://localhost:20080"
"idp": "localhost:20080"
},
"username": "marie",
"secret": "radioactivity",
Expand All @@ -24,7 +24,7 @@
{
"id": {
"opaque_id": "932b4540-8d16-481e-8ef4-588e4b6b151c",
"idp": "http://localhost:20080"
"idp": "localhost:20080"
},
"username": "richard",
"secret": "superfluidity",
Expand Down
8 changes: 4 additions & 4 deletions examples/ocmd/providers.demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "cernbox",
"full_name": "CERNBox",
"organization": "CERN",
"domain": "http://cernbox.cern.ch",
"domain": "cernbox.cern.ch",
"homepage": "https://cernbox.web.cern.ch",
"description": "CERNBox provides cloud data storage to all CERN users.",
"services": [
Expand Down Expand Up @@ -39,7 +39,7 @@
"name": "oc-cesnet",
"full_name": "ownCloud@CESNET",
"organization": "CESNET",
"domain": "http://cesnet.cz",
"domain": "cesnet.cz",
"homepage": "https://owncloud.cesnet.cz",
"description": "OwnCloud has been designed for individual users.",
"services": [
Expand Down Expand Up @@ -75,7 +75,7 @@
"name": "example",
"full_name": "ownCloud@Example",
"organization": "Example",
"domain": "http://example.org",
"domain": "example.org",
"homepage": "http://example.org",
"description": "Example cloud storage.",
"services": [
Expand Down Expand Up @@ -111,7 +111,7 @@
"name": "test",
"full_name": "ownCloud@Test",
"organization": "Test",
"domain": "http://test.org",
"domain": "test.org",
"homepage": "http://test.org",
"description": "Test cloud storage.",
"services": [
Expand Down
8 changes: 4 additions & 4 deletions examples/ocmd/users.demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": {
"opaque_id": "4c510ada-c86b-4815-8820-42cdf82c3d51",
"idp": "http://cernbox.cern.ch"
"idp": "cernbox.cern.ch"
},
"username": "einstein",
"secret": "relativity",
Expand All @@ -13,7 +13,7 @@
{
"id": {
"opaque_id": "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
"idp": "http://cesnet.cz"
"idp": "cesnet.cz"
},
"username": "marie",
"secret": "radioactivity",
Expand All @@ -24,7 +24,7 @@
{
"id": {
"opaque_id": "932b4540-8d16-481e-8ef4-588e4b6b151c",
"idp": "http://example.org"
"idp": "example.org"
},
"username": "richard",
"secret": "superfluidity",
Expand All @@ -35,7 +35,7 @@
{
"id": {
"opaque_id": "932b4522-139b-4815-8ef4-42cdf82c3d51",
"idp": "http://example.com"
"idp": "example.com"
},
"username": "test",
"secret": "test",
Expand Down
13 changes: 2 additions & 11 deletions examples/standalone/standalone.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
# services to enable
[grpc.services.gateway]
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.storageregistry]
[grpc.services.storageregistry.drivers.static]
home_provider = "/home"

[grpc.services.storageregistry.drivers.static.rules]
"/home" = "localhost:17000"
"/reva" = "localhost:18000"
"123e4567-e89b-12d3-a456-426655440000" = "localhost:18000"

[grpc.services.storageprovider]
[grpc.services.authprovider]
[grpc.services.authregistry]
[grpc.services.userprovider]
Expand All @@ -23,5 +13,6 @@ home_provider = "/home"
[grpc.services.ocmproviderauthorizer]

[http.services.datagateway]
[http.services.dataprovider]
[http.services.prometheus]
[http.services.ocmd]
6 changes: 3 additions & 3 deletions examples/standalone/users.demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": {
"opaque_id": "4c510ada-c86b-4815-8820-42cdf82c3d51",
"idp": "http://localhost:20080"
"idp": "localhost:20080"
},
"username": "einstein",
"secret": "relativity",
Expand All @@ -13,7 +13,7 @@
{
"id": {
"opaque_id": "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
"idp": "http://localhost:20080"
"idp": "localhost:20080"
},
"username": "marie",
"secret": "radioactivity",
Expand All @@ -24,7 +24,7 @@
{
"id": {
"opaque_id": "932b4540-8d16-481e-8ef4-588e4b6b151c",
"idp": "http://localhost:20080"
"idp": "localhost:20080"
},
"username": "richard",
"secret": "superfluidity",
Expand Down
27 changes: 27 additions & 0 deletions examples/storage-references/gateway.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# services to enable
[grpc.services.gateway]
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.storageregistry]
[grpc.services.storageregistry.drivers.static]
home_provider = "/home"

[grpc.services.storageregistry.drivers.static.rules]
"/home" = "localhost:17000"
"/reva" = "localhost:18000"
"123e4567-e89b-12d3-a456-426655440000" = "localhost:18000"

[grpc.services.authprovider]
[grpc.services.authregistry]
[grpc.services.userprovider]
[grpc.services.usershareprovider]
[grpc.services.publicshareprovider]
[grpc.services.ocmcore]
[grpc.services.ocmshareprovider]
[grpc.services.ocminvitemanager]
[grpc.services.ocmproviderauthorizer]

[http.services.datagateway]
[http.services.prometheus]
[http.services.ocmd]
35 changes: 35 additions & 0 deletions examples/storage-references/users.demo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"id": {
"opaque_id": "4c510ada-c86b-4815-8820-42cdf82c3d51",
"idp": "localhost:20080"
},
"username": "einstein",
"secret": "relativity",
"mail": "einstein@example.org",
"display_name": "Albert Einstein",
"groups": ["sailing-lovers", "violin-haters", "physics-lovers"]
},
{
"id": {
"opaque_id": "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
"idp": "localhost:20080"
},
"username": "marie",
"secret": "radioactivity",
"mail": "marie@example.org",
"display_name": "Marie Curie",
"groups": ["radium-lovers", "polonium-lovers", "physics-lovers"]
},
{
"id": {
"opaque_id": "932b4540-8d16-481e-8ef4-588e4b6b151c",
"idp": "localhost:20080"
},
"username": "richard",
"secret": "superfluidity",
"mail": "richard@example.org",
"display_name": "Richard Feynman",
"groups": ["quantum-lovers", "philosophy-haters", "physics-lovers"]
}
]
2 changes: 1 addition & 1 deletion internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (s *svc) createWebdavReference(ctx context.Context, share *ocm.Share) (*rpc
}
var webdavEndpoint string
for _, s := range meshProvider.ProviderInfo.Services {
if s.Endpoint.Type.Name == "Webdav" {
if strings.ToLower(s.Endpoint.Type.Name) == "webdav" {
webdavEndpoint = s.Endpoint.Path
}
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/ocm/invite/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"net/http"
"net/url"
"os"
"path"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -201,13 +202,20 @@ func (m *manager) ForwardInvite(ctx context.Context, invite *invitepb.InviteToke
"email": {contextUser.GetMail()},
"name": {contextUser.GetDisplayName()},
}

ocmEndpoint, err := getOCMEndpoint(originProvider)
if err != nil {
return err
}
u, err := url.Parse(ocmEndpoint)
if err != nil {
return err
}
u.Path = path.Join(u.Path, acceptInviteEndpoint)
recipientURL := u.String()

client := rhttp.GetHTTPClient(rhttp.Insecure(m.config.InsecureConnections))
recipientURL := fmt.Sprintf("%s%s", ocmEndpoint, acceptInviteEndpoint)

req, err := http.NewRequest("POST", recipientURL, strings.NewReader(requestBody.Encode()))
if err != nil {
return errors.Wrap(err, "json: error framing post request")
Expand Down
11 changes: 9 additions & 2 deletions pkg/ocm/invite/manager/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ package memory

import (
"context"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -102,13 +102,20 @@ func (m *manager) ForwardInvite(ctx context.Context, invite *invitepb.InviteToke
"email": {contextUser.GetMail()},
"name": {contextUser.GetDisplayName()},
}

ocmEndpoint, err := getOCMEndpoint(originProvider)
if err != nil {
return err
}
u, err := url.Parse(ocmEndpoint)
if err != nil {
return err
}
u.Path = path.Join(u.Path, acceptInviteEndpoint)
recipientURL := u.String()

client := rhttp.GetHTTPClient(rhttp.Insecure(m.Config.InsecureConnections))
recipientURL := fmt.Sprintf("%s%s", ocmEndpoint, acceptInviteEndpoint)

req, err := http.NewRequest("POST", recipientURL, strings.NewReader(requestBody.Encode()))
if err != nil {
return errors.Wrap(err, "json: error framing post request")
Expand Down
Loading