Giter VIP home page Giter VIP logo

wordpress's Introduction

WordPress by Auth0

WordPress Plugin for Auth0 Authentication

License

๐Ÿš€ Getting Started - ๐Ÿ’ป SDK Usage - ๐Ÿ“† Support Policy - ๐Ÿ’ฌ Feedback

Overview

The Auth0 WordPress plugin replaces the standard WordPress login flow with a new authentication process using Auth0's Universal Login experience. This enables you to secure your WordPress site with Auth0's advanced features, such as MFA, SSO, Passwordless, PassKey, and so on.

Important

This plugin is NOT a SDK (Software Development Kit.) It's APIs are internal and not intended for developers to extend directly. We do not support altering the plugin's behavior or integrating it in any way beyond what is outlined in this README. If you're looking to build a more extensive integration, please create a solution using the Auth0-PHP SDK instead.

Warning

v4 of the plugin is no longer supported as of June 2023. We are no longer providing new features or bugfixes for that release. Please upgrade to v5 as soon as possible.

Getting Started

Requirements

Please review our support policy on specific PHP and WordPress versions and when they may exit support in the future.

Installation

Composer

The plugin supports installation through Composer, and is WPackagist compatible. This approach is preferred when using Bedrock, but will work with virtually any WordPress installation.

For Bedrock installations, you'll usually run this command from the root WordPress installation directory, but check the documentation the project's maintainers provide for the best guidance.

For standard WordPress installations, this command can be run from the wp-content/plugins sub-directory.

composer require symfony/http-client nyholm/psr7 auth0/wordpress:^5.0

Note on Composer Dependencies

When installed with Composer, the plugin depends on the presence of PSR-18 and PSR-17 library implementations. The require command above includes two such libraries (symfony/http-client and nyholm/psr7) that satisfy these requirements, but you can use any other compatible libraries that you prefer. Visit Packagist for a list of PSR-18 and PSR-17 providers.

If you are using Bedrock or another Composer-based configuration, you can try installing auth0/wordpress without any other dependencies, as the implementations may be satisfied by other already installed packages.

Note PHP Standards Recommendations (PSRs) are standards for PHP libraries and applications that enable greater interoperability and choice. You can learn more about them and the PHP-FIG organization that maintains them here.

Activation

After installation, you must activate the plugin within your WordPress site:

  1. Open your WordPress Dashboard.
  2. Select 'Plugins' from the sidebar, and then 'Installed Plugins.'
  3. Choose 'Activate' underneath the plugin's name.

Configure Auth0

  1. Sign into Auth0. If you don't have an account, it's free to create one.
  2. Open 'Applications' from your Auth0 Dashboard, and select 'Create Application.'
  3. Choose 'Regular Web Application' and then 'Create.'
  4. From the newly created application's page, select the Settings tab.

Please prepare the following information:

  • Note the Domain, Client ID, and Client Secret, available from the newly created Application's Settings page. You will need these to configure the plugin in the next step.
  • From your WordPress Dashboard's General Settings page, note your WordPress Address and Site Address URLs. We recommend you read our guidance on common WordPress URL issues.

Continue configuring your Auth0 application from its Settings page:

  • Allowed Callback URLs should include the URL to your WordPress site's wp-login.php.
    • In most (but not all) cases, this will be your WordPress Address with /wp-login.php appended.
    • Please ensure your site is configured never to cache this URL, or you may see an "invalid state" error during login.
  • Allowed Web Origins should include both your WordPress Address and Site Address URLs.
  • Allowed Logout URLs should consist of your WordPress Address.

Common WordPress URL Issues
  • These must be the URLs your visitors will use to access your WordPress site. If you are using a reverse proxy, you may need to manually configure your WordPress Address and Site Address URLs to match the URL you use to access your site.
  • Make sure these URLs match your site's configured protocol. When using a reverse proxy, you may need to update these to reflect serving over SSL/HTTPS.

Troubleshooting

If you're encountering issues, start by checking that your Auth0 Application is setup like so:

  • Application Type must be set to Regular Web Application.
  • Token Endpoint Authentication Method must be set to Post.
  • Allowed Origins (CORS) should be blank.

