mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 16:56:56 +00:00
feature/Add endpoint providerCheck v5.1.0
This commit is contained in:
parent
a91acce206
commit
71d4d669f3
@ -1220,4 +1220,8 @@ retain_metrics_move_limit = 50000
|
||||
retain_metrics_scheduler_interval_in_seconds = 3600
|
||||
|
||||
#if same session used for different ip address, we can show this warning, default is false.
|
||||
show_ip_address_change_warning=false
|
||||
show_ip_address_change_warning=false
|
||||
|
||||
# List of provider considered as a valid ones at an instance
|
||||
# We specify the list as a comma separeted list
|
||||
valid_providers="Hostname props value"
|
||||
@ -16,6 +16,7 @@ import code.api.v4_0_0.{JSONFactory400, PostApiCollectionJson400}
|
||||
import code.consent.Consents
|
||||
import code.loginattempts.LoginAttempt
|
||||
import code.metrics.APIMetrics
|
||||
import code.model.dataAccess.AuthUser
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes.{apply => _}
|
||||
import code.userlocks.UserLocksProvider
|
||||
import code.users.Users
|
||||
@ -218,6 +219,40 @@ trait APIMethods510 {
|
||||
(JSONFactory510.getAccountAccessUniqueIndexCheck(groupedRows), HttpCode.`200`(cc.callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
staticResourceDocs += ResourceDoc(
|
||||
providerCheck,
|
||||
implementedInApiVersion,
|
||||
nameOf(providerCheck),
|
||||
"GET",
|
||||
"/management/system/integrity/provider",
|
||||
"Check Providers",
|
||||
s"""Check providers.
|
||||
|
|
||||
|${authenticationRequiredMessage(true)}
|
||||
|""".stripMargin,
|
||||
EmptyBody,
|
||||
CheckSystemIntegrityJsonV510(true),
|
||||
List(
|
||||
$UserNotLoggedIn,
|
||||
UserHasMissingRoles,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagSystemIntegrity, apiTagNewStyle),
|
||||
Some(canGetSystemIntegrity :: Nil)
|
||||
)
|
||||
|
||||
lazy val providerCheck: OBPEndpoint = {
|
||||
case "management" :: "system" :: "integrity" :: "provider" :: Nil JsonGet _ => {
|
||||
cc =>
|
||||
for {
|
||||
distinctRows: List[String] <- Future {
|
||||
AuthUser.findAll().map(_.provider.get).distinct
|
||||
}
|
||||
} yield {
|
||||
(JSONFactory510.getProviderCheck(distinctRows), HttpCode.`200`(cc.callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
staticResourceDocs += ResourceDoc(
|
||||
|
||||
@ -90,6 +90,18 @@ object JSONFactory510 {
|
||||
success = success,
|
||||
debug_info = debugInfo
|
||||
)
|
||||
}
|
||||
def getProviderCheck(distinctRows: List[String]): CheckSystemIntegrityJsonV510 = {
|
||||
val allowedProviders: List[String] = APIUtil.getPropsValue(nameOfProperty = "allowed_providers")
|
||||
.or(APIUtil.getPropsValue(nameOfProperty = "hostname"))
|
||||
.toList.map(_.toLowerCase()).map(_.split(",").toList).flatten
|
||||
val invalidRows = distinctRows.filter(!allowedProviders.contains(_))
|
||||
val success = distinctRows.forall(Nil.contains(_))
|
||||
val debugInfo = if(success) None else Some(s"Invalid provider values: ${invalidRows.mkString(",")}")
|
||||
CheckSystemIntegrityJsonV510(
|
||||
success = success,
|
||||
debug_info = debugInfo
|
||||
)
|
||||
}
|
||||
|
||||
def getApiInfoJSON(apiVersion : ApiVersion, apiVersionStatus: String) = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user