Wednesday 16 June 2021

PHP-JWT


Note that, by default, Apache will not pass the HTTP_AUTHORIZATION header to PHP. The reason behind this is:

The basic authorization header is only secure if your connection is done over HTTPS, since otherwise the credentials are sent in encoded plain text (not encrypted) over the network which is a huge security issue.

I fully appreciate the logic of this decision. However, to avoid a lot of confusion, add the following to your Apache configuration. Then the code will function as expected. If you’re using NGINX, the code should function as expected:

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


https://www.sitepoint.com/php-authorization-jwt-json-web-tokens/ 

No comments:

Post a Comment