InactiveProjects / limoncello-collins

Quick start JSON API application (Laravel based)
http://jsonapi.org
71 stars 10 forks source link

Authentication does not work, when executed via Apache #18

Closed pixelig closed 8 years ago

pixelig commented 8 years ago

Hey,

i'm super new to Laravel/Lumen so this might not be an issue at all. Anyhow here is what i did:

I followed the install instructions and started the server via php artisan serve --port=8888 everythings works fine. When i use the ember demo app Limoncello Ember, i can login, access and manipulate all models.

Then i copied the whole limoncello-collins dir to /var/www/sample-api and added an apache VirtualHost:

<VirtualHost *:80>
        ServerName api.sample.localhost
        DocumentRoot /var/www/sample-api/public
</VirtualHost>

<Directory "/var/www/sample-api/public">
        Order allow,deny
        Allow from all
        Require all granted
        AllowOverride all
</Directory>

Now when i change the API host within Limoncello Ember to api.sample.localhost i can still login, but every access to a resource (post, sites, etc.) is blocked: The page reloads and i have to login again.

When i try to access the API via curl i get the same phenomenon: I can receive a valid token with the login credentials, but any access to the API is blocked with 401 - Unauthorized.

Do you have any idea what's going wrong? Thanks in advance, both Limoncello Collins and Limoncello Shot look very promising and i'd love to use them in production.

neomerx commented 8 years ago

That's some kind of misconfiguration issue. What's in your laravel logs?

pixelig commented 8 years ago

There was nothing in the logs, but i found the problem: https://github.com/tymondesigns/jwt-auth/wiki/Authentication

so adding

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

to public\.htaccess solved the issue.

Now everything works as expected, thanks for your awesome work!