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

fix(ocm): Adjust for recend change for federated user IDs #10567

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-ocm-external-idp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix federated sharing when using an external IDP

We fixed a bug that caused federated sharing to fail, when the
federated oCIS instances where sharing the same external IDP.

https://github.com/owncloud/ocis/pull/1xxxx
https://github.com/cs3org/reva/pull/4933
7 changes: 0 additions & 7 deletions services/graph/pkg/identity/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/CiscoM31/godata"
cs3group "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1"
cs3user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
ocmuser "github.com/cs3org/reva/v2/pkg/ocm/user"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/v2/services/graph/pkg/errorcode"
)
Expand Down Expand Up @@ -134,12 +133,6 @@ func CreateUserModelFromCS3(u *cs3user.User) *libregraph.User {
OnPremisesSamAccountName: u.GetUsername(),
Id: &u.GetId().OpaqueId,
}
// decode the remote id if the user is federated
if u.GetId().GetType() == cs3user.UserType_USER_TYPE_FEDERATED {
remoteID := ocmuser.RemoteID(u.GetId())
user.Identities[0].Issuer = &remoteID.Idp
user.Identities[0].IssuerAssignedId = &remoteID.OpaqueId
}
return user
}

Expand Down
20 changes: 17 additions & 3 deletions services/ocm/pkg/revaconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@ package revaconfig

import (
"math"
"net/url"

"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/ocm/pkg/config"
)

// OCMConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]interface{} {

// Construct the ocm provider domain from the oCIS URL
providerDomain := ""
u, err := url.Parse(cfg.Commons.OcisURL)
switch {
case err != nil:
logger.Error().Err(err).Msg("could not parse oCIS URL")
case u.Host == "":
logger.Error().Msg("oCIS URL has no host")
default:
providerDomain = u.Host
}

return map[string]interface{}{
"shared": map[string]interface{}{
"jwt_secret": cfg.TokenManager.JWTSecret,
Expand Down Expand Up @@ -59,7 +73,7 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
"smtp_credentials": map[string]string{},
"gatewaysvc": cfg.Reva.Address,
"mesh_directory_url": cfg.ScienceMesh.MeshDirectoryURL,
"provider_domain": cfg.Commons.OcisURL,
"provider_domain": providerDomain,
"events": map[string]interface{}{
"natsaddress": cfg.Events.Endpoint,
"natsclusterid": cfg.Events.Cluster,
Expand Down Expand Up @@ -121,7 +135,7 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
"file": cfg.OCMInviteManager.Drivers.JSON.File,
},
},
"provider_domain": cfg.Commons.OcisURL,
"provider_domain": providerDomain,
"token_expiration": cfg.OCMInviteManager.TokenExpiration.String(),
"ocm_timeout": int(math.Round(cfg.OCMInviteManager.Timeout.Seconds())),
"ocm_insecure": cfg.OCMInviteManager.Insecure,
Expand All @@ -142,7 +156,7 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter
},
},
"gatewaysvc": cfg.Reva.Address,
"provider_domain": cfg.Commons.OcisURL,
"provider_domain": providerDomain,
"webdav_endpoint": cfg.Commons.OcisURL,
"webapp_template": cfg.OCMShareProvider.WebappTemplate,
"client_insecure": cfg.OCMShareProvider.Insecure,
Expand Down