Self service bank creation (limited by props)#2877
Merged
Conversation
There was a problem hiding this comment.
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) andGET /my/banks(list) endpoints inHttp4s700, gated byself_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
banksCreatedByUserhere is aList[MappedBank], but increateMyBankthe 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 | ||
| } |
|
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). |
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.



No description provided.