Skip to content

fix: make registration and login reachable - #183

Draft
nirmalhk7 wants to merge 3 commits into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/agrinet-auth-reachability
Draft

nirmalhk7 wants to merge 3 commits into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/agrinet-auth-reachability

Conversation

@nirmalhk7

@nirmalhk7 nirmalhk7 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Unauthenticated registration and login currently return 403 because the server mounts credential middleware before the auth router. Mount the auth router first and add production-server HTTP regression coverage; other routes still require credentials.

The six new cases exercise registration followed by login and authenticated access, incorrect passwords, unknown email addresses, unauthenticated protected-route access, auth-router fallthrough, and invalid bearer tokens. Routes, middleware, bcrypt, and JWT handling remain real; DynamoDB persistence and unrelated background jobs use test doubles.

Dependency: stacked on #179 (c4dda0f), which repairs the auth handlers' obsolete model APIs and restores real dependency/test discovery. Merge #179 first. The combined diff currently includes that PR; this PR's own changes are confined to commit 189390e (backend/server.js and backend/__tests__/serverAuth.test.js). Update the branch against upstream after the prerequisite merges.

Validation:

  • Before the fix: three new public-auth cases fail with 403; three protection cases pass.
  • After the fix: cd backend && npm test passes 37 Node tests and 52 Jest tests, including all six new cases.
  • git diff --check passes.
  • Localhost socket access required for HTTP tests. No live DynamoDB or browser-session verification performed.

Independent review: both reviewers judged the production-server coverage important and nonredundant; the test specialist rated it 8/10. No high-confidence defect in the two-file change was identified. They inspected source; the local red/green and suite runs above were performed separately.

Deployment limitation: existing bearer-authorized /users and /api/admin/users responses expose account contact fields, and /api/admin/users plus /api/admin/keys lack role checks. Public signup lets new visitors obtain bearer tokens, making these existing authorization weaknesses relevant to rollout. Keep this PR draft pending authorization review; passing authentication tests does not establish safe access control. Browser onboarding/session behavior is outside this change.

Qlty validation (0.653.0): used the existing quality-gates .qlty/qlty.toml and ESLint configuration temporarily, since #179/main does not yet contain that configuration. qlty check backend/server.js backend/__tests__/serverAuth.test.js --no-fix --no-progress --no-upgrade-check --summary --print-errors passes with no issues (ESLint, TruffleHog, TODO/FIXME checks). Matching baseline server check also passes. Full qlty smells --all --include-tests --sarif --no-upgrade-check scans of dependency commit c4dda0f and head 189390e produce identical complete SARIF result sets: eight pre-existing frontend complexity/return findings, zero new findings, zero findings in changed files, and no duplication findings. No suppressions, threshold changes, or quality configuration added to this PR.

Split the backend/security scope from NTARI-RAND#171. Restore complete Node and Jest test discovery, replace tracked dependency stubs with declared packages, migrate DynamoDB to the v3 document client, and repair routes using removed model APIs. Preserve promise interfaces and conditional error codes.

Resolve dependency conflicts against current main and retain compatible patched transitive versions.

Validation: clean npm ci; 37 Node tests and 46 Jest tests pass; npm audit reports zero vulnerabilities; git diff --check passes.
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Mount the auth router before credential middleware and exercise the production server boundary. Cover unauthenticated registration and login, invalid credentials, token use, and protected-route rejection.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
@nirmalhk7

Copy link
Copy Markdown
Contributor Author

Pls hold back on this for now.

Merge current main, retaining the account, federation, and conversation security repairs. Keep server-level authentication regressions and cover restricted admin access, sanitized directory responses, and rejected browser credentials at federation endpoints.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
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