Giter Site home page Giter Site logo

axewp / wp-graphql-headless-login Goto Github PK

View Code? Open in Web Editor NEW
63.0 2.0 11.0 4.94 MB

A WordPress plugin that provides Headless login and authentication for WPGraphQL, supporting traditional passwords, OAuth2/OpenID Connect, JWT, and more.

License: GNU General Public License v3.0

JavaScript 0.36% PHP 95.28% Shell 1.37% Dockerfile 0.38% TypeScript 2.40% SCSS 0.21%
graphql headless headless-wordpress jwt login oauth2 sso wordpress wordpress-plugin wp-graphql wp-plugin wpgraphql wpgraphql-plugin authentication openid-connect hacktoberfest hacktoberfest2023

wp-graphql-headless-login's Introduction

Headless Login for WPGraphQL Logo

Headless Login for WPGraphQL

A WordPress plugin that provides headless login and authentication for WPGraphQL, supporting traditional passwords, OAuth2/OpenID Connect, JWT, and more.


Packagist License Packagist Version GitHub commits since latest release (by SemVer) GitHub forks GitHub Repo stars
CodeQuality Integration Coding Standards Coverage Status

Description

Headless Login for WPGraphQL is a flexible and extensible plugin that allows headless WordPress sites to login and authenticate users via WPGraphQL using a variety of authentication methods, including traditional WordPress credentials (username/password), OAuth 2.0 / OpenID Connect, JSON Web Tokens (JWT), and more.

This plugin is inspired by and aims to replace WPGraphQL JWT Authentication as more powerful, comprehensive, and flexible authentication solution for Headless WP.

System Requirements

  • PHP 7.4-8.2+
  • WordPress 6.0+
  • WPGraphQL 1.14.0+

Quick Install

  1. Install & activate WPGraphQL.
  2. Download the latest release .zip file, upload it to your WordPress install, and activate the plugin.
  3. Enable and configure the authentication providers you want to use in GraphQL > Settings > Headless Login.

With Composer

composer require axepress/wp-graphql-headless-login

Updating and Versioning

Until we hit v1.0, we're using a modified version of SemVer, where:

  • v0.x: "Major" releases. These releases introduce new features, and may contain breaking changes to either the PHP API or the GraphQL schema
  • v0.x.y: "Minor" releases. These releases introduce new features and enhancements and address bugs. They do not contain breaking changes.
  • v0.x.y.z: "Patch" releases. These releases are reserved for addressing issue with the previous release only.

Development and Support

Development of Headless Login for WPGraphQL is provided by AxePress Development. Community contributions are welcome and encouraged.

Basic support is provided for free, both in this repo and in WPGraphQL Slack.

Priority support and custom development are available to our Sponsors.

Supported Features

The following functionality is currently supported:

Usage

Getting Started ( ๐ŸŽฏ You are here! )

Core Concepts

Reference

Recipes:

Testing

  1. Update your .env file to your testing environment specifications.
  2. Run composer install to get the dev-dependencies.
  3. Run composer install-test-env to create the test environment.
  4. Run your test suite with Codeception. E.g. vendor/bin/codecept run wpunit will run all WPUnit tests.

wp-graphql-headless-login's People

Contributors

arkdouglas avatar imjlk avatar jasonbahl avatar justlevine avatar kidunot89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wp-graphql-headless-login's Issues

Feature Request: Support for Apple Authentication

What problem does this address?

The lack of Apple authentication in the wp-graphql-headless-login plugin means users with Apple IDs cannot log in using their preferred method.

What is your proposed solution?

N/A

What alternatives have you considered?

N/A

Additional Context

N/A

Allow-Access-Control-Credentials header cannot be set.

Description

There's no option to set the Allow-Access-Control-Credentials header in the advanced settings. The custom fields are appended as a list under another header.

WPGRAPHQL_CORS has a checkbox for this, but there's a note in this plugin that says it's incompatible

Steps to reproduce

  1. Enable the headless login plugin
  2. Attempt to authenticate with a site that requires Allow-Access-Control-Credentials header

Additional context

No response

Plugin Version

1.0..0

WordPress Version

6.2

WPGraphQL Version

1.14.3

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

  • Yes
  • My issue is with a specific 3rd-party plugin.

Admin Field: Additional Domains help text is not shown correctly

Description

