Skip to content

Conversation

@MahdiBaghbani
Copy link

Although this PR is referenced under cs3org/OCM-STA#1, it is not directly part of the STA funded work. However, since the changes are closely related and beneficial to OCM, I decided to port them here as well for consistency.

Description

This PR implements WAYF (Where Are You From) specific discovery endpoints for the ScienceMesh package, enabling dynamic OCM provider discovery and federation management. The implementation follows the OCM Discovery 1.2 specification.

Technical

Things I've added to Reva

  • /sciencemesh/federations endpoint: Lists available federations and their associated servers
  • /sciencemesh/federations endpoint: Enables active discovery of OCM providers and their capabilities
  • Automatic InviteAcceptDialog discovery: Dynamically retrieves invitation handling URLs from remote providers
  • Federation configuration support: Loads federation data from configurable JSON files
  • Legacy endpoint fallback: Maintains compatibility with older OCM discovery implementations

Code changes

  • New OCM Client internal/http/services/ocmd/client.go: HTTP client for OCM provider discovery with timeout and TLS configuration
  • WAYF Handler internal/http/services/sciencemesh/wayf.go: Core logic for federation management and provider discovery
  • Updated routing internal/http/services/sciencemesh/sciencemesh.go: Added new endpoints and configuration options
  • OCM Discovery 1.2 compliance internal/http/services/wellknown/ocm.go: Updated API version and added InviteAcceptDialog support

…sciencemesh package

Signed-off-by: Mahdi Baghbani <mahdi-baghbani@azadehafzar.io>
Copy link

@butonic butonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I know you have this on draft, but I wanted to understand this and get involved early.

ocmClient := ocmd.NewClient(10*time.Second, false)

log.Debug().Str("domain", domain).Msg("Attempting OCM discovery")
disco, err := ocmClient.Discover(ctx, domain)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm. domain is taken from the request. and the /discover endpoint is unprotected. That allows anyone to make a GET /.well-known/ocm and GET /ocm-provider request to any host. even internal ones. We need to check if the requested host is in the list of configured federations?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so the idea is if Alice invited Bob and Bob cannot find it's home EFSS server name in Alice's WAYF page, he could enter his domain in the UI to be redirected to his EFSS.

Here is a demo with my modified GUI of OpenCloud (will open PR after fixing some corners):
opencloud-to-ocis.webm

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially considered implementing it entirely on the client side, but that approach would conflict with CSRF protection mechanisms

MahdiBaghbani and others added 5 commits November 1, 2025 09:00
Co-authored-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Mahdi Baghbani <mahdi-baghbani@azadehafzar.io>
Instead of creating a client each time a function is called, create client once

Signed-off-by: Mahdi Baghbani <mahdi-baghbani@azadehafzar.io>
Co-authored-by: Giuseppe Lo Presti <giuseppe.lopresti@cern.ch>
Signed-off-by: Mahdi Baghbani <mahdi-baghbani@azadehafzar.io>
@glpatcern recommendations
moved types to spec.go
used directory urls instead of a file

Signed-off-by: Mahdi Baghbani <mahdi-baghbani@azadehafzar.io>
as per @glpatcern recommendations

Also return 404 if the remote EFSS doesn't provide an
inviteAcceptDialog

Signed-off-by: Mahdi Baghbani <mahdi-baghbani@azadehafzar.io>
@MahdiBaghbani MahdiBaghbani marked this pull request as ready for review November 18, 2025 11:44
@github-project-automation github-project-automation bot moved this to Qualification in OpenCloud Team Board Nov 26, 2025
@butonic
Copy link

butonic commented Nov 26, 2025

@dragonchaser this PR adds missing enpoints for the current OCM spec. Since you digested that yesterday, can you give it a review?

Signed-off-by: Christian Richter <c.richter@opencloud.eu>
@dragonchaser dragonchaser force-pushed the opencloud/feature-ocm-wayf branch from 8397299 to b45fa51 Compare November 27, 2025 10:35
@dragonchaser dragonchaser merged commit b517260 into opencloud-eu:main Nov 27, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from Qualification to Done in OpenCloud Team Board Nov 27, 2025
@openclouders openclouders mentioned this pull request Nov 27, 2025
1 task
@MahdiBaghbani
Copy link
Author

Thanks for the acceptance! 🥳

I just have a question about:

resp, err := c.client.Do(req)
defer func() {
if resp != nil && resp.Body != nil {
_ = resp.Body.Close()
}
}()
if err != nil {
return nil, errors.Wrap(err, "error doing OCM discovery request")
}
defer func(body io.ReadCloser) {
err := body.Close()
if err != nil {
log.Warn().Err(err).Msg("error closing response body")
}
}(resp.Body)

@dragonchaser did I made a mistake on placing the body closer under err check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants