Skip to content

Commit

Permalink
block some status endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferdudas97 committed Dec 13, 2023
1 parent 2f820d6 commit 1a35778
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class AdminRouteProperties {
class StatusRouteProperties {
var enabled = false
var endpoints: MutableList<EndpointMatch> = mutableListOf()
var blockedStatusEndpoints: MutableList<EndpointMatch> = mutableListOf()
var createVirtualCluster = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,22 @@ class RBACFilterFactory(

private fun createStatusRoutePolicy(statusRouteProperties: StatusRouteProperties): Map<String, Policy.Builder> {
return if (statusRouteProperties.enabled) {
val notRules = statusRouteProperties.blockedStatusEndpoints.map {
rBACFilterPermissions.createPathPermission(
path = it.path,
matchingType = it.matchingType
).build()
}
val permissions = statusRouteProperties.endpoints
.map {
rBACFilterPermissions.createPathPermission(
val permission = rBACFilterPermissions.createPathPermission(
path = it.path,
matchingType = it.matchingType
).build()
)
notRules.forEach { permission.setNotRule(it) }
permission.build()
}

val policy = Policy.newBuilder()
.addPrincipals(anyPrincipal)
.addPermissions(anyOf(permissions))
Expand Down Expand Up @@ -368,15 +377,18 @@ class RBACFilterFactory(
principal
)
)

OAuth.Policy.STRICT -> mergePrincipals(
listOf(
strictPolicyPrincipal,
principal
)
)

OAuth.Policy.ALLOW_MISSING_OR_FAILED -> {
principal
}

null -> {
principal
}
Expand Down

0 comments on commit 1a35778

Please sign in to comment.