Scroll down and expand the "Advanced Settings" panel, then:

  • Under OAuth:
    • Ensure that JsonWebToken Signature Algorithm is set to RS256.
    • Check that OIDC Conformant is enabled.
  • Under Grant Types:
    • Ensure that Implicit, Authorization Code, and Client Credentials are enabled.
    • You may also want to enable Refresh Token.

Configure the Plugin

Upon activating the Auth0 plugin, you will find a new "Auth0" section in the sidebar of your WordPress Dashboard. This section enables you to configure the plugin in a variety of ways.

For the plugin to operate, at a minimum, you will need to configure the Domain, Client ID, and Client Secret fields. These are available from the Auth0 Application you created in the previous step. Once configured, select the "Enable Authentication" option to have the plugin begin handling authentication for you.

We recommend testing on a staging/development site using a separate Auth0 Application before putting the plugin live on your production site.

Configure WordPress

Plugin Database Tables

The plugin uses dedicated database tables to guarantee high performance. When the plugin is activated, it will use the database credentials you have configured for WordPress to create these tables.

Please ensure your configured credentials have appropriate privileges to create new tables.

Cron Configuration

The plugin uses WordPress' background task manager to perform important periodic tasks. Proper synchronization between WordPress and Auth0 relies on this.

By default, WordPress' task manager runs on every page load, which is inadvisable for production sites. For best performance and reliability, please ensure you have configured WordPress to use a cron job to run these tasks periodically instead.

SDK Usage

The plugin is built on top of Auth0-PHP โ€” Auth0's full-featured PHP SDK for Authentication and Management APIs.

For custom WordPress development, please do not extend the plugin's classes themselves, as this is not supported. Nearly all of the plugin's APIs are considered internal and will change over time, most likely breaking any custom extension built upon them.

Instead, please take advantage of the full PHP SDK that the plugin is built upon. You can use the plugin's getSdk() method to retrieve a configured instance of the SDK, ready for use. This method can be called from the plugin's global wpAuth0() helper, which returns the WordPress plugin itself.

<?php

$plugin = wpAuth0(); // Returns an instanceof Auth0\WordPress\Plugin
   $sdk = wpAuth0()->getSdk(); // Returns an instanceof Auth0\SDK\Auth0

Please direct questions about developing with the Auth0-PHP SDK to the Auth0 Community, and issues or feature requests to it's respective repository. Documentations and examples on working with the Auth0-PHP SDKs are also available from its repository.

Support Policy

  • Our PHP version support window mirrors the PHP release support schedule. Our support for PHP versions ends when they stop receiving security fixes.
  • As Automattic's stated policy is "security patches are backported when possible, but this is not guaranteed," we only support the latest release marked as "actively supported" by Automattic.
Plugin Version WordPress Version PHP Version Support Ends
5 6 8.3 Nov 2026
8.2 Dec 2025
8.1 Nov 2024

Composer and WordPress do not offer upgrades to incompatible versions. Therefore, we regularly deprecate support within the plugin for PHP or WordPress versions that have reached end-of-life. These deprecations are not considered breaking changes and will not result in a major version bump.

Sites running unsupported versions of PHP or WordPress will continue to function but will not receive updates until their environment is upgraded. For your security, please ensure your PHP runtime and WordPress remain up to date.

Feedback

Contributing

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

Raise an issue

To provide feedback or report a bug, please raise an issue on our issue tracker.

Vulnerability Reporting

Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.


Auth0 Logo

Auth0 is an easy-to-implement, adaptable authentication and authorization platform.
To learn more checkout Why Auth0?

This project is licensed under the MIT license. See the LICENSE file for more info.

wordpress's People

Contributors

albeja avatar cocojoe avatar cristiandouce avatar damieng avatar drobin03 avatar evansims avatar fossabot avatar glena avatar horike37 avatar hrajchert avatar idpaterson avatar joshcanhelp avatar lbalmaceda avatar mgonto avatar mostekcm avatar navesd avatar niugait avatar ntotten avatar pieterbeulque avatar pnu avatar qwp6t avatar rickyrauch avatar roborourke avatar rolodato avatar rudyaffandi avatar szepeviktor avatar thameera avatar waded avatar widcket avatar woloski 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  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  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

