Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

michaelnguyen547's avatar

overwrite passport keys creation location?

by default, php artisan passport:keys will generate keys at /storage directory. Is there a way to ask php artisan passport:keys to generate keys in different directory?

0 likes
3 replies
D9705996's avatar
D9705996
Best Answer
Level 51

Why do you want to do this?

I had a look at the source code and the Passport class has a public keyPath property that is used to determine where to store the keys. However I dont see how you would go setting the path

There is a way to load thd keys from another location so might need to manually move the keys

Passport::loadKeysFrom('/var/http/path/to/files');

These tests might help

https://github.com/laravel/passport/blob/6cae8eba19e8fa817b337bc86970f7fb59ec5787/tests/KeysCommandTest.php

To be honest I would leave as is unless you have a deal breaker reason to change

1 like
revolistic's avatar

We are using passport with Password Grant Client which generate jwt tokens to auth in our JSON API.

I have some doubt about the SSL keys for Passport the command generated with the command artisan passport:keys or artisan passport:install I am not pretty sure how to deal with it in our deployment process for staging or production..

I could stored the keys in the deployment scripts and always generate the files (./storage/oauth-private.key, ./storage/oauth-public.key) with the same keys in each deployment process or run artisan passport:keys in each deployment process which will generate a new key for each deployment.

There is any security recommendation for this?

I guess that if a new pair key are generated for each deployment, the actual logged users jwt keys will be invalidad and they will need to logging again?

1 like

Please or to participate in this conversation.