Skip to content

Commit b3ea416

Browse files
committed
minor refactor of config ccontroller and authorise consumer service in order to extend config roles with additional logic (includes filter)
1 parent 2e0c268 commit b3ea416

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/ConfigController.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class ConfigController(
1515
var authorisationConfig: AuthorisationConfig,
1616
) {
1717
@GetMapping("authorisation")
18-
fun getAuthorisation(): Map<String, List<String>> {
19-
return authorisationConfig.consumers
20-
}
18+
fun getAuthorisation(): Map<String, List<String>> =
19+
authorisationConfig.consumers.entries
20+
.map { it.key.replace(".include", "") to it.value }
21+
.toMap()
2122
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.roleconfig
2+
3+
class ConsumerConfig(
4+
val Consumer: String,
5+
val Includes: List<String>,
6+
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/internal/AuthoriseConsumerService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AuthoriseConsumerService {
1414
println("consumer: $consumer")
1515
println("requestedPath: $requestedPath")
1616

17-
consumerPathConfig[consumer]?.forEach {
17+
consumerPathConfig[consumer + ".include"]?.forEach {
1818
if (Regex(it).matches(requestedPath)) {
1919
return true
2020
}

0 commit comments

Comments
 (0)