wordpress's Issues

add_menu_page/admin_menu conflicts with other plugins.

I was having issues where the menu page would not be linked inside of the admin navigation. In particular I found this issue was happening when ACF Pro was activated http://www.advancedcustomfields.com/ I tried to track down where the conflict was happening and found that if I prevented ACF from generating it's menu page the auth0 menu page link appeared.

Considering that ACF is one of the most popular plugins for wordpress I thought it would reasonable that both plugins should work together.

When comparing the method that each plugin creates it's admin page, I found that both plugins were in fact using the correct action "admin-menu" to hook into, but ACF has set it's priority and accepted arguments whereas wp-auth0 used the defaults.

Here is ACF's action

add_action('admin_menu', array($this,'admin_menu'), 99, 0);

And now wp-auth0's

add_action( 'admin_menu', array(__CLASS__, 'init_menu') );

If I add a priority to wp-auth0 of 99+ the conflict resolves itself. Or if I remove the priority argument from ACF the conflict resolves itself. I am not positive what is best practice here, to use the defaults or set a custom priority. I will post a duplicate issue one the ACF plugin github, so that hopefully these types of conflicts can be avoided.

Support for SSO

If SSO is enabled, it should redirect to /authorize (only if there is SSO cookie).
On logout should single logout

Wordpress tries to auto login even when "Auto Login (no widget)" is unchecked

Given the "Single Sign On (SSO)" is checked in the Auth0 settings and "Auto Login (no widget)" is unchecked.

To reproduce this issue:

  1. Login via wordpress auth0 widget.
  2. Logout (it only logs out of Wordpress not Auth0).
  3. Go to http://[domain.com]/wp-login.php

The application now results in error:
Type: Failed Login
Description: http://[domain.com]/wp-login.php is not in the list of authorized callback URLs: http://[domain.com]/index.php?auth0=1. Please go to 'https://manage.auth0.com/#/applications/raFDFlsRPwMTbHT6Jyg7ZARG4QJVvkz6/settings' and make sure you are sending the same callback url from your application.
Connection: Username-Password-Authentication

Make the widget showable as Shortcode and Widget

The Login Widget is now shown only in the login page. Some pages/themes have always wanted to show the Login Widget as a WP Widget anywhere in the page (Right sidebar for example) or as a Shortcode.

Hardwired redirect url after login

In the file https://github.com/auth0/wp-auth0/blob/master/templates/auth0-login-form.php#L122 there is hardwired place of wordpress index.php.
Our issue is, that we have wordpress in the subdirectory of the webserver, to be precise on /articles/ , so we need the path /articles/index.php there. Maybe the best solution will be to prefix index.php by wordpress site url <?php echo get_site_url(); ?>.

The related support issue on wordpress.org is https://wordpress.org/support/topic/hardwired-redirect-url-after-login

Mixed content warning

Currently it seems like Auth0 calculates the WPA0_PLUGIN_URL too soon in the process, so the URL of the CSS files doesn't get https:// on a secure site.

Calculating this value on demand fixes the problem, e.g.:

    wp_enqueue_style( 'auth0-widget', trailingslashit(plugin_dir_url(__FILE__) ) . 'assets/css/main.css' );

Validate settings before saving

Entering invalid settings such as a mistyped client ID, secret or tenant can cripple a Wordpress installation, since it breaks the login. These settings should be validated before saving to ensure the login configuration is always in a valid state.

Support Storing Stripe id in Auth0

Ideally the stripe id for the customer would be storable / loadable by Auth0 plugin such that WooCommerce + one of the Stripe plugins could use the token for loading saved payment information.

Per the Stripe docs:

Once you've created a customer, you should store its id in your own database so you can refer to it later when communicating with stripe.

and more here

Stripe plugins for WooCommerce:

There are even more for WordPress in general.

Prompt users for email when logging in with IdP that doesn't provide one

