mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:17:09 +00:00
feature/Centralize Berlin Group path usage
This commit is contained in:
parent
1667593a13
commit
32998cd2e2
@ -726,7 +726,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
|
||||
}
|
||||
def composeErrorMessage() = {
|
||||
val path = callContextLight.map(_.url).getOrElse("")
|
||||
if (path.contains("berlin-group")) {
|
||||
if (path.contains(ApiVersion.berlinGroupV13.urlPrefix)) {
|
||||
val path =
|
||||
if(APIUtil.getPropsAsBoolValue("berlin_group_error_message_show_path", defaultValue = true))
|
||||
callContextLight.map(_.url)
|
||||
|
||||
@ -3,6 +3,7 @@ package code.api.util
|
||||
import code.api.APIFailureNewStyle
|
||||
import code.api.util.APIUtil.fullBoxOrException
|
||||
import com.openbankproject.commons.model.User
|
||||
import com.openbankproject.commons.util.ApiVersion
|
||||
import net.liftweb.common.{Box, Empty}
|
||||
import net.liftweb.http.provider.HTTPParam
|
||||
|
||||
@ -20,7 +21,7 @@ object BerlinGroupCheck {
|
||||
|
||||
private def validateHeaders(verb: String, url: String, reqHeaders: List[HTTPParam], forwardResult: (Box[User], Option[CallContext])): (Box[User], Option[CallContext]) = {
|
||||
val headerMap = reqHeaders.map(h => h.name.toLowerCase -> h).toMap
|
||||
val missingHeaders = if(url.contains("berlin-group") && url.endsWith("/consent"))
|
||||
val missingHeaders = if(url.contains(ApiVersion.berlinGroupV13.urlPrefix) && url.endsWith("/consent"))
|
||||
(berlinGroupMandatoryHeaders ++ berlinGroupMandatoryHeaderConsent).filterNot(headerMap.contains)
|
||||
else
|
||||
berlinGroupMandatoryHeaders.filterNot(headerMap.contains)
|
||||
@ -33,7 +34,7 @@ object BerlinGroupCheck {
|
||||
}
|
||||
|
||||
def validate(body: Box[String], verb: String, url: String, reqHeaders: List[HTTPParam], forwardResult: (Box[User], Option[CallContext])): (Box[User], Option[CallContext]) = {
|
||||
if(url.contains("berlin-group")) {
|
||||
if(url.contains(ApiVersion.berlinGroupV13.urlPrefix)) {
|
||||
validateHeaders(verb, url, reqHeaders, forwardResult) match {
|
||||
case (user, _) if user.isDefined || user == Empty => // All good. Chain another check
|
||||
// Verify signed request (Berlin Group)
|
||||
|
||||
@ -8,13 +8,14 @@ import code.api.v3_0_0.ViewJsonV300
|
||||
import code.api.v4_0_0.{PostAccountAccessJsonV400, PostViewJsonV400}
|
||||
import code.setup.ServerSetupWithTestData
|
||||
import code.views.Views
|
||||
import com.openbankproject.commons.util.ApiVersion
|
||||
import dispatch.Req
|
||||
import net.liftweb.json.Serialization.write
|
||||
import org.scalatest.Tag
|
||||
|
||||
trait BerlinGroupServerSetupV1_3 extends ServerSetupWithTestData {
|
||||
object BerlinGroupV1_3 extends Tag("BerlinGroup_v1_3")
|
||||
val V1_3_BG = baseRequest / "berlin-group" / "v1.3"
|
||||
val V1_3_BG = baseRequest / ApiVersion.berlinGroupV13.urlPrefix / "v1.3"
|
||||
def v4_0_0_Request: Req = baseRequest / "obp" / "v4.0.0"
|
||||
|
||||
override def beforeEach() = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user