Skip to content

feat(ocm): add safe received webapp launch - #5850

Merged
glpatcern merged 11 commits into
masterfrom
safe-received-webapp-launch
Nov 4, 2026
Merged

glpatcern merged 11 commits into
masterfrom
safe-received-webapp-launch

Conversation

@MahdiBaghbani

@MahdiBaghbani MahdiBaghbani commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

This PR is part of the cs3org/OCM-STA#20 and cs3org/OCM-STA#48

Summary

  • Add received webapp launch to ScienceMesh OpenInApp: load the received share, check the stored offer with ValidateWebappLaunch, validate the requested file path, discover the sender, and exchange the shared secret for an access token. The response stays app_url and access_token, and the secret never leaves the server. Error text goes through redactLaunchError, so neither the secret nor the token is echoed back.
  • Reject before any dial: the offer has to require must-exchange-token and allow the blank target on both sides, must-use-mfa is refused (403) unless mfa_policy is off, the app URI and token URL have to be https without userinfo, and the share-relative path is checked up front - traversal segments, absolute suffixes, literal or encoded dot segments and empty interior segments are rejected before discovery, with encoded forms decoded first. The path is also joined onto the app URI before discovery, so a path that can't be joined fails before any token is minted.
  • Add mfa_policy under [http.services.wellknown.ocmprovider]: reject (default) or off. Reva has no per-user MFA proof, but a deployment where every login already goes through OIDC with a hardware token can set off to accept must-use-mfa offers. Nothing is advertised, so off only relaxes our own check and makes no enforce-mfa claim in discovery. An unknown value fails startup.
  • Use one retained public-only client for both Discover and ExchangeToken, built at init from the ScienceMesh transport config, so a token host that differs from the discovery host still goes through the same dial guard. Nothing is cached, each launch discovers again, and client_id is the configured provider domain.
  • Supersedes Enhancement: Add webapp launch support to sciencemesh OpenInApp #5701.
flowchart TD
    REQ["POST /sciencemesh/open-in-app"] --> SH["load stored share and webapp offer"]
    SH --> V{"ValidateWebappLaunch"}
    V -->|"must-use-mfa and mfa_policy = reject"| MFA["403, no dial"]
    V -->|"no must-exchange-token, no blank target, or malformed URI"| BAD["400, no dial"]
    V -->|"ok"| PATH{"validateShareFilePath"}
    PATH -->|"traversal, absolute suffix, or dot segment"| BAD
    PATH -->|"valid"| URI{"requireHTTPSAppURI"}
    URI -->|"not https or userinfo"| BAD
    URI -->|"https"| JOIN{"joinShareRelativePath"}
    JOIN -->|"cannot join"| BAD
    JOIN -->|"app_url"| ORG{"senderDiscoveryOrigin"}
    ORG -->|"invalid absolute WebDAV URI"| BAD
    ORG -->|"WebDAV origin, else webapp origin"| C{"public-only dial guard"}
    C -->|"loopback, or private outside allowed_federation_cidrs"| REF["refused"]
    C -->|"public, or private within allowed_federation_cidrs"| D["Discover"]
    D --> T["resolve token endpoint, https"]
    T --> X["ExchangeToken, client_id = provider domain"]
    X --> OUT["app_url + access_token"]
    OUT -.->|"later in the stack"| SRV["served launcher page posts the token to the app, this JSON route is removed"]
Loading

Later in the stack, #5906 serves this launch as a CSP-scoped page that posts the token straight to the app, and #5909 removes /sciencemesh/open-in-app. The checks above stay the same; at the top of the stack the access token never reaches the browser.

The part you might ask about is senderDiscoveryOrigin. It takes the first absolute WebDAV origin, and an invalid one fails the launch instead of falling back to the webapp URI, so a broken WebDAV entry can't steer discovery to another host. #5851 replaces this with the share sender's idp.

The other thing is private networks. The launch client is built once at init from the ScienceMesh publicOCMTransportConfig(), so it shares the service's timeout, TLS settings and allowed_federation_cidrs. A sender on a private network is refused unless its range is explicitly configured; loopback and environment proxies stay disabled on this service. Testbeds that run OCM traffic through a MITM proxy on a private Docker network put that network in allowed_federation_cidrs.

@MahdiBaghbani MahdiBaghbani self-assigned this Sep 29, 2026
@MahdiBaghbani MahdiBaghbani added feature New feature OCM Open Cloud Mesh labels Sep 29, 2026
@MahdiBaghbani
MahdiBaghbani force-pushed the safe-received-webapp-launch branch 2 times, most recently from 82cae53 to b87bb54 Compare October 8, 2026 08:29
@glpatcern
glpatcern force-pushed the safe-received-webapp-launch branch 3 times, most recently from 2a3febd to fb526ee Compare October 12, 2026 14:26
@MahdiBaghbani
MahdiBaghbani force-pushed the safe-received-webapp-launch branch from d999d31 to 4fa0371 Compare October 15, 2026 20:56
@glpatcern
glpatcern force-pushed the safe-received-webapp-launch branch 3 times, most recently from 4de26bc to 6a0ab85 Compare October 20, 2026 09:20
@MahdiBaghbani
MahdiBaghbani force-pushed the safe-received-webapp-launch branch from 6a0ab85 to 9e33682 Compare October 30, 2026 15:36
@glpatcern
glpatcern force-pushed the safe-received-webapp-launch branch from 9e33682 to 7ac3647 Compare November 4, 2026 09:26
@glpatcern
glpatcern force-pushed the safe-received-webapp-launch branch from 7ac3647 to 1587181 Compare November 4, 2026 09:30
@glpatcern
glpatcern force-pushed the safe-received-webapp-launch branch from 1587181 to 9d30079 Compare November 4, 2026 11:38
@glpatcern
glpatcern merged commit d94142b into master Nov 4, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature OCM Open Cloud Mesh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants