Skip to content

feat(ocm): launch webapps via served launcher - #283

Merged
glpatcern merged 2 commits into
cernboxfrom
served-webapp-launch
Nov 5, 2026
Merged

glpatcern merged 2 commits into
cernboxfrom
served-webapp-launch

Conversation

@MahdiBaghbani

@MahdiBaghbani MahdiBaghbani commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

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

Summary

  • Launch received webapps through Reva's served launcher page (feat(ocm): serve CSP-scoped webapp launcher page cs3org/reva#5906) instead of posting the token to the app from CERNBox itself. CERN's CSP has form-action 'self', which blocks the old form POST to the app's origin (for example https://compute.teosc.se/services/ocm/open). The new form posts to /sciencemesh/webapp-launch on CERNBox's own origin, and Reva answers with a page whose own CSP allows exactly that one app, which then posts to it.
  • The handler still opens the named about:blank window synchronously, so the popup blocker allows it, and submits a hidden form into that window with no await in between. The fields are file (the resource id), expired_session_redirect_uri (https:// plus the current host), and the user's token twice, as access-token and access_token, so both Reva's bearer token strategy and its bearer credential strategy find it. The token travels only in the POST body, never in a URL.
  • The CERNBox code no longer handles the app's access token: the /sciencemesh/open-in-app XHR, the app_url check, and the client-side form to the app are gone. Popup-blocked and missing-resource cases keep their messages, and a throwing submit closes the window and shows "Couldn't open remotely".
  • Reva authenticates the web OIDC token through the bearer credential strategy, which is in the default credential_chain. bearer in token_strategy_chain is only needed when the token is already a Reva token. The proxy must not add its own CSP on /sciencemesh/webapp-launch.
flowchart TD
    A["Open remotely with appName"] --> W["window.open about:blank, named ocm-remote-timestamp"]
    W -->|"null, popup blocked"| PW["popup warning, no request"]
    W -->|"window"| R{"resource present?"}
    R -->|"no"| E["close window, Couldn't open remotely"]
    R -->|"yes"| F["hidden form POST to /sciencemesh/webapp-launch, target = that window"]
    F -->|"submit throws"| E
    F -->|"submitted"| L["Reva launcher page, form-action = app origin"]
    L --> APP["POST access_token to the app URL"]
Loading

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@rawe0
rawe0 self-requested a review October 29, 2026 13:39
rawe0
rawe0 previously approved these changes Oct 29, 2026
@rawe0
rawe0 self-requested a review October 29, 2026 13:40
@rawe0
rawe0 dismissed their stale review October 29, 2026 13:40

incorrect PR

@MahdiBaghbani
MahdiBaghbani removed this pull request from stack #277 October 30, 2026 11:19
@MahdiBaghbani
MahdiBaghbani added this pull request to stack #287 October 30, 2026 11:20

@rawe0 rawe0 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good :) just one question below

Comment thread packages/web-app-ocm/src/extensions.ts Outdated
Comment on lines +119 to +120
['access-token', accessToken],
['access_token', accessToken]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How come we have two access-tokens?

@MahdiBaghbani MahdiBaghbani Oct 30, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's the same token under the two names Reva reads from a form body:

  • access-token is read by Reva bearer token strategy which checks whether the value is already a Reva token
    That form field name comes from existing upstream code cs3org/reva#3315

  • access_token is read by the bearer credential strategy which passes an IdP token to the gateway to authenticate, thats the RFC 6750 form field name, and feat(ocm): serve CSP-scoped webapp launcher page cs3org/reva#5906 adds the form-body read there

Webs authStore.accessToken is the OIDC access token so with a normal IdP setup access_token is the field that actually authenticates

access-token covers deployments where the bearer token is already a Reva token
Both go only in the POST body to CERNBoxs own /sciencemesh/webapp-launch never in a URL so the second copy exposes nothing extra

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can drop access-token here access_token alone is enough for the OIDC token with no Reva change

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right, we should drop access-token here, the only token the remote user needs is the access_token minted by the exhange-token OCM flow

Base automatically changed from protocol-gated-remote-webapp-actions to cernbox November 5, 2026 09:55
@glpatcern
glpatcern force-pushed the served-webapp-launch branch from f162143 to 8196f8e Compare November 5, 2026 09:55
@glpatcern
glpatcern merged commit 3f0c221 into cernbox Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants