Skip to content

Commit

Permalink
feat: use WP-Auth0 domain option
Browse files Browse the repository at this point in the history
  • Loading branch information
joshcanhelp committed Oct 11, 2023
1 parent 6118153 commit 8be4645
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ First, install the [Login by Auth0 plugin](https://wordpress.org/plugins/auth0/)

```php
// Auth0 credentials
define( 'AUTH0_DOMAIN', 'Your Auth0 domain' );
define( 'AUTH0_API_AUDIENCE', 'API identifier for the WP REST API' );
define( 'AUTH0_API_SIGNING_SECRET', 'API signing secret from Auth0' );
define( 'AUTH0_API_DEBUG', 'Set to `true` to add debugging log entries' );
Expand Down Expand Up @@ -42,7 +41,7 @@ You can get this running to test it out locally with Docker using [this Gist](ht

## Troubleshooting

Try setting `AUTH0_API_DEBUG` to `true` and watching your PHP error log for information on failures.
Try setting `AUTH0_API_DEBUG` to `true` and watching your WP error log for information on failures.

If API requests aren't working, Apache might not be passing authorization headers to PHP. Try adding this line (or similar methods) to `.htaccess`:

Expand Down
4 changes: 3 additions & 1 deletion src/wp-rest-api-auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function determine_current_user( $user ) {
// Verify the incoming JWT access token.
// Auth0-generated access tokens for users will be ID token shaped.
$token_verifier = new \WP_Auth0_IdTokenVerifier(
'https://' . \AUTH0_DOMAIN . '/',
'https://' . \WP_Auth0_Options::Instance()->get('domain') . '/',
\AUTH0_API_AUDIENCE,
new \WP_Auth0_SymmetricVerifier( \AUTH0_API_SIGNING_SECRET )
);
Expand All @@ -78,6 +78,8 @@ function determine_current_user( $user ) {
return null;
}



// We don't have a user to associate this call to.
if ( ! $decoded_token['sub'] ) {
if ( $debug_mode ) {
Expand Down

0 comments on commit 8be4645

Please sign in to comment.