Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add first concept for link-sharing #1831

Merged
merged 9 commits into from
Jan 28, 2025
Merged

Add first concept for link-sharing #1831

merged 9 commits into from
Jan 28, 2025

Conversation

pylipp
Copy link
Contributor

@pylipp pylipp commented Dec 6, 2024

Rendered document.

PasswordPusher ADR

It got more detailed in the BE part. For the UI it's rather some questions/ideas.

LMK if parts are not clear.

@pylipp
Copy link
Contributor Author

pylipp commented Dec 6, 2024

- the shared data will be live (as opposed to "freezing" the data to the time of link creation)
- link format is `.../<code> (can't use `.../bases/X/statviz`: insecure because it's easy to navigate to other bases and view their data; also not unique (can't expire))
- the expiration time of the link is one week. Later we can make is customizable, and/or add an action to invalidate a created link
- we expose the public app in the `api` GAE service. Hence it won't interfer with the main `app` service
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this already the case? Or something we're doing specifically for link sharing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we're not doing this yet. It's a suggestion for the link-sharing use case.


- there has to be a new action-based permission to allow link-creation for certain usergroups
- there has to be a public FE and a public GraphQL endpoint to fetch data
- the public FE is hosted under `api.boxtribute.org/shared` and deployed with the `deploy-api` CircleCI job (depends a new `build-statviz` job)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you share context on why you're suggesting this? It seems strange to me to host the FE on what appears to be an API endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggested this for simplicity (less devops effort because we don't need to establish a new subdomain nor any new GAE services). The endpoints we currently have for the api subdomains are the GraphQL one at / and the documentation at /docs.
For a separation of concerns it probably makes sense to have a dedicated subdomain for link-sharing.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pylipp got it. Is there any other way we can achieve that? If the back end link sharing is going to be part of the standard API on the api subdomain, then any reason the link sharing can't just operate as part of the same FE code base? Or am I misunderstanding here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, this comment slipped through somehow. @jamescrowley

any reason the link sharing can't just operate as part of the same FE code base?
Do you want the link-sharing back-end to be part of the FE code base? Or do you want the public FE for shared links to be in the same code base as the standard FE?

One more thing re the new public BE: When we introduce a new /shared route on the api subdomain, we can (and will) use a new schema there, different from the standard API schema (hosted on /).

### Open questions

- how do avoid misuse of the link, or the exposed public GraphQL endpoint (DDoS mitigation)?
- can FE resolve a URL like `.../<code>` into a route like `.../<code>/bases/X/statviz` on the FE **and** process the returned data as if it was a GraphQL response?
Copy link
Contributor

Choose a reason for hiding this comment

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

when you say resolve, does the FE actually need to map to a different route? Is it just crafting a graphql query directly? I wasn't clear why the FE would need to "process the returned data as if it was a GraphQL response?" - or specifically, why it therefore wouldn't be a graphql response in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We (Hans, Felipe, me) talked about this yesterday; it seems to be feasible but requires adjustments to existing queries.

I'll try to explain it like this: in v2, when the user visits e.g. /bases/2/statviz, it will load the page and send a GraphQL request to the BE. A GraphQL response is returned and used to build the page.
For the scenario of link-sharing I was thinking whether the following is possible:

  1. user visits link at .../<code>
  2. FE sends request incl the code
  3. BE checks the code. Since it has saved the type of requested data at the time of link creation, it can now look up the data and return it in the response, incl the corresponding route for FE
  4. FE goes to the returned route and plugs in the returned data (instead of issuing another GraphQL request)
    You can see this as a mind experiment of mine rather 😄 does it make sense to you?

The approach we agreed on is different though:

  1. FE sends request with code
  2. BE validates code and sends metadata route
  3. FE goes to route and runs GraphQL queries to fetch data

Copy link
Member

@HaGuesto HaGuesto Jan 14, 2025

Choose a reason for hiding this comment

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

@pylipp sorry, but did we really agree on that? Performance-wise this is not a nice solution since we are creating a waterfall, e.g. you have to wait for two requests instead of just one. This is rather how I would do it:

  1. FE sends request with code
  2. BE validates code and sends back information which view is behind that code and the corresponding requested data needed to show the view, e.g.
{
    resolveSharableLink {
        view
        viewData {
             createdBoxes { 
  1. FE should either render the returned view under the same route or redirect (not sure what is easier).
  2. Since the data is already cached in the FE from the first request, no additional request to the BE should happen.


### Open questions

- how do avoid misuse of the link, or the exposed public GraphQL endpoint (DDoS mitigation)?
Copy link
Contributor

Choose a reason for hiding this comment

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

Could look at rate limiting server side based on the link hash being passed in. Could also consider https://cloud.google.com/armor/docs

@pylipp pylipp force-pushed the draft-for-link-sharing branch from df7f4b5 to df392c6 Compare December 23, 2024 18:01
@aerinsol
Copy link
Member

aerinsol commented Dec 24, 2024

@jamescrowley , would be interested in getting your input with all the findings made by the team, especially for the password pusher library (or suitable alternative).

Copy link
Member

@aerinsol aerinsol left a comment

Choose a reason for hiding this comment

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

LGTM, would like to hear more technical commentary on @jamescrowley from the answer, and both @jamescrowley and @HaGuesto on PP analysis.

@HaGuesto
Copy link
Member

HaGuesto commented Jan 14, 2025

I took a look at the PP REST API. Here my thoughts:

Pro:

  • it does what we need and is not much more complex than this.
  • we can integrate it in a modular way so that we can easily replace it by another provider or our own structure if we really run into problems at some point.
  • the integration is very simple (PP account creation and then API token creation, implementing two kind of requests from the BE, adding secrets to CircleCI) and will save us time to get first prototypes out.

Con:

  • I didn't see what the rate limit is but from the documentation it sounds like we should not run into problems in the near future.
  • repo is active, but mainly maintained by one person.
  • we need to be careful what data we want to store in the links. There shouldn't be user information in there, maybe a user id but only if we really need it.

I'd go for it. @pylipp feel free to book me if you want to talk about it. I also pinged @jamescrowley on it.

@pylipp
Copy link
Contributor Author

pylipp commented Jan 15, 2025

@HaGuesto Thanks for the feedback and the new idea of integrating PP, I quite like it too. I directly updated the doc acc. a couple of comments.

@pylipp
Copy link
Contributor Author

pylipp commented Jan 20, 2025

Related follow-up discussion on Slack

@pylipp pylipp force-pushed the draft-for-link-sharing branch from 8fa3f37 to bee3423 Compare January 27, 2025 16:41
@pylipp
Copy link
Contributor Author

pylipp commented Jan 27, 2025

@pylipp pylipp merged commit 7b02eac into master Jan 28, 2025
@pylipp pylipp deleted the draft-for-link-sharing branch January 28, 2025 16:37
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants