Skip to content

PAT-1895 Build Storage client from resolved StorageApiToken#531

Merged
pepamartinec merged 9 commits into
mainfrom
pepa/PAT-1895_storageFactory
Jun 24, 2026
Merged

PAT-1895 Build Storage client from resolved StorageApiToken#531
pepamartinec merged 9 commits into
mainfrom
pepa/PAT-1895_storageFactory

Conversation

@pepamartinec

@pepamartinec pepamartinec commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Release Notes

https://linear.app/keboola/issue/PAT-1895/storage-api-php-client-branch-wrapper-do-not-use-storage-token-from

Note

Implementace StorageClientApiFactory + controller argument resolver.

  • factory se bude pouzivat misto existujici StorageClientRequestFactory, ktera nefunguje s PAT tokenama
  • resolver usnadnuje pouziti pro nejcastejsi use-case - chci Storage API clienta pro aktualni Storage token

Adds Keboola\ApiBundle\StorageApiClient\StorageClientApiFactory, a Storage API client factory that builds a ClientWrapper from an already-resolved StorageApiToken object instead of re-reading the token from the request headers. The branch-wrapper's StorageClientRequestFactory derives the token straight from Authorization: Bearer / X-StorageApi-Token, which breaks for Connection programmatic tokens (kbc_pat_* / kbc_at_*): the header carries the programmatic token, while the real legacy Storage token only exists on the StorageApiToken that api-bundle's authenticator resolved via the Manage API exchange. api-bundle is the right home for this factory — it already resolves the StorageApiToken and already depends on keboola/storage-api-php-client-branch-wrapper.

The factory takes the token value from StorageApiToken::getTokenValue(), pins authType to AuthType::STORAGE_TOKEN (the resolved value is always a legacy Storage token), and resolves the run id from X-KBC-RunId with the usual generator/uniqid fallback. It is intentionally independent of StorageClientRequestFactory — it owns its own ClientOptions and neither factory references the other. This PR ships only the class and its unit tests; DI auto-registration in KeboolaApiExtension and the consumer-facing usage docs are a deliberate follow-up step, so nothing in the container consumes the factory yet.

Plans for customer communication

None.

Impact analysis

No end-user impact. The factory is not registered in the container yet (no DI wiring), so no code path consumes it; this PR only adds a new class and its tests.

Change type

New feature

Justification

Multi-project / PAT support: downstream services must build Storage clients from the resolved StorageApiToken, not from request headers that carry a programmatic token.

Deployment

Merge & automatic deploy.

Rollback plan

Revert of this PR.

Post release support plan

None.

@linear

linear Bot commented Jun 23, 2026

Copy link
Copy Markdown

PAT-1895

@pepamartinec pepamartinec force-pushed the pepa/PAT-1895_storageFactory branch from 1a900c7 to 7e87b73 Compare June 24, 2026 06:03
@pepamartinec pepamartinec force-pushed the pepa/PAT-1895_storageFactory branch from d6d179a to df6d1e7 Compare June 24, 2026 09:23
@pepamartinec pepamartinec requested a review from romantmb June 24, 2026 11:14
use Keboola\StorageApiBranch\StorageApiToken;
use Symfony\Component\HttpFoundation\Request;

class StorageClientApiFactory

@pepamartinec pepamartinec Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is hard. Nasleduju pattern existujicich factory (StorageClientRequestFactory, StorageClientPlainFactory)

@pepamartinec pepamartinec requested a review from odinuv June 24, 2026 11:23

@romantmb romantmb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pepamartinec pepamartinec merged commit e6bf9b7 into main Jun 24, 2026
26 checks passed
@pepamartinec pepamartinec deleted the pepa/PAT-1895_storageFactory branch June 24, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants