DRAFT: feat(admin-user): Implementation e2e Admin User#3
Draft
mrdhira wants to merge 3 commits into
Draft
Conversation
…AdminRefreshToken Fill the admin-auth request/response DTOs (AdminTokenResponse per RFC 6749 Section 5.1, AdminRefreshTokenRequest, AdminForgotPassword/ChangePassword responses) and add AdminResetPasswordRequest/Response. Add ResetPassword to IAdminUserService (verify-OTP-and-set-password step the forgot flow needs). Rename the RefreshToken model/repository chain to AdminRefreshToken for symmetry with AdminPasswordReset, freeing the unprefixed namespace for a future storefront-customer refresh table. Table admin_refresh_tokens and all SQL are unchanged; the rename is Go identifiers + package only. Register IAdminPasswordResetRepository and IAdminRefreshTokenRepository in .mockery.yml and regenerate mocks for the Phase 5 service tests.
Implement all six IAdminUserService methods (Setup, Login, RefreshToken, ForgotPassword, ResetPassword, ChangePassword) over the repository, hasher, JWT issuer, and mailer via functional-options DI. Security behaviour: enumeration-safe login (dummy argon2 verify on unknown email; uniform error), RFC 9700 refresh reuse-detection revoking the whole rotation family, refresh and OTP expiry enforced in Go (never SQL), constant-time OTP compare with attempt-cap and single-use, session revocation on reset/change, and a Status re-check (IsActive) on refresh and change so a deactivated admin can't outlive its login. Forgot-password invalidates prior codes before issuing a new one to keep the single-active-code invariant. Conventions: auth config lives in config/config.go (AdminOAuthTokenConfig, AdminOTPConfig); business errors are centralized in internal/api/constant; response models are data-only (the handler owns success copy); expiry is checked with time.Now() rather than an injected clock; only the external mailer is mocked in tests (hasher/token use real impls). Add IAdminUserRepository.GetByID and AdminUser.IsActive(). Service tests at 96.7%.
Test coverage: 22.1%per package |
Runtime + configuration layer for the api, plus the build split. Config: config.Load reads env (with a stdlib .env autoloader — real env wins, 0600-perm warning, size cap, secret-safe parse errors) and fails fast on a missing/short JWT secret, malformed values, and out-of-range semantics (TTL ordering, Argon2 floors, OTP bounds, Mailgun all-or-nothing). Env-only, no yaml dependency. Generic parsers extracted to internal/shared/envx. Wiring: the 'api' command builds the full DI graph (repos -> services -> handlers -> server) and serves with graceful shutdown; Mailgun degrades to a Noop mailer when unconfigured. Binaries: split into four independent package-main binaries (logres CLI, logres-api, logres-web, logres-webadmin) so each links only its surface's deps; shared graceful-serve in internal/shared/httpx, build metadata in internal/shared/cli, mailer migrated to OptionFunc. Also scaffold the Tailwind CSS build (assets/css, package.json) for the upcoming frontends, and update security-compliance X1/X2/X9.
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.
No description provided.