jonathan-dejong / simple-jwt-authentication

Extends the WP REST API using JSON Web Tokens Authentication as an authentication method.
GNU General Public License v3.0
87 stars 25 forks source link

Allow custom HTTP Header field for the JWT Token #13

Closed JanThiel closed 6 years ago

JanThiel commented 6 years ago

When trying to use HTTP Basic Auth together with another Auth scheme like JWT, you face two issues that are circumvented by this Pull Request. First: It is not really supported to add multiple Authorization schemes (Authorization: Basic [BASIC-Token], Bearer [JWT-Token]). And second does this plugin always fails, if the "Authorization" header contains anything else than "Bearer ...".

Allowing a custom header field for the JWT Auth will make such situations work. In our case, it is for a testing environment where Basic Auth is always present. The default should nevertheless remain the HTTP_AUTHORIZATION header.

This PR allows you to control the header field name to look for the JWT token by an entry within wp-config.php.

Best Regards, Jan