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

Cannot access payload-webp optimized images using query return in access control #3101

Closed
DanielKraemer opened this issue Jul 31, 2023 · 2 comments
Assignees
Labels
status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@DanielKraemer
Copy link

Link to reproduction

To Reproduce

Upload images to a media collection with a relationship field (e. g. to a site) and have payload-webp installed and activated.
Only allow user to read the webp files if they have a relationship to the same site and use a query constrained for checking this.

Access-configuration for my media collection:
access: { create: ****, read: hasBasicReadAccess('site'), update: ****, delete: **** },

Function "hasBasicReadAccess":

export const hasBasicReadAccess = (siteIdFieldName = 'siteId'): Access => ({
  req: {
    user,
  },
}) => {
  if (user?.isSystemAdmin) return true;
  if (user) {

    const userSiteIds = [];

    if (user.sites && user.sites.length > 0) {
      user.sites.forEach(({ site } : { site: string | Site }) => {
        userSiteIds.push((typeof site === 'string') ? site : site.id);
      });
    }

    return {
      or: [
        {
          author: {
            equals: user.id,
          },
        },
        {
          [siteIdFieldName]: {
            in: userSiteIds,
          },
        },
      ],
    };
  }
  return false;
};

Describe the Bug

I cannot access a .webp media file created by payload-webp when return a query constrain while checking read-access.

Testing it as a mongodb query using robo3t for example all is fine.

Always receiving error
Forbidden: You are not allowed to perform this action. at /home/user/payloadcms/node_modules/payload/src/auth/getExecuteStaticAccess.ts:53:17 at processTicksAndRejections (node:internal/process/task_queues:95:5)

payload-webp version: ^1.1.0

Payload Version

1.8.2

@DanielKraemer DanielKraemer added the status: needs-triage Possible bug which hasn't been reproduced yet label Jul 31, 2023
@tylandavis
Copy link
Member

Hello @DanielKraemer, payload-webp is not an official plugin and therefor not maintained by us, I would suggest opening an issue on the plugin's repo in order to get help with this issue.

Copy link
Contributor

github-actions bot commented Sep 7, 2024

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants