fix: bootstrap Passport personal access client#206
Open
drbelt27 wants to merge 1 commit into
Open
Conversation
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
This change bootstraps the Laravel Passport Personal Access Client required for API key creation in production Docker deployments.
It adds a focused Artisan command,
trypost:bootstrap-passport, and invokes it from the production entrypoint after database migrations and Passport key initialization.Problem
A fresh production deployment can have:
while still having no Personal Access Client in
oauth_clients.When a user creates an API key from the workspace settings, TryPost calls
User::createToken(...). Laravel Passport then fails with HTTP 500:Reproduction
PassportSeeder.Root cause
TryPost already contains
Database\Seeders\PassportSeeder, and the mainDatabaseSeederincludes it.However, the production Docker entrypoint runs migrations and prepares Passport keys without running the focused Passport seeder.
As a result, the application can start successfully while
User::createToken(...)remains unusable because no active Personal Access Client exists.Solution
This pull request:
trypost:bootstrap-passportArtisan command;Database\Seeders\PassportSeeder;DatabaseSeeder;|| true;Idempotency and concurrency
The bootstrap is designed to be safe across repeated and concurrent production starts.
It:
reuses an existing active Personal Access Client;
supports valid clients with either a
nullprovider or theusersprovider;does not create duplicates during repeated starts;
does not revoke or replace valid clients;
does not invalidate existing access tokens;
creates a new valid client when only revoked clients exist;
serializes concurrent bootstrap attempts using:
GET_LOCK.Locks are released after execution, including failure paths.
Testing
Full test suite
The full suite was executed against a dedicated local PostgreSQL test database. No production database or production credentials were used.
Focused bootstrap tests
Related API key tests
Additional checks
git diff --check: passed;bash -n docker/entrypoint.sh: passed;The local test environment used a dedicated PostgreSQL database named
trypost_testand isolated Passport test keys. No production environment was involved.Backward compatibility
Existing installations with a valid Personal Access Client remain unchanged.
This change does not:
Scope
This pull request only addresses Passport Personal Access Client bootstrap during production Docker startup.
It does not include:
Risk
The risk is low and limited to production startup.
The entrypoint now fails explicitly when Passport bootstrap cannot complete. This is preferable to allowing the application to start successfully while API key creation remains broken with an HTTP 500 error.
Rollback
Rollback consists of reverting this commit.
Any Personal Access Client already created remains valid, and existing clients and tokens are not modified by the rollback.
Reviewer notes
The main review points are:
trypost:bootstrap-passportArtisan command;