Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

GraphQL: Can't read page.single with there is read permission on page #1895

Closed
codevin opened this issue May 15, 2020 · 11 comments
Closed

GraphQL: Can't read page.single with there is read permission on page #1895

codevin opened this issue May 15, 2020 · 11 comments
Assignees
Labels

Comments

@codevin
Copy link

codevin commented May 15, 2020

In the page-component pull request which I submitted, GraphQL query is used to read the Component page. It fails for general user because it tests 'manage.page' or 'delete.page' permissions.

Shouldn't it also include 'read.page' also? Because if guest can read a page, GraphQL should also be able to read it.

File: https://github.com/Requarks/wiki/blob/master/server/graph/resolvers/page.js
Function:

  async single (obj, args, context, info) {
      let page = await WIKI.models.pages.getPageFromDb(args.id)
      if (page) {
        if (WIKI.auth.checkAccess(context.req.user, ['manage:pages', 'delete:pages'], {
          path: page.path,
          locale: page.localeCode
        })
@Smankusors
Copy link

Are you sure your global permission and page rules are correct? You cannot just set global permission without page rules.

@codevin
Copy link
Author

codevin commented May 15, 2020 via email

@NGPixel
Copy link
Member

NGPixel commented May 15, 2020

The single endpoint does not check for page rules, only permissions, because it's meant to be used by the admin panel, which is why there's no read:pages permission.

Adding the read:pages permission would require the page rules to be checked and some properties to be marked as manage only.

@codevin
Copy link
Author

codevin commented May 16, 2020

Could you revisit the assumption that GraphQL is only used by admin users or for admin purposes only?

Because page-components depends on some API way to access the source of page. I guess this is important design decision.

My point is that page-components will enable more interesting functionality within wikis (like introducing widgets like weather, show table data and so on). It won't work without this capability as of now.

@NGPixel
Copy link
Member

NGPixel commented May 16, 2020

That's not what I said. This specific resource is for admin. Many other GraphQL resources are used by normal users and guests.

What is your use case for querying the page source?

@codevin
Copy link
Author

codevin commented May 16, 2020 via email

@NGPixel
Copy link
Member

NGPixel commented May 18, 2020

I don't think using pages to store Vue components is the best idea. It would be very inefficient to fetch and store them in this manner. I would rather have a dedicated table and resolvers. And possibly inject them directly on the page server-side so they load instantly on the client.

@codevin
Copy link
Author

codevin commented May 18, 2020 via email

@codevin
Copy link
Author

codevin commented May 20, 2020

Can we at least have client side plugins, so those who are interested can have this capability?

I will open a feature request in feedback to get some votes.

@NGPixel
Copy link
Member

NGPixel commented May 20, 2020

I'm all for it, I just don't agree with the suggested implementation.

A feature request where the implementation can be discussed would be best.

@codevin
Copy link
Author

codevin commented Sep 25, 2020 via email

@NGPixel NGPixel closed this as completed Mar 21, 2021
@requarks requarks locked and limited conversation to collaborators Mar 21, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

3 participants