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

The field \"RootMutation.login\" cannot be accessed without authentication. #169

Open
rotkohlsuppe opened this issue Oct 6, 2022 · 3 comments

Comments

@rotkohlsuppe
Copy link

rotkohlsuppe commented Oct 6, 2022

Hi everybody,
I'm trying to access the endpoint through the official WPGraphQL Plugin from the WP Plugin Library.
The plugin features the option to disable all requests, except authorized ones:
Bildschirmfoto 2022-10-06 um 17 31 43

In order to use this feature I installed this plugin wp-graphql-jwt-authentication.
But with the option from above activated it doesn't allow access to the login field anymore:
The field \"RootMutation.login\" cannot be accessed without authentication.

How should I deal with this? I know the plugin works, for example querying users only works with authentication through this JWT plugin. But I want to restrict access to every endpoint, including Pages, Posts, etc., except for the Authentication Enpoint.
How can I achieve this, if this plugin doesn't work with the option from WPGraphQL?
Thanks for any ideas! Cheers!

@davidmadon
Copy link

I'm running into the same issue.
Shouldn't the plugin work with the "restrict endpoints" setting active in WPGraphQL?

Any suggestions?

@lucaBuccarello
Copy link

lucaBuccarello commented Oct 25, 2022

You have to specify to the plugin which mutation has to be public

  1. Go in wordpress and find wp-graphql-jwt-authentication plugin path
  2. Open "wp-graphql-jwt-authentication.php"
  3. In the init() function add these lines after the end of the first "add_filter":
add_filter( 
  'graphql_require_authentication_allowed_fields', 
  function( $allowed ) {
	$allowed[] = 'login';
	return $allowed;
}, 10, 1 );

Reference: link
@rotkohlsuppe @davidmadon

@rotkohlsuppe
Copy link
Author

You have to specify to the plugin which mutation has to be public

1. Go in wordpress and find wp-graphql-jwt-authentication plugin path

2. Open "wp-graphql-jwt-authentication.php"

3. In the init() function add these lines after the end of the first "add_filter":
add_filter( 
  'graphql_require_authentication_allowed_fields', 
  function( $allowed ) {
	$allowed[] = 'login';
	return $allowed;
}, 10, 1 );

Reference: link @rotkohlsuppe @davidmadon

Thank you very much. Will give it a try

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

No branches or pull requests

3 participants