Reputation: 473
So currently have a live environment that spans across two application servers and a separate database server as well. 3 servers total. Both app servers write and read from the DB server.
Now the problem I am seeing with Laravel Passport is when i create a Personal Access Token. It seems to only authenticate on the original issuing server (that or the first one it hits on the first submit) ... I have a round robin setup right now - so basically every other request is saying i am unauthenticated...
If my two app servers (identical) are reading from the same DB server... then what is the issue? Is laravel passport storing something in a file? not 100% sure on the ins and outs of Passport...
Will also note my sessions are stored in Redis on the DB server both app servers are pointing to that.
Edit:
Too add to this - When i switch domains it seems to send back unAuthenticated? ... assuming in the token it has something to do with the issuing domain? Not 100% sure ... but if anyone has any insight let me know!
Thanks Citti
Upvotes: 1
Views: 1923
Reputation: 1
Everyone still struggling from this, I came across this issue and after doing a quick search stumbled upon this pull request https://github.com/laravel/passport/pull/683, you can add the following keys to your .env file then instead of reading from the actual file your application will use these keys from your .env file.
PASSPORT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIJJ...\n-----END RSA PRIVATE KEY-----"
PASSPORT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nMIICI...\n-----END PUBLIC KEY-----\n"
Make sure to use double quotes "" to enclose your key otherwise you are going to see parsing errors, that way you can copy your server keys from the first server to .env file and then use the same ones for the any new servers you add, works perfectly.
Upvotes: 0
Reputation: 33
Laravel Passport generates the access token from a file that resides in storage/oauth-private.key
and storage/oauth-public.key
These files are on the server. If you have executed the passport:install
command, then on other servers it will not be possible to validate the user access token
Hope this helps
Upvotes: 2