WordPress requires all users to have both username and email, as can be seen here:

screen shot 2014-10-10 at 10 43 21 am

When logging in with an identity provider that does not provide an email such as Instagram or Twitter, user creation fails with Error: could not create user.

A solution for this would be to prompt users for an email when signing up if the identity provider hasn't provided one.

Enhancement: Allow WordPress plugin to work in enterprise environment without internet access

A prospective customer with an internal wordpress site with no internet access asked what deployment options of Auth0 they could use. Would be nice if the wordpress plugin allowed them to use cloud-based Auth0 by not requiring internet access from the plugin to Auth0, e.g. by routing all traffic through redirects through user browser. (It sounds like today, the direct connection from plugin to Auth0 is required to get a token after authentication, so perhaps this could be done by implementing an option to use token flow instead of code flow).

Error message when logging out from admin panel

Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /data/web/virtuals/1111/virtual/www/wp-content/plugins/auth0/WP_Auth0.php on line 340

Warning: Cannot modify header information - headers already sent by (output started at /data/web/virtuals/1111/virtual/www/wp-content/plugins/auth0/WP_Auth0.php:340) in /data/web/virtuals/1111/virtual/www/wp-includes/pluggable.php on line 1173.

Session_start warnings

( ! ) Warning: session_start(): The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in /home/thanh/dev/site/local_dev_wp/wp-content/plugins/auth0/WP_Auth0.php on line 569

( ! ) Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/thanh/dev/site/local_dev_wp/wp-content/plugins/auth0/WP_Auth0.php:569) in /home/thanh/dev/site/local_dev_wp/wp-content/plugins/auth0/WP_Auth0.php on line 569

State shouldn't be required

$state = $wp_query->query_vars['state'];
...
if ($stateFromGet->interim) {

Lines 344 & 392

This assumes state is present, and assumes that it's a json_encoded object that always has an interim property. Due to this it throws PHP notices which if displayed prevent auth0 from redirecting.

State isn't always present, like when doing sso via /authorize.

Just use isset checks and it'll fix the problem :)

Thanks

Add fallback URL to log in with WP credentials even after disabling WP login

The "disable WordPress login" option should only be cosmetic, and a fallback URL should be provided to always be able to log in with WordPress credentials. As an example, Zendesk does this when enabling SSO by sending a fallback URL by email to prevent locking oneself out from their account.

Manually deleting stuff through FTP or SSH is not fun :)

Auth0 users with different accounts but same username will not be able to log into the site

With the recent commit, the error triggered by username collisions is no longer suppressed, but this means that users different accounts with the same username will receive an error message telling them that their username already exists.

The issue arises because Auth0 usernames are simply the first part of the email address, up to the @ symbol. But, several users can have the same username, since Auth0 only requires the full email to be unique.

Would it be possible to switch from using Auth0 usernames (which are not unique) to Auth0 email addresses (which are) for the WP username?

Logout does not work when Wordpress is locked down (private site)

When using a plugin like "Authenticator" we can lock down a Wordpress site (all content needs authentication). Now in that case the Logout does not work as expected. It will clear the Wordpress cookie but it does not logout from Auth0 or the IdP. As a result the following happens:

  1. Logout (clear WP cookie)
  2. Go to homepage. Not authenticated
  3. Go to Auth0. Auth cookie present, we have SSO
  4. Back to WP, user is authenticated.

Note: this only happens when "Auto Login (no widget)" is enabled and a connection is specified (like "google-oauth2")

Ability to Redirect to WP Site with JWT in Querystring

I have two sites: www.site.com and shop.site.com. I am using Wordpress on the shopping site (specifically WooCommerce). I currently use Auth0 to authenticate on the main site. I have added the Auth0 WP plugin on the shopping site.

I would like to require users to use the same account on both sites. Further I would like to avoid even having the user enter his email/password again on the shopping site if he is directed there from the main site. Is there a way that when I link the user from the main site to the shopping site I can do so along with the jwt which can then be used by the auth0 plugin on the WP site to login the user?

Something like shop.site.com/login?jwt=XXXXXXX?

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.