Repository navigation
Move OAuth signing keys into storage/ - #6
Merged
Merged
Conversation
Craft 5.12 writes OAuth signing keys to its storage path, and Laravel Passport reads them from storage_path(). Those match unless CRAFT_STORAGE_PATH points elsewhere, so move them in that case, and suggest replacing CRAFT_OAUTH_*_KEY settings with PASSPORT_*_KEY. Amp-Thread-ID: https://ampcode.com/threads/T-ae777030-d792-49ae-8853-87e83195c88f Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Craft 5.12 adds OAuth (MCP and authenticated GraphQL), with JWT access tokens signed by
oauth-private.key. Craft 6 validates the same tokens with Laravel Passport (craftcms/cms#20154 keeps the token tables compatible). Passport only accepts them if it finds the same signing keys.By default the two match, so nothing needs to move. When
CRAFT_STORAGE_PATHpoints somewhere else, Craft 6 ignores it forstorage_path(), so this PR adds a step:oauth-private.keyandoauth-public.keyfromCRAFT_STORAGE_PATHintostorage/with mode 0600, which Passport's permission check requires. Existing files instorage/are never overwritten.CRAFT_OAUTH_PRIVATE_KEY/CRAFT_OAUTH_PUBLIC_KEYor usesprivateKey/publicKeyinconfig/oauth.php, it suggestsPASSPORT_PRIVATE_KEY/PASSPORT_PUBLIC_KEY. Craft 6 has no OAuth config of its own, and Passport expects the key contents, not a path. The tool doesn't rewrite these variables, because PEM values can span several lines in.env.Evidence
test_it_moves_oauth_keys_into_laravel_storage: a project withCRAFT_STORAGE_PATH=craft-storageand keys there ends up withstorage/oauth-*.key(0600) and both Next Steps.storage/oauth-private.keydoesn't exist).OK (3 tests, 62 assertions), and PHPStan reports no errors.