Skip to content

Self service bank creation (limited by props)#2877

Merged
simonredfern merged 2 commits into
OpenBankProject:developfrom
simonredfern:develop
Jul 23, 2026
Merged

Self service bank creation (limited by props)#2877
simonredfern merged 2 commits into
OpenBankProject:developfrom
simonredfern:develop

Conversation

@simonredfern

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 23, 2026 08:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a v7.0.0 self-service bank creation flow (/my/banks) intended for sandbox usage, gated by a new prop-based per-user quota and backed by server-generated bank identities to prevent user-supplied strings reaching public bank listings.

Changes:

  • Introduces POST /my/banks (create) and GET /my/banks (list) endpoints in Http4s700, gated by self_service_bank_creation.limit.
  • Persists the creator user id on newly created banks (MappedBank.CreatedByUserId) and uses it to enforce quota / listing.
  • Adds v7 route tests, new error messages, and documents the new prop and endpoint inventory.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
obp-api/src/main/scala/code/api/v7_0_0/Http4s700.scala Implements /my/banks create/list endpoints, quota checks, ResourceDocs.
obp-api/src/main/scala/code/model/dataAccess/MappedBank.scala Adds CreatedByUserId field and DB index for querying by creator.
obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala Sets CreatedByUserId on bank creation using CallContext user.
obp-api/src/main/scala/code/util/BankNameGenerator.scala Adds server-side bank id/name generator (no user-provided identity).
obp-api/src/main/scala/code/api/util/ErrorMessages.scala Adds new error message constants for disabled/quota-reached cases.
obp-api/src/test/scala/code/api/v7_0_0/Http4s700RoutesTest.scala Adds test scenarios covering auth, disabled state, body validation, quota, listing.
obp-api/src/main/resources/props/sample.props.template Documents new self_service_bank_creation.limit prop.
CLAUDE.md Updates the documented list of v7.0.0 native endpoints to include /my/banks.
Comments suppressed due to low confidence (1)

obp-api/src/main/scala/code/api/v7_0_0/Http4s700.scala:391

  • banksCreatedByUser here is a List[MappedBank], but in createMyBank the same name was used for a count. Using a clearer name (e.g. banks) avoids confusion when scanning the file.
          for {
            banksCreatedByUser <- Future(MappedBank.findAll(By(MappedBank.CreatedByUserId, user.userId)))
          } yield JSONFactory600.createBanksJsonV600(banksCreatedByUser)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +335 to +336
_ <- Future(Entitlement.entitlement.vend.addEntitlement(
generatedName.bankId, cc.userId, canCreateEntitlementAtOneBank.toString()))
Comment on lines +317 to +320
banksCreatedByUser <- Future(MappedBank.count(By(MappedBank.CreatedByUserId, cc.userId)))
_ <- Helper.booleanToFuture(SelfServiceBankLimitReached, failCode = 403, cc = Some(cc)) {
banksCreatedByUser < selfServiceBankLimit
}
Comment on lines +317 to +320
banksCreatedByUser <- Future(MappedBank.count(By(MappedBank.CreatedByUserId, cc.userId)))
_ <- Helper.booleanToFuture(SelfServiceBankLimitReached, failCode = 403, cc = Some(cc)) {
banksCreatedByUser < selfServiceBankLimit
}
Copilot AI review requested due to automatic review settings July 23, 2026 11:40
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment on lines +359 to +360
_ <- Future(Entitlement.entitlement.vend.addEntitlement(
generatedName.bankId, cc.userId, canCreateEntitlementAtOneBank.toString()))
Comment on lines 3378 to 3382
.national_identifier(national_identifier)
.mBankRoutingScheme(bankRoutingScheme)
.mBankRoutingAddress(bankRoutingAddress)
.CreatedByUserId(callContext.map(_.user).flatMap(_.toOption).map(_.userId).getOrElse(""))
.saveMe()
Comment on lines +282 to +287
// ─── Self-service bank creation — /my/banks ──────────────────────────────
// One bank per registered user, gated by props self_service_bank_creation.limit
// (default 0 = disabled). Every public-facing string (bank_id, short name, full
// name) is generated by BankNameGenerator, so no user-supplied text can reach the
// anonymous GET /banks listing — which is why the POST takes an empty body.
// Response shapes reuse the v6 bank JSON (BankJson600 / BanksJsonV600).
@simonredfern
simonredfern merged commit 076400e into OpenBankProject:develop Jul 23, 2026
12 checks passed
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.

2 participants