Screenshot 2024-08-05 at 19 30 02

'additionalAuthorizedDomains' should display the help text from here

Steps to reproduce

Expand the additional settings and see the help text for additional domains.
The help text should display the help text should display:
Domains added here will also be included in the Access-Control-Allow-Origin header. Make sure to include the protocol (http:// or https://).

Instead says: Separate with commas, spaces, or the Enter key.

Additional context

No response

Plugin Version

0.3

WordPress Version

6.6.1

WPGraphQL Version

1.27.2

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

  • Yes
  • My issue is with a specific 3rd-party plugin.

Fully-implement Typescript for plugin settings

What problem does this address?

Currently, the Plugin Settings screen use Typescript files to add a bit of extra type-safe linting, but its not implemented fully.

With the current state of WP's javascript eschewing traditional back-compat, and since using React for plugin settings is still a fairly uncommon pattern, the more type-safety to easily detect a break, the better.

What is your proposed solution?

All JS files should use Typescript, and ts linting should be added to the CI workflow.

What alternatives have you considered?

No response

Additional Context

No response

Add SAML support

What problem does this address?

SAML is a popular authentication method - especially in the enterprise space. We should support it.

What is your proposed solution?

Create a new ProviderConfig that implements onelogin/php-saml.

What alternatives have you considered?

There are a few other SAML libraries for PHP, but onelogin's is by far the standard.

Additional Context

No response

Generic Oauth2 can not be enabled

Description

Hello! I am trying to set up Discord Oauth2 with the generic Oauth2 provider. However I get the error message
"debugMessage": "Provider generic-oauth2 is not enabled."

I can see in my database that the isEnabled property is correct for the provider, and based on what i'm seeing in the ProviderRegistry.php file I would be receiving another message if there was error in the config.

Steps to reproduce

Run a generic Oauth2 login mutation

mutation discordAuth($code: String = "xxx") {
  login(
    input: {provider: GENERIC_OAUTH2, oauthResponse: {code: $code, state: ""}}
  ) {
    authToken
  }
}

Additional context

No response

Plugin Version

0.0.7

WordPress Version

Version 6.2

WPGraphQL Version

1.14.0

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

  • Yes
  • My issue is with a specific 3rd-party plugin.

Fatal error on activation

Description

I caught a fatal error when trying to install the plugin.

Steps to reproduce

  1. Install & activate WPGraphQL.
  2. Download the 0.1.4 release .zip file, upload it to your WordPress install, and try to activate the plugin.

Additional context

Plugin could not be activated because it triggered a fatal error.

Warning: require(/var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/vendor/composer/../ralouphie/getallheaders/src/getallheaders.php): Failed to open stream: No such file or directory in /var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/vendor/composer/autoload_real.php on line 41 Fatal error: Uncaught Error: Failed opening required '/var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/vendor/composer/../ralouphie/getallheaders/src/getallheaders.php' (include_path='.:/usr/local/lib/php') in /var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/vendor/composer/autoload_real.php:41 Stack trace: #0 /var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/vendor/composer/autoload_real.php(45): ComposerAutoloaderInite3dd5adcad35e0c0a990ad87f09c52a0::{closure}('7b11c4dc42b3b30...', '/var/www/html/w...') #1 /var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/vendor/autoload.php(25): ComposerAutoloaderInite3dd5adcad35e0c0a990ad87f09c52a0::getLoader() #2 /var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/src/Autoloader.php(33): require_once('/var/www/html/w...') #3 /var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/wp-graphql-headless-login.php(34): WPGraphQL\Login\Autoloader::autoload() #4 /var/www/html/wp-admin/includes/plugin.php(2314): include_once('/var/www/html/w...') #5 /var/www/html/wp-admin/plugins.php(192): plugin_sandbox_scrape('wp-graphql-head...') #6 {main} thrown in /var/www/html/wp-content/plugins/wp-graphql-headless-login-0.1.4/vendor/composer/autoload_real.php on line 41

Plugin Version

0.1.4

WordPress Version

6.2.2

WPGraphQL Version

1.19.0

Additional enviornmental details

docker-compose.yaml:

version: '3.8'
services:
wordpress:
image: wordpress:6.2.2
restart: always
ports:
- "8000:80"
environment:
ENVIRONMENT: ${ENVIRONMENT}
WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
WORDPRESS_DEBUG: true
DRAFT_SECRET: ${DRAFT_SECRET}
DRAFT_COOKIE_LIVE_TIME_S: ${DRAFT_COOKIE_LIVE_TIME_S}
GRAPHQL_JWT_AUTH_SECRET_KEY: ${GRAPHQL_JWT_AUTH_SECRET_KEY}
volumes:
- ./wp-content:/var/www/html/wp-content
depends_on:
- db
networks:
- my_network
db:
image: mysql:5.7
restart: always
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: ${WORDPRESS_DB_NAME}
MYSQL_USER: ${WORDPRESS_DB_USER}
MYSQL_PASSWORD: ${WORDPRESS_DB_PASSWORD}
MYSQL_RANDOM_ROOT_PASSWORD: ${MYSQL_RANDOM_ROOT_PASSWORD}
volumes:
- db_data:/var/lib/mysql
networks:
- my_network
networks:
my_network:
volumes:
db_data:

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

  • Yes
  • My issue is with a specific 3rd-party plugin.

Settings not loading and JavaScript errors when `site_url` and `home_url` are on different domains

Description

I am experiencing an issue with the Headless Login Settings addon. Despite trying different versions and disabling other addons, the Headless Login Settings are not loading properly. I have attached screenshots for reference.

Additionally, whenever I click on any button, I encounter JavaScript errors, as shown in the screenshots.
image
image

Steps to reproduce

  1. Install Headless Login Settings addon.
  2. Change the site url to the frontend url, make it different from the wordpress address url
    image
  3. Attempt to access the settings page.
  4. Click on any button. Nothing change, and the "Please wait while the settings are loaded" never change.

Additional context

The Headless Login Settings should load without any issues, and clicking on buttons should not result in JavaScript errors.

Plugin Version

0.1.4. Installed via the zip via the github release page (tried the last 5 releases its the same)

WordPress Version

6.3.2

WPGraphQL Version

1.17.0

Additional enviornmental details

Site Language | en_US
User Language | en_US
Timezone | +00:00
Home URL | https://frontendurl
Site URL | https://wordpressinstallurl
Permalink structure | /%postname%/
Is this site using HTTPS? | Yes
Is this a multisite? | No
Can anyone register on this site? | Yes
Is this site discouraging search engines? | No
Default comment status | Open
Environment type | production
User count | 4
Communication with WordPress.org | WordPress.org is reachable

Headless Login for WPGraphQL | Version 0.1.4 by AxePress | Auto-updates disabled
WPGraphQL | Version 1.17.0 by WPGraphQL | Auto-updates disabled

Server architecture | Unable to determine server architecture

Web server | nginx/1.22.1
PHP version | 8.0.25 (Supports 64bit values)
PHP SAPI | fpm-fcgi
PHP max input variables | 5000
PHP time limit | 300
PHP memory limit | 1073741824
Max input time | 60
Upload max filesize | 512M
PHP post max size | 512M
cURL version | 7.83.1 OpenSSL/1.1.1s
Is SUHOSIN installed? | No
Is the Imagick library available? | Yes
Are pretty permalinks supported? | Yes
Current time | 2023-10-29T15:33:39+00:00
Current UTC time | Sunday, 29-Oct-23 15:33:39 UTC
Current Server time | 2023-10-29T15:33:38+00:00

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

  • Yes
  • My issue is with a specific 3rd-party plugin.

Add support for setting WP login cookies

What problem does this address?

Currently, users need to authenticate separately on WP and the frontend. This makes admin preview flows more annoying, as well as complicates the current recommended wp-graphql-woocommerce checkout approach which suggests using the server checkout over manually registering GraphQL support for payment gateways.

What is your proposed solution?

Add the ability to generate WP Login cookies when authenticating, with a corresponding toggle in the plugin settings.

What alternatives have you considered?

No response

Additional Context

https://mikejolley.com/2021/03/02/headless-wordpress-cookie-based-login-using-graphql/

https://developers.wpengine.com/blog/headless-wordpress-authentication-native-cookies

Document how to bind to `next-auth` / `authjs` ?

What problem does this address?

I want my WooCommerce users to connect to my application using NextAuth through my Wordpress.

What is your proposed solution?

I used Generic OAuth2 using Auth0. But in development mode it's a nightmare.

What alternatives have you considered?

I want to use site token but there's no doc for that

Additional Context

No response

SetCookie Header didn't specify a "SameSite" attribute - Set Authentication Cookie Option

Description

Hi,

I have created a simple React App (running on http://localhost:5173) that fetches data through WPGraphql.
I have installed wp-graphql-headless-login in order to get Social login features (Google and Facebook).

I am in the process of configuring the Google auth and i would like the wp-headless-login plugin to set the wp authentication cookie automatically on login success.

I am now able to login and create the logged in user automatically in wordpress.
The problem i am facing is that the wp auth cookie does not get set because it is lacking of the SameSite attribute.
I can see that the request tries to set the wp auth cookie but it does not get set.

Here is a screenshot:

Screenshot 2023-12-21 at 18 28 21

There is no way for me within the plugin to change the SameSite attribute to none ?

here is my plugin configuration

Screenshot 2023-12-21 at 18 30 00.

Steps to reproduce

  1. Install the plugin
  2. add a Google provider along with CLIENT ID and CLIENT SECRET.
  3. In the plugin Login Settings TURN ON all settings.
  4. In the plugin Access Control Settings TURN ON Block unauthorized domains and Add ACAC.
  5. Set the locally running react frontend url in the authorized domains.

Additional context

No response

Plugin Version

0.1.4

WordPress Version

6.4.2

WPGraphQL Version

1.19.0

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

  • Yes
  • My issue is with a specific 3rd-party plugin.

External provider integration

Description

Trying to integrate an external provider (TheNetworg\OAuth2\Client\Provider\Azure), I receive the error "The provider class must extend AbstractProvider".

It appears to be because OAuth2Config is expecting AbstractProvider to be in the WPGraphQL\Login\Vendor\League\OAuth2\Client\Provider namespace, rather than \League\OAuth2\Client\Provider, since it's been prefixed with Strauss.

I did not get the same error when testing the example here, but it's a bit beyond my ken at the moment to say why that's different (perhaps since it's already a dependency?)

I guess #96 (comment) is a similar report.

Steps to reproduce

Implement skeleton config like

<?php

namespace App\GraphQL\OAuthProviderConfig;

use TheNetworg\OAuth2\Client\Provider\Azure;

class AzureProviderConfig extends
	\WPGraphQL\Login\Auth\ProviderConfig\OAuth2\OAuth2Config
{
	public function __construct()
	{
		parent::__construct(Azure::class);
	}

	public static function get_name(): string
	{
		return __('Azure', 'wp-graphql-login');
	}

	public static function get_slug(): string
	{
		return 'azure';
	}

	protected static function client_options_schema(): array
	{
		return [];
	}

	public static function client_options_fields(): array
	{
		return [];
	}

	public function get_user_data(array $owner_details): array
	{
		return [];
	}

	protected function get_options(array $settings): array
	{
		return [];
	}
}
add_filter('graphql_login_registered_provider_configs', function (
	array $provider_configs
) {
	// Give the provider a unique slug, and pass the ProviderConfig class name.
	$provider_configs['azure'] =
		\App\GraphQL\OAuthProviderConfig\AzureProviderConfig::class;

	return $provider_configs;
});

Additional context

No response

Plugin Version

0.1.4

WordPress Version

6.4.2

WPGraphQL Version

1.19.0

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

  • Yes
  • My issue is with a specific 3rd-party plugin.

0.0.9 breaks the "ADDITIONAL AUTHORIZED DOMAINS" form field

Description

Upgrading to 0.0.9 renders the form field for "additional authorized domains" in the provider settings unusable - any input fields do not display, when a new host is input it dissapears.

Steps to reproduce

  1. Install 0.0.9
  2. Go to graphql > settings > headless login
  3. Scroll down to "Access Control Settings"
  4. Attempt to utilize the "Additional authorized domains" field

Additional context

No response

Plugin Version

0.0.9

WordPress Version

6.2

WPGraphQL Version

1.14.0

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

  • Yes
  • My issue is with a specific 3rd-party plugin.

Add E2E and acceptance tests for settings

What problem does this address?

Gutenberg likes to break things, but we need to make sure updates don't break any functionality or extensibility.

What is your proposed solution?

We should implement codecept acceptance tests and playright e2e tests to ensure a stable backend.

What alternatives have you considered?

No response

Additional Context

Inspiration: WordPress/gutenberg#38851

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.