Skip to content

feat: delete consent challenges once they can no longer be used - #2959

Closed
hongwei1 wants to merge 1 commit into
OpenBankProject:developfrom
hongwei1:feature/remove-spent-consent-challenges
Closed

hongwei1 wants to merge 1 commit into
OpenBankProject:developfrom
hongwei1:feature/remove-spent-consent-challenges

Conversation

@hongwei1

@hongwei1 hongwei1 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

A consent's OBP_CONSENT_CHALLENGE rows in ExpectedChallengeAnswer are now deleted once none of them can be used any more. When the PSU answers a UK consent challenge correctly on POST /obp/v5.1.0/banks/BANK_ID/consents/CONSENT_ID/authorise, the answered challenge and any other challenge started on that consent are removed. The same happens when the consent becomes REVOKED, REJECTED or EXPIRED, whether through updateConsentStatus (including the management endpoint PUT /management/banks/BANK_ID/consents/CONSENT_ID), through revoke (every revoke endpoint, the UK DELETE included) or through the UK expiry sweep in ConsentScheduler. A wrong answer keeps its row, so the attempt counter still limits the next guesses. Rows of other challenge types are never touched: Berlin Group consent challenges stay because the BG authorisation endpoints list them after they are answered, and transaction request challenges stay because the quorum check counts them. The removal goes through a new ChallengeProvider.deleteChallengesByConsentId(consentId, challengeType). A failed delete is logged and does not fail the request, because the answer or status change has already gone through.

UKOpenBankingV401AccountInfoTests covers a correct answer (both OBP consent challenges removed, a Berlin Group challenge on the same consent kept), a wrong answer (row and attempt count kept), a correct answer that is then refused (challenge still removed), the REJECTED / REVOKED / EXPIRED transitions next to AUTHORISED (which keeps its rows), and the UK expiry sweep.

A consent's OBP_CONSENT_CHALLENGE rows are deleted when the PSU answers
one correctly on POST .../consents/CONSENT_ID/authorise (the answered
challenge and any other one started on the consent), and when the
consent becomes REVOKED, REJECTED or EXPIRED through updateConsentStatus,
revoke or the UK expiry sweep. A wrong answer keeps its row so the
attempt counter still applies. Berlin Group consent challenges and
transaction request challenges are left as they are, since they are read
after answering.
@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@hongwei1

hongwei1 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Combined with #2959, #2960 and #2961 into #2962, which carries the same commits as one change.

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