I am very new to slim framework so below is the exact steps I did in the /varr/www/html for apace on centos 7 with php7.
-
composer create-project slim/slim-skeleton
-
rename is to apiv1
-
chown -R apache:apache apiv1
-
Going back to main directory I installed all these.
composer require firebase/php-jwt
composer require tuupola/base62
composer require tuupola/slim-basic-auth
composer require tuupola/slim-jwt-auth
composer require tuupola/cors-middleware -
Then in my public folder in my .htacess I have this.
RewriteEngine OnRewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.)::\2$
RewriteRule ^(.) - [E=BASE:%1]RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L] -
I am following the link here https://trinitytuts.com/secure-your-php-web-services-using-jwt/
I notice when in the middleware I enable this section.
$app->add(new \Tuupola\Middleware\Cors([
"logger" => $container["logger"],
"origin" => ["*"],
"methods" => ["GET", "POST", "PUT", "PATCH", "DELETE"],
"headers.allow" => ["Authorization", "If-Match", "If-Unmodified-Since"],
"headers.expose" => ["Authorization", "Etag"],
"credentials" => true,
"cache" => 60,
"error" => function ($request, $response, $arguments) {
return new UnauthorizedResponse($arguments["message"], 401);
}
]));
Everything fails to work and I get page isnt working and nothing in log files. I even tried e.g. credentials to be false. For time being this the settings in JwtAuthentication.php I set this to false.
private $options = [
“secure” => false,
What else can I do to enable it working fine ?