feat(rest-api-application): migrate auth_key context to contract-first architecture - #1950
Merged
josecelano merged 4 commits intoJun 26, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements SI-3 of the contract-first REST API migration by moving the auth_key context to the protocol → application → runtime-adapter → axum transport layering, and rewiring the Axum handlers to dispatch via a new application use-case service instead of calling tracker-core directly.
Changes:
- Added
auth_keyprotocol DTOs (resources + input forms) underrest-api-protocol, and moved usage away from Axum-local DTO modules. - Introduced
AuthKeyPort(application boundary) andAuthKeyApiService(use-case) inrest-api-application, plusTrackerAuthKeyAdapterinrest-api-runtime-adapter. - Updated
axum-rest-api-serverrouting/handlers/tests to use protocol DTOs and the new application service, removing the oldauth_keylocal DTO module.
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/rest-api-runtime-adapter/src/adapters/mod.rs | Exposes the new auth_key adapter module. |
| packages/rest-api-runtime-adapter/src/adapters/auth_key.rs | Implements AuthKeyPort by wrapping KeysHandler and mapping tracker-core outputs to protocol DTOs. |
| packages/rest-api-protocol/src/v1/context/mod.rs | Registers the new auth_key context and documents forms vs resources. |
| packages/rest-api-protocol/src/v1/context/auth_key/mod.rs | Adds the protocol context module for /api/v1/keys. |
| packages/rest-api-protocol/src/v1/context/auth_key/resources/mod.rs | Exposes AuthKey protocol resource module. |
| packages/rest-api-protocol/src/v1/context/auth_key/resources/auth_key.rs | Introduces AuthKey DTO + AuthKeyError protocol error type. |
| packages/rest-api-protocol/src/v1/context/auth_key/forms/mod.rs | Exposes AddKeyForm input DTO module. |
| packages/rest-api-protocol/src/v1/context/auth_key/forms/add_key_form.rs | Moves AddKeyForm into the protocol layer (requires serde_with). |
| packages/rest-api-protocol/Cargo.toml | Adds serde_with dependency to support the moved form DTO. |
| packages/rest-api-application/src/use_cases/mod.rs | Registers the new auth-key use-case service module. |
| packages/rest-api-application/src/use_cases/auth_key.rs | Adds AuthKeyApiService orchestrating calls to the AuthKeyPort. |
| packages/rest-api-application/src/ports/mod.rs | Registers the new auth-key port module. |
| packages/rest-api-application/src/ports/auth_key.rs | Defines AuthKeyPort trait (application boundary). |
| packages/axum-rest-api-server/tests/server/v1/asserts.rs | Switches AuthKey assertions to use protocol DTO type. |
| packages/axum-rest-api-server/src/v1/routes.rs | Wires TrackerAuthKeyAdapter + AuthKeyApiService into v1 routing. |
| packages/axum-rest-api-server/src/v1/context/auth_key/routes.rs | Changes handler state from KeysHandler to AuthKeyApiService. |
| packages/axum-rest-api-server/src/v1/context/auth_key/handlers.rs | Rewrites handlers to call AuthKeyApiService and map protocol-level errors. |
| packages/axum-rest-api-server/src/v1/context/auth_key/responses.rs | Switches response payload type to protocol AuthKey and adjusts invalid-key response signature. |
| packages/axum-rest-api-server/src/v1/context/auth_key/resources.rs | Removes Axum-local AuthKey DTO module (migrated to protocol). |
| packages/axum-rest-api-server/src/v1/context/auth_key/mod.rs | Removes forms/resources module exports (now provided by protocol). |
| packages/axum-rest-api-server/Cargo.toml | Drops serde_with dependency (moved to protocol crate). |
| docs/issues/open/1941-1938-si-3-migrate-auth-key-context.md | Updates the SI-3 issue spec/progress to match the implemented architecture. |
| Cargo.lock | Moves serde_with dependency from axum-rest-api-server to rest-api-protocol. |
Comments suppressed due to low confidence (1)
packages/axum-rest-api-server/src/v1/context/auth_key/responses.rs:60
invalid_auth_key_duration_responseis triggered fromPOST /keyswhen the providedseconds_validoverflows the clock computation, but the message currently starts with "Invalid URL". This isn't a URL issue; it should describe invalid request input.
#[must_use]
pub fn invalid_auth_key_duration_response(duration: u64) -> Response {
bad_request_response(&format!("Invalid URL: invalid auth key duration: \"{duration}\""))
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…t architecture - Add AuthKey and AuthKeyError to rest-api-protocol (resources/) - Add AddKeyForm to rest-api-protocol (forms/) — protocol now covers both input (forms) and output (resources) DTOs - Define AuthKeyPort trait in rest-api-application - Implement AuthKeyApiService use-case and TrackerAuthKeyAdapter - Rewire Axum handlers to dispatch through AuthKeyApiService - Add serde_with dependency to rest-api-protocol for AddKeyForm - Update issue spec progress
…_handler Use failed_to_add_key_response for the Database error branch in the add handler instead of failed_to_generate_key_response.
- Add absolute rule: if GPG passphrase prompt times out, the agent must stop and notify the user — never bypass signing with --no-gpg-sign - Update Committer agent instructions with the same rule - Update commit-changes skill with detailed GPG timeout procedure
josecelano
force-pushed
the
1941-migrate-auth-key-context
branch
from
June 26, 2026 15:57
6b0628e to
f7cbdb2
Compare
Member
Author
|
ACK f7cbdb2 |
7 tasks
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.
Description
Implements SI-3: Migrate
auth_keycontext to contract-first architecture (sub-issue of #1938).Changes
rest-api-protocol: Addedv1::context::auth_key/with:resources/auth_key.rs—AuthKeyDTO +AuthKeyErrorenum (3 variants matchingPeerKeyError)forms/add_key_form.rs—AddKeyForminput DTO (protocol now covers both input and output types)rest-api-application: DefinedAuthKeyPorttrait andAuthKeyApiServiceuse-caserest-api-runtime-adapter: ImplementedTrackerAuthKeyAdapterwrappingKeysHandler+ conversion functionaxum-rest-api-server: Rewired handlers to dispatch throughAuthKeyApiService, removed local DTOs (resources.rs,forms.rs)Architecture flow
Verification
AuthKeyPorttrait defined inrest-api-applicationAuthKeyApiServiceuse-case implementedTrackerAuthKeyAdapterimplemented