Skip to content

Conversation

enrico-kaack-comp
Copy link
Contributor

What this PR does / why we need it:

  • changes Cookies SameSite to None to allow cookies and therefore session when embedded in iFrame
  • set CSP with frame-anchestors to only be embeddable in website we trust
  • set reasonable CSP defaults

We can not allow CORS since every browser initiated request will contain the session cookie (as defined by SameSite). Without CORS and with the frame-anchestors we allow this to only happen within our domain/site.

This change allow us to be used in openMFP.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Copy link
Contributor

@andreaskienle andreaskienle left a comment

Choose a reason for hiding this comment

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

There are two typos (didn't mark all changes), but apart from that, it looks great! I also tested the embedding in HSP, and it works for me 👍

@andreaskienle andreaskienle requested a review from Copilot July 10, 2025 11:37
Copilot

This comment was marked as outdated.

@andreaskienle andreaskienle requested a review from Copilot July 14, 2025 07:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables the service to be embedded in openMFP by updating cookie settings for cross-site use, introducing a CSP that restricts framing, and exposing a new FRAME_ANCESTORS environment variable. It also renames the dev flag to --local-dev and wires in @fastify/helmet for CSP enforcement.

  • Adjust session cookies to SameSite=None, secure: true, and partitioned: true for cross-site embedding.
  • Add FRAME_ANCESTORS env var, register it, and enforce it in a CSP frame-ancestors directive via Helmet.
  • Rename local dev flag, update scripts and plugin registrations accordingly.

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server/encrypted-session.js Set cookies to cross-site mode (None), always secure, partitioned
server/config/env.js Added required FRAME_ANCESTORS variable to env schema
server/app.js Removed env plugin registration before session setup (regression)
server.js Registered envPlugin, added Helmet with CSP including frame-ancestors
package.json Changed dev script to use --local-dev, added Helmet dependency
index.html Removed legacy window.global shim
.env.template Documented new FRAME_ANCESTORS variable
Comments suppressed due to low confidence (2)

.env.template:25

  • [nitpick] Consider adding example values (e.g. https://app.example.com https://admin.example.com) to clarify how to format multiple origins for FRAME_ANCESTORS.
FRAME_ANCESTORS=

server/app.js:12

  • The environment plugin registration (envPlugin) was removed, but encryptedSession relies on fastify.config. Re-add await fastify.register(envPlugin); before registering encryptedSession to ensure config values are available.
  fastify.register(encryptedSession, {

Copy link
Member

@n3rdc4ptn n3rdc4ptn left a comment

Choose a reason for hiding this comment

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

Lgtm

@andreaskienle andreaskienle merged commit bff581d into main Jul 17, 2025
5 checks passed
@andreaskienle andreaskienle deleted the feat/make-embeddable branch July 17, 2025 07:53
@andreaskienle andreaskienle mentioned this pull request Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants