Skip to content

Commit ac792de

Browse files
alyxbalyxb
and
alyxb
authored
Fixes for use as WP plugin (#7)
Co-authored-by: alyxb <alyxrb@gmail.com>
1 parent 4e61a41 commit ac792de

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,24 @@ Require the autoloader at some point when `add_action` is available, like in `wp
3131

3232
### Install manually
3333

34-
To install this manually without Compsoer, just download the [latest release ZIP](https://github.com/joshcanhelp/wp-rest-api-auth0/releases) and upload through the admin interface. Please note that this plugin will not update automatically; updates will need to be made by deleting and re-adding (make sure your site is in maintenance mode) or directly via an FTP client (not recommended).
34+
To install this manually without Composer, just download the [latest release ZIP](https://github.com/joshcanhelp/wp-rest-api-auth0/releases) and upload through the admin interface. Please note that this plugin will not update automatically; updates will need to be made by deleting and re-adding (make sure your site is in maintenance mode) or directly via an FTP client (not recommended).
3535

3636
## Testing with Docker
3737

3838
You can get this running to test using Docker [using this Gist](https://gist.github.com/joshcanhelp/0e35b657ca03142e3d79595c28bb3ed7).
39+
40+
### Troubleshooting
41+
42+
If API requsts aren't working, Apache might not be passing authorization headers to PHP. Try adding this line (or similar methods) to `.htaccess`:
43+
44+
```
45+
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
46+
```
47+
48+
Also, make sure your WP API endpoint doesn't follow this pattern, where `/index.php/` is required before `/wp-json/`:
49+
50+
```
51+
Example:
52+
https://<your.site>/index.php/wp-json/
53+
```
54+
See [this solution](http://dejanjanosevic.info/remove-index-php-permalink-in-wordpress/) to help resolve this index.php issue.

src/wp-rest-api-auth0.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
namespace JoshCanHelp\WordPress\RestApiAuth0;
1111

12-
use Auth0\SDK\Helpers\Tokens\SymmetricVerifier;
13-
use Auth0\SDK\Helpers\Tokens\TokenVerifier;
14-
1512
add_filter( 'determine_current_user', __NAMESPACE__ . '\\determine_current_user', 10, 1 );
1613

1714
/**
@@ -49,10 +46,10 @@ function determine_current_user( $user ) {
4946
// If we cannot validate the token for some reason, the request is processed without auth.
5047

5148
// Verify the incoming access token.
52-
$token_verifier = new TokenVerifier(
49+
$token_verifier = new \WP_Auth0_IdTokenVerifier(
5350
'https://' . AUTH0_DOMAIN . '/',
5451
AUTH0_API_AUDIENCE,
55-
new SymmetricVerifier( AUTH0_API_SIGNING_SECRET )
52+
new \WP_Auth0_SymmetricVerifier( AUTH0_API_SIGNING_SECRET )
5653
);
5754

5855
try {

0 commit comments

Comments
 (0)