You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chore(api): replace any with concrete request types in AuthServiceInterface #169
Each implementation opens with a type assertion and returns fmt.Errorf("invalid request type") on mismatch, so a caller passing the wrong concrete type fails at runtime rather than at compile time.
The any signature is pre-existing design; LeanerCloud/cloud-commitments-cli#1737 only added a parameter to it. Converting to concrete types means touching every implementation and every call site of AuthServiceInterface — the real service, the authServiceAdapter in internal/server/app.go, MockAuthService, the mockAuthForExchange stub, and the handler call sites — inside a PR whose purpose was closing a p1 privilege-escalation issue (LeanerCloud/cloud-commitments-cli#1550). Mixing an interface refactor into a security review makes both harder to review, and the security fix is the time-critical half.
The original reason for any is recorded in internal/auth/service_api.go: "They use any to avoid import cycles with the api package." Any fix has to address that constraint — most likely by moving the request types into a shared package, or by defining the API-side types and converting at the adapter rather than inside the service.
Scope
internal/api/types.go — the interface
internal/auth/service_api.go — the four implementations plus their type assertions
internal/server/app.go — authServiceAdapter
internal/api/mocks_test.go, internal/api/handler_ri_exchange_test.go — test doubles
handler call sites in internal/api/handler_groups.go, handler_users.go
Worth doing as a standalone refactor with no behaviour change, so the diff is reviewable as exactly that.
Activity
IAmJSD commentedon Oct 23, 2026
Claiming: working on this
chore(api): type AuthServiceInterface user and group writes with the …