mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:56:46 +00:00
Merge pull request #801 from constantine2nd/develop
Tickets: #773, #765 and #623
This commit is contained in:
commit
679443c9df
@ -189,16 +189,16 @@ trait OBPRestHelper extends RestHelper with MdcLoggable {
|
||||
val usr = getUser
|
||||
usr match {
|
||||
case Full(u) => fn(Full(u)) // Authentication is successful
|
||||
case ParamFailure(_, _, _, apiFailure : APIFailure) => errorJsonResponse(apiFailure.msg, apiFailure.responseCode)
|
||||
case Failure(msg, _, _) => errorJsonResponse(msg)
|
||||
case _ => errorJsonResponse("oauth error")
|
||||
case ParamFailure(a, b, c, apiFailure : APIFailure) => ParamFailure(a, b, c, apiFailure : APIFailure)
|
||||
case Failure(msg, t, c) => Failure(msg, t, c)
|
||||
case _ => Failure("oauth error")
|
||||
}
|
||||
} else if (Props.getBool("allow_direct_login", true) && hasDirectLoginHeader) {
|
||||
DirectLogin.getUser match {
|
||||
case Full(u) => fn(Full(u)) // Authentication is successful
|
||||
case _ => {
|
||||
var (httpCode, message, directLoginParameters) = DirectLogin.validator("protectedResource", DirectLogin.getHttpMethod)
|
||||
errorJsonResponse(message, httpCode)
|
||||
Full(errorJsonResponse(message, httpCode))
|
||||
}
|
||||
}
|
||||
} else if (Props.getBool("allow_gateway_login", false) && hasGatewayHeader) {
|
||||
@ -222,21 +222,25 @@ trait OBPRestHelper extends RestHelper with MdcLoggable {
|
||||
setGatewayLoginUsername(s)(u.name)
|
||||
setGatewayLoginCbsToken(s)(cbsAuthToken.get)
|
||||
fn(Full(u))
|
||||
case Failure(msg, _, _) => errorJsonResponse(msg)
|
||||
case _ => errorJsonResponse(payload, httpCode)
|
||||
case Failure(msg, t, c) => Failure(msg, t, c)
|
||||
case _ => Full(errorJsonResponse(payload, httpCode))
|
||||
}
|
||||
case Failure(msg, _, _) =>
|
||||
errorJsonResponse(msg)
|
||||
case Failure(msg, t, c) =>
|
||||
Failure(msg, t, c)
|
||||
case _ =>
|
||||
errorJsonResponse(ErrorMessages.GatewayLoginUnknownError)
|
||||
Failure(ErrorMessages.GatewayLoginUnknownError)
|
||||
}
|
||||
case _ => errorJsonResponse(message, httpCode)
|
||||
case _ =>
|
||||
Failure(message)
|
||||
}
|
||||
case Full(h) if h.split(",").toList.exists(_.equalsIgnoreCase(getRemoteIpAddress()) == false) => // All other addresses will be rejected
|
||||
errorJsonResponse(ErrorMessages.GatewayLoginWhiteListAddresses)
|
||||
case Empty => errorJsonResponse(ErrorMessages.GatewayLoginHostPropertyMissing) // There is no gateway.host in props file
|
||||
case Failure(msg, _, _) => errorJsonResponse(msg)
|
||||
case _ => errorJsonResponse(ErrorMessages.GatewayLoginUnknownError)
|
||||
Failure(ErrorMessages.GatewayLoginWhiteListAddresses)
|
||||
case Empty =>
|
||||
Failure(ErrorMessages.GatewayLoginHostPropertyMissing) // There is no gateway.host in props file
|
||||
case Failure(msg, t, c) =>
|
||||
Failure(msg, t, c)
|
||||
case _ =>
|
||||
Failure(ErrorMessages.GatewayLoginUnknownError)
|
||||
}
|
||||
} else {
|
||||
fn(Empty)
|
||||
|
||||
@ -3,7 +3,7 @@ package code.api.ResourceDocs1_4_0
|
||||
import code.api.util.APIUtil
|
||||
import code.api.util.APIUtil.{defaultJValue, _}
|
||||
import code.api.v3_0_0.JSONFactory300.createBranchJsonV300
|
||||
import code.api.v3_0_0.{LobbyJsonV330, _}
|
||||
import code.api.v3_0_0.{AdapterInfoJsonV300, LobbyJsonV330, _}
|
||||
import code.bankconnectors.vMar2017.{MessageDocJson, MessageDocsJson}
|
||||
import code.branches.Branches.{DriveUpString, _}
|
||||
import code.common._
|
||||
@ -1895,7 +1895,7 @@ object SwaggerDefinitionsJSON {
|
||||
val connectorMetricJson = ConnectorMetricJson(
|
||||
connector_name = "mapper",
|
||||
function_name = "getBanks",
|
||||
obp_api_request_id = "12345",
|
||||
correlation_id = "12345",
|
||||
date = exampleDate,
|
||||
duration = 1000
|
||||
)
|
||||
@ -2000,6 +2000,14 @@ object SwaggerDefinitionsJSON {
|
||||
account_routing = accountRoutingJsonV121
|
||||
)
|
||||
val coreAccountsJsonV300 = CoreAccountsJsonV300(accounts = List(coreAccountJsonV300))
|
||||
|
||||
val adapterInfoJsonV300 = AdapterInfoJsonV300(
|
||||
name = "String",
|
||||
version = "String",
|
||||
git_commit = "String",
|
||||
date = "String"
|
||||
)
|
||||
|
||||
//The commont error or success format.
|
||||
//Just some helper format to use in Json
|
||||
case class NoSupportYet()
|
||||
|
||||
@ -252,7 +252,7 @@ case class ConfigurationJSON(akka: AkkaJSON, elastic_search: ElasticSearchJSON,
|
||||
case class ConnectorMetricJson(
|
||||
connector_name: String,
|
||||
function_name: String,
|
||||
obp_api_request_id: String,
|
||||
correlation_id: String,
|
||||
date: Date,
|
||||
duration: Long
|
||||
)
|
||||
@ -576,7 +576,7 @@ object JSONFactory220{
|
||||
ConnectorMetricJson(
|
||||
connector_name = metric.getConnectorName(),
|
||||
function_name = metric.getFunctionName(),
|
||||
obp_api_request_id = metric.getCorrelationId(),
|
||||
correlation_id = metric.getCorrelationId(),
|
||||
duration = metric.getDuration(),
|
||||
date = metric.getDate()
|
||||
)
|
||||
|
||||
@ -708,7 +708,7 @@ trait APIMethods300 {
|
||||
|
|
||||
""".stripMargin,
|
||||
emptyObjectJson,
|
||||
usersJSONV200,
|
||||
adapterInfoJsonV300,
|
||||
List(UserNotLoggedIn, UnknownError),
|
||||
Catalogs(Core, notPSD2, notOBWG),
|
||||
List(apiTagApi))
|
||||
@ -716,13 +716,13 @@ trait APIMethods300 {
|
||||
|
||||
lazy val getAdapter: PartialFunction[Req, Box[User] => Box[JsonResponse]] = {
|
||||
case "banks" :: BankId(bankId) :: "adapter" :: Nil JsonGet _ => {
|
||||
user =>
|
||||
_ =>
|
||||
for {
|
||||
_ <- Bank(bankId) ?~! BankNotFound
|
||||
ai: InboundAdapterInfoInternal <- Connector.connector.vend.getAdapterInfo() ?~ "Not implemented"
|
||||
}
|
||||
yield {
|
||||
successJsonResponseFromCaseClass(ai)
|
||||
successJsonResponseFromCaseClass(createAdapterInfoJson(ai))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ import code.api.v1_2_1._
|
||||
import code.api.v1_4_0.JSONFactory1_4_0.{BranchesJsonV300, _}
|
||||
import code.api.v2_0_0.JSONFactory200.{UserJsonV200, UsersJSONV200}
|
||||
import code.atms.Atms.{Atm, AtmId, AtmT}
|
||||
import code.bankconnectors.vMar2017.InboundAdapterInfoInternal
|
||||
import code.branches.Branches._
|
||||
import code.entitlement.Entitlement
|
||||
import code.model.dataAccess.ResourceUser
|
||||
@ -341,6 +342,14 @@ case class AtmJsonV300 (
|
||||
case class AtmsJsonV300(branches : List[AtmJsonV300])
|
||||
|
||||
|
||||
case class AdapterInfoJsonV300(
|
||||
name: String,
|
||||
version: String,
|
||||
git_commit: String,
|
||||
date: String
|
||||
)
|
||||
|
||||
|
||||
object JSONFactory300{
|
||||
//stated -- Transaction relevant methods /////
|
||||
def createTransactionsJson(transactions: List[ModeratedTransaction]) : TransactionsJsonV300 = {
|
||||
@ -904,5 +913,13 @@ object JSONFactory300{
|
||||
}
|
||||
|
||||
|
||||
def createAdapterInfoJson(ai: InboundAdapterInfoInternal): AdapterInfoJsonV300 = {
|
||||
AdapterInfoJsonV300(
|
||||
name = ai.name,
|
||||
version = ai.version,
|
||||
git_commit = ai.git_commit,
|
||||
date = ai.date
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user