Repository navigation
AdminPortal: send [REDACTED SECRET] actions as POST with the CSRF token - #626
Open
devin-ai-integration[bot] wants to merge 3 commits into
Open
devin-ai-integration[bot] wants to merge 3 commits into
devin-ai-integration[bot] wants to merge 3 commits into
Conversation
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>
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
Author
There was a problem hiding this comment.
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).
Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
Author
|
Browser-tested against backend #2060 (localhost:8080) on a throwaway MySQL container only.
Recordings: main flow · logout retest Unit specs added in 33b481f ( |
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.
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}/confirmand/api/user/{username}/enable|disablePOST-only: GET now returns 405, and POST without a token returns 403.UserService.enableUser/disableUserandAppointmentService.confirmAppointment:http.get(url)→http.post(url, null, { withCredentials: true }).@angular/http'sCookieXSRFStrategycopies theXSRF-TOKENcookie intoX-XSRF-TOKENon every request. It is the HttpModule default;AppModulenow provides it explicitly so the dependency on Spring's names is visible.POST /indexis CSRF-protected too, and on a fresh browser no backend call has set the cookie yet.LoginService.sendCredentialnow doesGET /indexfirst, thenmergeMaps to the POST.location.reload()used to run right after.subscribe(). With the customX-XSRF-TOKENheader 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 runsrouter.navigate(['/login']).then(() => location.reload())so the page ends on/login.MockBackend): login sends the GET before the POST and skips the POST if the GET fails;xsrfStrategyFactorysets 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
UserFrontcopy. This PR targets the separate Online-Banking-System backend (#2060). Land only one of the overlapping AdminPortal changes.Testing
ng buildpasses.ng lintadds no new errors (the existing files already had 172).ng testrun already fails on master: four component specs don't compile (TS2346), so I ran only the service specs.mysql:5.7container. WithOrigin: http://localhost:4200and 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 flipsuser.enabled.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
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