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

Access denied for : keystone{ adminMeta { lists { ... #5807

Closed
Temkit opened this issue May 27, 2021 · 1 comment · Fixed by #6955
Closed

Access denied for : keystone{ adminMeta { lists { ... #5807

Temkit opened this issue May 27, 2021 · 1 comment · Fixed by #6955

Comments

@Temkit
Copy link

Temkit commented May 27, 2021

this query is not working :

const { data: modules, errors: errorModules } = await client.query({
      query: gql`
        {
          keystone {
            adminMeta {
              lists {
                key
                description
                label
                singular
                plural
                path
                fields {
                  path
                }
              }
            }
          }
        }
      `,

with error :

ApolloError: GraphQL error: Access denied
at new ApolloError (/Users/sidalitemkit/work/web/ysana/kysana-pql/scripts/sanitate/node_modules/apollo-client/bundle.umd.js:92:26)
at /Users/sidalitemkit/work/web/ysana/kysana-pql/scripts/sanitate/node_modules/apollo-client/bundle.umd.js:1588:34
at /Users/sidalitemkit/work/web/ysana/kysana-pql/scripts/sanitate/node_modules/apollo-client/bundle.umd.js:2008:15
at Set.forEach ()
at /Users/sidalitemkit/work/web/ysana/kysana-pql/scripts/sanitate/node_modules/apollo-client/bundle.umd.js:2006:26
at Map.forEach ()
at QueryManager.broadcastQueries (/Users/sidalitemkit/work/web/ysana/kysana-pql/scripts/sanitate/node_modules/apollo-client/bundle.umd.js:2004:20)
at /Users/sidalitemkit/work/web/ysana/kysana-pql/scripts/sanitate/node_modules/apollo-client/bundle.umd.js:2131:19
at Object.next (/Users/sidalitemkit/work/web/ysana/kysana-pql/scripts/sanitate/node_modules/zen-observable/lib/Observable.js:322:23)
at notifySubscription (/Users/sidalitemkit/work/web/ysana/kysana-pql/scripts/sanitate/node_modules/zen-observable/lib/Observable.js:135:18) {
graphQLErrors: [
{
message: 'Access denied',
locations: [Array],
path: [Array],
extensions: [Object],
uid: 'ckp6wxt8s0000kkuu3u9nfs2b',
name: 'GraphQLError'
}
],
networkError: null,
extraInfo: undefined
}

To Reproduce

Steps to reproduce the behaviour:

  1. create a new keystone next project with yarn
  2. run the query like this :
  const authLink = setContext(async (_, { headers }) => {
    return {
      headers: {
        ...headers,
        authorization: `Bearer Fe26.2******  `,
      },
    };
  });

  const httpLink = createHttpLink({
    uri: 'http://localhost:3000/api/graphql',
    fetch: fetch,
  });

  const client = new ApolloClient({
    link: authLink.concat(httpLink),
    cache: new InMemoryCache(),
  });

  try {
    console.log('initata');
    const { data: modules, errors: errorModules } = await client.query({
      query: gql`
        {
          keystone {
            adminMeta {
              lists {
                key
                description
                label
                singular
                plural
                path
                fields {
                  path
                }
              }
            }
          }
        }
      `,
    });

Expected behavior

when running on the graphQl Explorer its working :

Screen Shot 2021-05-27 at 2 22 05 PM

@Temkit
Copy link
Author

Temkit commented May 27, 2021

but working when i do : isAccessAllowed: (context) => true,

export default auth.withAuth(
  config({
    db: {
      adapter: 'prisma_postgresql',
      url: '*********',
    },
    ui: {
      isAccessAllowed: (context) => true,
    },
    lists,
    session: withItemData(
      statelessSessions({
        maxAge: sessionMaxAge,
        secret: sessionSecret,
      }),
      { User: 'email' },
    ),
  }),
);

i thought that was only for UI ?
Why it's not working when using context.sudo ?

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 a pull request may close this issue.

2 participants