Repository navigation
feat: share a budget's hours with its customer through a secret link - #100
Open
claude-for-timatic[bot] wants to merge 10 commits into
Open
claude-for-timatic[bot] wants to merge 10 commits into
claude-for-timatic[bot] wants to merge 10 commits into
Conversation
Only the sha256 hash of the token is stored; the plain token and the frontend url are returned once. Budgets hidden from the customer cannot be shared.
The frontend sends the token in the X-Share-Token header. The new share_token guard resolves it to a SharedBudgetViewer, which may only GET its own budget (with customer and budgetType), its periods and its time spent totals, at 60 requests a minute. Prices, contract and change ids and the customer's hourly rate and external id are left out.
Showing the budget again does not revive the old link; a new one has to be created.
tomasvanrijsse
force-pushed
the
feat/50-budget-share-link
branch
from
November 8, 2026 08:19
5cbafee to
b01c616
Compare
tomasvanrijsse
self-requested a review
November 9, 2026 07:28
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.
A budget can be shared with its customer through a revocable secret link. The public page lives entirely in the frontend (Timatic/timatic-frontend#14). The backend only makes the secret usable: the share token is a read-only credential for one budget on the existing endpoints, with prices stripped. This PR has no public endpoint of its own.
Closes #50
Contract
Managing the link (needs
budgets.update):POST budgets/{budget}/share-linkreturns 201 with typebudget-share-linksand attributestokenandurl. The url is{frontend_url}/shared-budgets/{budgetId}#{token}. Each call replaces the previous link, and the token is shown only here.DELETE budgets/{budget}/share-linkreturns 204 and revokes the link.Budgetresource gainsisShared. Creating a link for a budget withshowToCustomer=falseanswers 422.Using the link: the SPA sends the header
X-Share-Token: <token>. It works for GET only, for that one budget:budgets/{id}, withincludelimited tocustomerand/orbudgetTypebudgets/{id}/periodsbudget-time-spent-totals?filter[budgetId]={id}&periodUnit=…These fields are absent when the share token is used:
totalPrice,contractId,changeIdtotalPricehourlyRate,externalIdResponses:
Retry-After.Decisions
share_tokenguard (Auth::viaRequest) returns aSharedBudgetViewerprincipal that can onlybudgets.read. TheRestrictShareTokenToSharedBudgetmiddleware is the real gate:SubstituteBindings, so a budget that doesn't exist gets 403 instead of 404 and doesn't reveal which ids exist.auth:api,share_token.Str::random(48), stored as a sha256 hash. Creating a new link invalidates the old one.show_to_customer=false) revokes its link for good. Showing it again does not bring the old link back. Archived budgets stay readable.config/auth.phpgets ashared_budget_viewersprovider. It exists only so Larastan knowsAuth::user()can be a viewer, and nothing queries it.Review
The first design (a public
shared-budgets/{token}endpoint with its own resources) was replaced after your review. A security review agent then attacked the token. Nothing reached beyond the allowlist: includes, sparse fieldsets, filter arrays, HEAD, other route groups, guard order and policies all hold. Fixed after that review:Retry-Afteron 429Docs to update after #96 (budgets)
Share link:
X-Share-Tokenand limited to 60 requests a minute.Tests:
tests/Feature/Budgets/ShareLinkTest.php.GLOSSARY.md: add Share link.Verification
Full Pest suite green, PHPStan 0 errors, Pint applied.