Skip to content

DRAFT: feat(admin-user): Implementation e2e Admin User#3

Draft
mrdhira wants to merge 3 commits into
mainfrom
feat/admin-auth-service-layer
Draft

DRAFT: feat(admin-user): Implementation e2e Admin User#3
mrdhira wants to merge 3 commits into
mainfrom
feat/admin-auth-service-layer

Conversation

@mrdhira

@mrdhira mrdhira commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

mrdhira added 2 commits July 4, 2026 12:11
…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%.
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Test coverage: 22.1%

per package
  github.com/wigata-intech/logres          0.0%
  cmd                                      88.9%
  cmd/api                                  79.6%
  cmd/web                                  0.0%
  cmd/webAdmin                             0.0%
  config                                   83.8%
  internal/api                             0.0%
  internal/api/handler/admin               0.0%
  internal/api/handler/cart                0.0%
  internal/api/handler/order               0.0%
  internal/api/handler/product             0.0%
  internal/api/model                       0.0%
  internal/api/repository/adminPasswordReset 100.0%
  internal/api/repository/adminRefreshToken 100.0%
  internal/api/repository/adminUser        100.0%
  internal/api/repository/cart             0.0%
  internal/api/repository/category         0.0%
  internal/api/repository/file             0.0%
  internal/api/repository/order            0.0%
  internal/api/repository/product          0.0%
  internal/api/repository/tag              0.0%
  internal/api/service/adminFile           0.0%
  internal/api/service/adminOrder          0.0%
  internal/api/service/adminProduct        0.0%
  internal/api/service/adminUser           96.7%
  internal/api/service/cart                0.0%
  internal/api/service/order               0.0%
  internal/api/service/product             0.0%
  internal/shared/cli                      95.9%
  internal/shared/clock                    100.0%
  internal/shared/envx                     90.8%
  internal/shared/hasher                   84.4%
  internal/shared/httpx                    88.9%
  internal/shared/mailer                   100.0%
  internal/shared/migrationx               82.0%
  internal/shared/otp                      88.9%
  internal/shared/slugify                  100.0%
  internal/shared/sqlite                   96.7%
  internal/shared/token                    93.3%
  internal/web                             0.0%
  internal/webAdmin                        0.0%
  mock/api/repository                      0.0%
  mock/api/service                         0.0%
  mock/shared/mailer                       0.0%

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant