Prefix changes are safe + engine views survive custom mount names - #13
Conversation
…e custom mount names Two fixes proven in production on vehiclesdb.com: 1. The initializer template warned "Once set, do NOT change [token_prefix] or existing keys will fail authentication!" — false on both strategies. sha256 looks up by pure token digest (prefix never consulted); bcrypt scopes by each key's OWN stored prefix via the known-prefixes scan (which the suite already exercised). Observed live: keys minted under ak_ kept authenticating after the app rebranded to vdb_. The warning becomes an accurate explanation, and two regression tests pin the guarantee per strategy. 2. Engine views called the host-side routes proxy by its default name (api_keys.keys_path), so mounting with a custom `as:` exploded with "undefined local variable 'api_keys'". Engine views now use their own engine-relative helpers, which resolve under any mount name. A source lint test keeps the proxy out of views; the dummy app gains a second, custom-named mount for manual verification. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ReviewBoth fixes are well-motivated and the sha256/bcrypt regression tests for Bug: the custom-mount fix is incomplete — the shared layout still calls the host-side proxy
<%= link_to "My API Keys", api_keys.keys_path, class: "active" %>This is the layout rendered for every engine page (no controller sets The reason it slipped through: Minor / non-blocking
Overall: solid, well-tested fix for issue #1 (the |
Two fixes, both hit for real while wiring api_keys into vehiclesdb.com:
1. The
token_prefixwarning was falseThe initializer template said changing the prefix makes existing keys "fail authentication". It doesn't, on either strategy:
prefixcolumn, with the known-prefixes fallback scan (already covered byauthenticates with bcrypt when configured prefix mismatch triggers known prefixes scan).Observed live: after switching an app from
ak_to a brandedvdb_prefix, previously-mintedak_keys kept authenticating in production. The warning is now an accurate explanation of the actual behavior (including the one real cost: the slower known-prefixes path under bcrypt), and two new regression tests pin the guarantee per strategy — so users can brand their prefixes without fear of stranding integrations.2. Custom mount names broke every engine view
Six view call sites used the host-side routes proxy by its default name. Engine views now use bare engine-relative helpers (
keys_path), which resolve against the engine's own routes under any mount name. A source-lint test keeps proxy calls out of the views (the suite deliberately runs without booting the dummy app, so a rendered test isn't possible in-harness); the dummy app gains a second custom-named mount for manual verification.Full suite: 219 runs, 0 failures.
🤖 Generated with Claude Code