Skip to content

Commit

Permalink
Merge pull request #2479 from constantine2nd/develop
Browse files Browse the repository at this point in the history
Few tweaks
  • Loading branch information
simonredfern authored Jan 13, 2025
2 parents dc4f6d7 + 39ba747 commit 5c5b96c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ display_internal_errors=false
# - decoupled
# In case that "psu_authentication_method = redirection" you must define
# psu_authentication_method_sca_redirect_url = redirect_url_value
# psu_make_payment_sca_redirect_url = redirect_url_value
# -------------------------------------------------------------- Authentication methods --

## This property is used for documenting at Resource Doc. It may include the port also (but not /obp)
Expand Down
3 changes: 2 additions & 1 deletion obp-api/src/main/scala/code/api/OAuth2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ object OAuth2Login extends RestHelper with MdcLoggable {
val openBankRoles: List[String] =
// Sync Keycloak's roles
(json \ "resource_access" \ resourceAccessName \ "roles").extract[List[String]]
.filter(role => tryo(ApiRole.valueOf(role)).isDefined) // Keep only the roles OBP-API can recognise
// Keep only the roles OBP-API can recognise
.filter(role => tryo(ApiRole.valueOf(role)).isDefined || ApiRole.isBerlinGroupRole(role))
val scopes = Scope.scope.vend.getScopesByConsumerId(consumerPrimaryKey.toString).getOrElse(Nil)
val databaseState = scopes.map(_.roleName)
// Already exist at DB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,16 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats {
// Remark: This code may be
//map OBP transactionRequestId to BerlinGroup PaymentId
val paymentId = transactionRequest.id.value
val scaRedirectUrl = getPropsValue("psu_authentication_method_sca_redirect_url")
.openOr(MissingPropsValueAtThisInstance + "psu_authentication_method_sca_redirect_url")
val scaRedirectUrl = getPropsValue("psu_make_payment_sca_redirect_url")
.openOr(MissingPropsValueAtThisInstance + "psu_make_payment_sca_redirect_url")
InitiatePaymentResponseJson(
transactionStatus = transactionRequest.status match {
case "COMPLETED" => "ACCP"
case "INITIATED" => "RCVD"
},
paymentId = paymentId,
_links = InitiatePaymentResponseLinks(
scaRedirect = LinkHrefJson(s"$scaRedirectUrl/payments/$paymentId"),
scaRedirect = LinkHrefJson(s"$scaRedirectUrl/$paymentId"),
self = LinkHrefJson(s"/v1.3/payments/sepa-credit-transfers/$paymentId"),
status = LinkHrefJson(s"/v1.3/payments/$paymentId/status"),
scaStatus = LinkHrefJson(s"/v1.3/payments/$paymentId/authorisations/${paymentId}")
Expand Down
11 changes: 11 additions & 0 deletions obp-api/src/main/scala/code/api/util/ApiRole.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package code.api.util

import code.api.Constant.{SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID}
import code.api.dynamic.endpoint.helper.DynamicEndpointHelper

import java.util.concurrent.ConcurrentHashMap
Expand Down Expand Up @@ -1058,6 +1059,16 @@ object ApiRole extends MdcLoggable{
dynamicRoles ::: roles.map(_.toString)
}

def isBerlinGroupRole(value: String): Boolean = {
value match {
case SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID => true
case SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID => true
case SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID => true
case SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID => true
case _ => false
}
}

}

object Util {
Expand Down
12 changes: 1 addition & 11 deletions obp-api/src/main/scala/code/api/util/NewStyle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,7 @@ object NewStyle extends MdcLoggable{
val viewIds = List(ViewId(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID))
Views.views.vend.getPrivateBankAccountsFuture(user, viewIds) map { i =>
if(i.isEmpty) {
(unboxFullOrFail(Empty, callContext, NoViewReadAccountsBerlinGroup , 403), callContext)
} else {
(i, callContext )
}
}
}
def getAccountListThroughView(user : User, viewId: ViewId, callContext: Option[CallContext]): OBPReturnType[List[BankIdAccountId]] = {
val viewIds = List(viewId)
Views.views.vend.getPrivateBankAccountsFuture(user, viewIds) map { i =>
if(i.isEmpty) {
(unboxFullOrFail(Empty, callContext, NoViewReadAccountsBerlinGroup , 403), callContext)
(unboxFullOrFail(Empty, callContext, s"$NoViewReadAccountsBerlinGroup {$SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID}" , 403), callContext)
} else {
(i, callContext )
}
Expand Down

0 comments on commit 5c5b96c

Please sign in to comment.