Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add support for proxying images and files always via keystone express server, no matter local or s3, and add security access control extension hook #9001

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sunnymoon
Copy link

Implemented proxied mode (it was referred to in the documentation and examples as creating a server route on express, but it didn't for s3 case) in s3 as well as leaving the same "static express mapping" as before for local storage mode.
Implemented an access Control hook extension point to validate access to either local or s3 assets with proxied mode
Fix the documentation to conform to "serverRoute" always (instead of distinguishing between s3 or local kinds).
Still feel the code could be further improved by:

  1. Not allowing "generateUrl" to be implemented on the case of "proxied" mode (serverRoute.path defined)
  2. Check for "overlaps" between the "serverRoute.path" and other express middlewares at startup and warning the devs about it
  3. Implement the pathPrefix option (correctly on s3) on local storage kind (and mkdir accordingly at startup)
  4. Check for "signed" vs "serverRoute.path" vs "acl" options and warn devs appropriately

Copy link

codesandbox-ci bot commented Feb 1, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 79620ca:

Sandbox Source
@keystone-6/sandbox Configuration

@sunnymoon
Copy link
Author

Is anyone looking at PRs? How could I help further ?

@pmatrola-linkare
Copy link

I need this pull request to use in my project

@dcousens
Copy link
Member

dcousens commented Mar 1, 2024

Hi @sunnymoon, I am reviewing pull requests, but I haven't had a chance to test this particular pull request yet.

If anyone else is up to help review and test, that will be appreciated.

@sunnymoon
Copy link
Author

sunnymoon commented Mar 1, 2024 via email

@dcousens
Copy link
Member

@sunnymoon sorry I missed your question in March, any review is helpful, and this pull request is needing a rebase and preferably an eslint --fix call 💛

import cors, { type CorsOptions } from 'cors'
import express from 'express'
import type { GraphQLFormattedError, GraphQLSchema } from 'graphql'
import { createServer, type Server } from 'http'
Copy link
Member

Choose a reason for hiding this comment

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

Let's drop unnecessary changes from this pull request

/** A function that is checked before serving the file or image to check for permissions.
* This function will only be respected if the serverRoute is set
*/
isAccessAllowed?: (options: StorageAccessAllowedOptions) => boolean,
Copy link
Member

@dcousens dcousens May 23, 2024

Choose a reason for hiding this comment

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

If this only works if serverRoute is set, we should probably put this in the serverRoute object

@dcousens
Copy link
Member

dcousens commented May 23, 2024

I'm wondering if this is how you should approach this generally, something seems like an anti-pattern somewhere so I might need to look at this more conceptually first.

@sunnymoon
Copy link
Author

sunnymoon commented May 23, 2024 via email

@sunnymoon
Copy link
Author

sunnymoon commented May 23, 2024 via email

@sunnymoon
Copy link
Author

sunnymoon commented May 23, 2024 via email

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.

None yet

3 participants