feature/Enhance Consent Flow of Berlin Group part 3

This commit is contained in:
Marko Milić 2021-02-15 16:18:35 +01:00
parent 7d562b9a38
commit 264ea6d415
5 changed files with 16 additions and 5 deletions

View File

@ -658,7 +658,8 @@ class Boot extends MdcLoggable {
val viewsUKOpenBanking = List(
SYSTEM_READ_ACCOUNTS_BASIC_VIEW_ID, SYSTEM_READ_ACCOUNTS_DETAIL_VIEW_ID,
SYSTEM_READ_BALANCES_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BASIC_VIEW_ID,
SYSTEM_READ_TRANSACTIONS_DEBITS_VIEW_ID, SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID
SYSTEM_READ_TRANSACTIONS_DEBITS_VIEW_ID, SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID,
SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID
)
for {
systemView <- viewSetUKOpenBanking

View File

@ -351,7 +351,8 @@ The account-id is constant at least throughout the lifecycle of a given consent.
_ <- passesPsd2Aisp(callContext)
(account: BankAccount, callContext) <- NewStyle.function.getBankAccountByAccountId(accountId, callContext)
_ <- Helper.booleanToFuture(failMsg = UserNoOwnerView +"userId : " + u.userId + ". account : " + accountId){
u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId))
u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId)) ||
u.hasReadAccountsBerlinGroupViewAccess(BankIdAccountId(account.bankId, account.accountId))
}
} yield {
(JSONFactory_BERLIN_GROUP_1_3.createAccountBalanceJSON(account), HttpCode.`200`(callContext))
@ -483,7 +484,8 @@ This account-id then can be retrieved by the
_ <- passesPsd2Aisp(callContext)
(account: BankAccount, callContext) <- NewStyle.function.getBankAccountByAccountId(AccountId(accountId), callContext)
_ <- Helper.booleanToFuture(failMsg = UserNoOwnerView +"userId : " + u.userId + ". account : " + accountId){
u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId))
u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId)) ||
u.hasReadAccountsBerlinGroupViewAccess(BankIdAccountId(account.bankId, account.accountId))
}
} yield {
(JSONFactory_BERLIN_GROUP_1_3.createCardAccountBalanceJSON(account), HttpCode.`200`(callContext))

View File

@ -31,6 +31,8 @@ object Constant extends MdcLoggable {
final val SYSTEM_READ_TRANSACTIONS_BASIC_VIEW_ID = "ReadTransactionsBasic"
final val SYSTEM_READ_TRANSACTIONS_DEBITS_VIEW_ID = "ReadTransactionsDebits"
final val SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID = "ReadTransactionsDetail"
// Berlin Group
final val SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID = "ReadAccountsBerlinGroup"
//These are the default incoming and outgoing account ids. we will create both during the boot.scala.
final val INCOMING_ACCOUNT_ID= "OBP_DEFAULT_INCOMING_ACCOUNT_ID"

View File

@ -379,7 +379,7 @@ object Consent {
case Full(jsonAsString) =>
try {
val consent = net.liftweb.json.parse(jsonAsString).extract[ConsentJWT]
checkConsent(consent, consentId, calContext) match { // Check is it Consent-JWT expired
checkConsent(consent, storedConsent.jsonWebToken, calContext) match { // Check is it Consent-JWT expired
case (Full(true)) => // OK
applyConsentRules(consent)
case failure@Failure(_, _, _) => // Handled errors
@ -503,7 +503,7 @@ object Consent {
ConsentView(
bank_id = bankAccount._1.map(_.bankId.value).getOrElse(""),
account_id = bankAccount._1.map(_.accountId.value).getOrElse(""),
view_id = "owner"
view_id = Constant.SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID
)
}
}

View File

@ -78,6 +78,12 @@ case class UserExtended(val user: User) extends MdcLoggable {
final def hasOwnerViewAccess(bankIdAccountId: BankIdAccountId): Boolean = {
checkOwnerViewAccessAndReturnOwnerView(bankIdAccountId).isDefined
}
final def hasReadAccountsBerlinGroupViewAccess(bankIdAccountId: BankIdAccountId): Boolean = {
APIUtil.checkViewAccessAndReturnView(
ViewId(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID),
bankIdAccountId, Some(this.user)
).isDefined
}
def assignedEntitlements : List[Entitlement] = {
Entitlement.entitlement.vend.getEntitlementsByUserId(userId) match {