VOOZH about

URL: https://deepwiki.com/auth0/wordpress/2-getting-started

⇱ Getting Started | auth0/wordpress | DeepWiki


Loading...
Menu

Getting Started

This section provides a step-by-step guide for installing, configuring, and testing the Auth0 WordPress plugin for the first time. It covers the initial setup process from installation through your first successful authentication test.

For detailed architectural information about how the plugin works internally, see Architecture. For specific configuration options, see Configuration Options.


Purpose and Scope

This guide walks through:

  • Installing the plugin via Composer
  • Activating the plugin in WordPress
  • Creating and configuring an Auth0 Application
  • Configuring plugin credentials in WordPress
  • Testing the authentication flow

Each step is covered in detail in the child pages:


Prerequisites

The plugin requires:

RequirementVersionNotes
PHP8.1+See Support Policy for version lifecycle
WordPress6+Only the most recent actively-supported release
Database PermissionsTable creationRequired for custom tables
ComposerLatestFor dependency management
PSR-18 ImplementationAnyHTTP client (e.g., symfony/http-client)
PSR-17 ImplementationAnyHTTP factory (e.g., nyholm/psr7)

Sources: README.md22-29


Setup Process Overview

The following diagram illustrates the complete setup journey from initial installation through first successful login:

Diagram 1: Complete Getting Started Flow


Sources: README.md20-168


Code Entities Involved in Setup

This diagram maps the setup process to the actual code files and WordPress hooks that execute during each phase:

Diagram 2: Setup Steps to Code Entity Mapping


Sources: wpAuth0.php1-100 README.md56-168


What Happens During Plugin Activation

When you activate the plugin through the WordPress admin interface, a specific sequence of operations occurs to prepare the plugin for use:

Diagram 3: Activation Process Code Flow


The activation function performs the following operations:

  1. Secret Generation: Creates three cryptographically secure secrets using random_bytes(64) (producing 64 random bytes, converted to 128-character hexadecimal strings):

    • auth0_cookie_secret: Used for cookie encryption
    • auth0_backchannel_logout_secret: Used to validate back-channel logout webhooks
    • auth0_fallback_secret: Used for authentication fallback scenarios
  2. Idempotent Design: The function checks if secrets already exist before generating new ones. If secrets are present from a previous activation, they are not regenerated. This ensures that deactivating and reactivating the plugin does not invalidate existing sessions or configurations.

  3. Persistent Storage: All secrets are stored in the WordPress options table using add_option(), making them available across all requests.

Sources: wpAuth0.php1-50 README.md92-99


Database Table Creation

During the first request after activation (when Plugin::run() is called), the plugin creates two custom database tables if they don't already exist:

Table NamePurposeKey Columns
auth0_accountsMaps WordPress users to Auth0 identitiesuser_id, sub (Auth0 subject identifier), connection
auth0_syncQueues user synchronization events for background processingid, type, user_id, data, created_at

These tables are created using the database credentials configured for WordPress. The user must have CREATE TABLE privileges.

Why Custom Tables?: The plugin uses dedicated tables instead of WordPress options or post meta for performance reasons. Custom tables support efficient indexing and querying for user identity lookups and event queue processing, which are performance-critical operations.

Sources: README.md157-162


Cron Configuration Recommendation

The plugin schedules two WordPress cron jobs:

  • auth0_cron_sync: Processes the event queue to synchronize user data with Auth0
  • auth0_cron_maintenance: Performs cleanup operations on the auth0_accounts table

By default, WordPress's cron system runs on page load, which is inefficient for production environments. The plugin documentation recommends configuring a system cron job to trigger WordPress cron periodically:


This ensures reliable, predictable execution of background synchronization tasks.

Sources: README.md163-168


Configuration File Structure

The plugin stores configuration in WordPress options, organized into groups:

Option GroupStored InPurpose
auth0_clientWordPress options tableAuth0 credentials (Domain, Client ID, Client Secret)
auth0_authenticationWordPress options tableAuthentication settings (Enable, Auto-create users, Default role)
auth0_syncWordPress options tableSynchronization settings (Schedule, Events to sync)
auth0_accountsWordPress options tableSession pairing and advanced authentication settings

These options are managed through the WordPress admin interface at WordPress Dashboard > Auth0.

Sources: README.md147-154


Required Auth0 Application Configuration

The Auth0 application must be configured with specific settings for the plugin to function correctly:

Diagram 4: Auth0 Application Required Settings


Sources: README.md100-145


Common Setup Issues and Solutions

IssueSymptomSolution
Missing PSR implementationsComposer installation failsInstall symfony/http-client and nyholm/psr7 or compatible alternatives
Database permission errorActivation fails or admin error noticeGrant CREATE TABLE privilege to WordPress database user
"Invalid state" error during loginLogin fails after Auth0 redirectEnsure wp-login.php is not cached; verify callback URL matches exactly
Missing secrets after activationAuthentication doesn't workDeactivate and reactivate plugin to generate secrets
WordPress URL mismatchCallback fails or session issuesEnsure WordPress Address and Site Address match actual visitor-facing URLs
Cron jobs not runningUser sync doesn't occurConfigure system cron instead of relying on WP-Cron on page load

Sources: README.md120-145


Next Steps After Setup

Once the basic setup is complete and you've successfully tested a login:

  1. Configure User Synchronization: See WordPress Configuration for sync settings
  2. Review Advanced Settings: Configure session pairing, token refresh, and other advanced options
  3. Test User Creation: Verify that new Auth0 users are created correctly in WordPress
  4. Configure Role Mapping: Set default WordPress roles for auto-created users
  5. Review Security Settings: Understand the security model in Security Model

For extending functionality or custom development, use the Auth0-PHP SDK instance via wpAuth0()->getSdk() rather than extending plugin classes directly. See Extending the Plugin for details.

Sources: README.md169-185