Skip to content

AdminPortal: send [REDACTED SECRET] actions as POST with the CSRF token - #626

Open
devin-ai-integration[bot] wants to merge 3 commits into
masterfrom
devin/task-7-adminportal-csrf-post
Open

devin-ai-integration[bot] wants to merge 3 commits into
masterfrom
devin/task-7-adminportal-csrf-post

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Summary

Makes the Angular AdminPortal work against COG-GTM/Online-Banking-System#2060. That PR turns on CSRF (CookieCsrfTokenRepository.withHttpOnlyFalse()) and makes /api/appointment/{id}/confirm and /api/user/{username}/enable|disable POST-only: GET now returns 405, and POST without a token returns 403.

  • UserService.enableUser/disableUser and AppointmentService.confirmAppointment: http.get(url) → http.post(url, null, { withCredentials: true }).
  • CSRF header: @angular/http's CookieXSRFStrategy copies the XSRF-TOKEN cookie into X-XSRF-TOKEN on every request. It is the HttpModule default; AppModule now provides it explicitly so the dependency on Spring's names is visible.
  • Login: the form-login POST /index is CSRF-protected too, and on a fresh browser no backend call has set the cookie yet. LoginService.sendCredential now does GET /index first, then mergeMaps to the POST.
  • location.reload() used to run right after .subscribe(). With the custom X-XSRF-TOKEN header every call is CORS-preflighted, so the reload aborted the request before the POST went out. Confirm/enable/disable now reload in the success callback. Logout runs router.navigate(['/login']).then(() => location.reload()) so the page ends on /login.
  • Specs (MockBackend): login sends the GET before the POST and skips the POST if the GET fails; xsrfStrategyFactory sets the header from the cookie; enable/disable/confirm are credentialed POSTs.

Recipient delete (also POST-only in #2060) is a Thymeleaf page in the backend and is not called by the AdminPortal.

Note: older open PRs #617, #618 and #622 also touch these AdminPortal files, paired with CSRF changes to this repo's UserFront copy. This PR targets the separate Online-Banking-System backend (#2060). Land only one of the overlapping AdminPortal changes.

Testing

  • ng build passes. ng lint adds no new errors (the existing files already had 172).
  • The 6 service specs pass in ChromeHeadless. A full ng test run already fails on master: four component specs don't compile (TS2346), so I ran only the service specs.
  • Ran #2060 locally against a throwaway mysql:5.7 container. With Origin: http://localhost:4200 and curl: login via the cookie token works, preflight returns 200, GET disable returns 405, POST without a token returns 403, POST with the token returns 200 and flips user.enabled.
  • Browser end-to-end test (login, disable/enable, confirm appointment, logout, re-login) passed against the same setup. Screenshots and recordings are in the PR comment.

Devin-Org: engineering

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/8144a89da0d1422f973f2a196abbeee0
Link to Bot: https://devin-gtm.devinenterprise.com/org/devin-gtm/bots/a78446fd2653463e94cefb31caca525b
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/8144a89da0d1422f973f2a196abbeee0?variant=devin

Implemented in “Switch AdminPortal admin calls to POST with CSRF”Devin Review


Note

Devin could not open this Pull Request as matthewguerra-cog: they have no GitHub connection usable for this repository.
As a fallback, Devin opened this PR as itself.


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

Online-Banking-System now enables CSRF protection with a cookie token
repository and makes appointment confirm and user enable/disable POST-only.

- Call confirm/enable/disable with POST.
- Fetch the login page before the login POST so the XSRF-TOKEN cookie exists;
  Http sends it back as X-XSRF-TOKEN (strategy configured explicitly).
- Reload only after confirm/enable/disable/logout complete, since the CSRF
  header makes them preflighted and an immediate reload aborted them.

Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

🔍 Devin Review: 1 custom reviewer finding

Custom reviewers

  • 🧪 Test reviewer: 1 finding · View
  • 🧪 Test 2 reviewer: no findings · View

Devin Review

Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 finding. Devin automatically fixed it.

Fixed by Devin (1)
  • P2 — CSRF login sequence lacks regression coverage — Added MockBackend specs: login GETs /index before the POST, skips the POST if the GET fails, xsrfStrategyFactory copies XSRF-TOKEN into X-XSRF-TOKEN, and enable/disable/confirm are credentialed POSTs (6/6 pass in ChromeHeadless).

View findings in Devin Review · Follow Devin's work

Devin Review

Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

Browser-tested against backend #2060 (localhost:8080) on a throwaway MySQL container only.

  • Fresh-cookie login: GET /index, then POST /index with X-XSRF-TOKEN; user list loads.
  • Disable and re-enable a customer: token-bearing POSTs return 200, and the reloaded UI and DB match (1 → 0 → 1).
  • Confirm appointment: POST returns 200 and the appointment shows confirmed.
  • With the backend unreachable, disable fails without reloading and nothing changes.
  • The first run caught a logout regression (the page stayed on /userAccount). 97c82a1 fixes it: logout now navigates to /login before reloading. A retest confirmed it, and re-login still works.
Appointment confirmed After logout (97c82a1) Re-login
Appointment confirmed Logout lands on login Re-login user list

Recordings: main flow · logout retest

Unit specs added in 33b481f (LoginService GET-before-POST order, the XSRF header strategy, POST [REDACTED SECRET] calls): 6/6 pass in ChromeHeadless.

Written by Devin

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.

0 participants