usefulteam / jwt-auth

WordPress JSON Web Token Authentication
https://wordpress.org/plugins/jwt-auth/
124 stars 50 forks source link

Regex check for jwt_auth_whitelist #16

Closed dominic-ks closed 3 years ago

dominic-ks commented 4 years ago

I came across some issues adding some patterns to the jwt_auth_whitelist to whitelist them from auth and when I looked at the plugin code I found a TODO for this very point in JWTAuth::is_whitelisted()

I'm trying to whitelist something with the following pattern:

If I add a check that looks something like this I get what I need:

$regex = '/' . str_replace( '/' , '\/' , $endpoint ) . '/'; if( preg_match( $regex , $request_uri )) { return true; }

I need to use this because I only want to whitelist this route if it has /action on the end of it.

What do you think about adding this in there?

contactjavas commented 3 years ago

Thanks @dominic-ks ! It's on master now. I expect to publish minor update to the plugin this week