USACE / USACE/cwms-data-api

Open Up SAME-ORIGIN to .mil sites

Open
#1,292 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

blobs priority:blocker
Dominant language
Java
Stars
28
Forks
25
Avg merge
4d 22h
Merged PRs (30d)
20

Description

Is your feature request related to a problem? Please describe.
Currently water management is working towards using the Blob endpoint for storing and serving files to/from the cloud.

See:

  • #1283

In order to embed and display various files within our new domain, which is now different from CDA's domain:

https://water.usace.army.mil vs https://cwms-data.usace.army.mil

We will need the SAME-ORIGIN to be relaxed and/or altered.

Describe the solution you'd like
I propose we somehow alter these lines:

https://github.com/USACE/cwms-data-api/blob/develop/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java#L358-L360

To allow for all endpoints except the BLOB endpoint to keep the SAME ORIGIN. Make it so you can embed PDF and other files from Blob.

Additionally, not that we would (Someone might), but what if you wanted to fetch an html page and render that? Say, a report built in html but rendered in our React source?

Describe alternatives you've considered
Include CDA in the reverse proxy config for water.usace.army.mil/cwms-data. This was done previously, but would require everyone using this domain on their sites for cda. This also does not solve the issue for TEST/DEV/Local pages.

@willbreitkreutz may know why this was not done on the WAF already to match the previous setup?

Additional context

Image Image
<object
    data={pdfUrl}
  type="application/pdf"
  width="100%"
  height="1000px"
>
  <embed
    src={pdfUrl}
    type="application/pdf"
    width="100%"
    height="1000px"
  />
  <p>
    Your browser does not support PDFs. Download the PDF{" "}
    <a href={pdfUrl}>here</a>.
  </p>
</object>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with cwms-data-api/src/main/java/cwms/cda/ApiServlet.java around lines 358-360 and review how the SAME-ORIGIN policy is applied. Read issue #1283 and compare the Blob endpoint with the other endpoints, including the stated water.usace.army.mil and cwms-data.army.mil use cases. Done means the intended Blob embedding behavior is supported without unintentionally relaxing protection for other endpoints.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.