aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-server-spring-boot
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-modules/kvision-server-spring-boot')
-rw-r--r--kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt16
1 files changed, 15 insertions, 1 deletions
diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt
index e87b95ff..328e384d 100644
--- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt
+++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt
@@ -30,6 +30,20 @@ import org.springframework.security.web.server.util.matcher.ServerWebExchangeMat
* A function to gather paths for spring security matchers.
*/
fun ServerHttpSecurity.AuthorizeExchangeSpec.serviceMatchers(vararg services: KVServiceManager<*>): ServerHttpSecurity.AuthorizeExchangeSpec.Access {
+ return this.matchers(*getServerWebExchangeMatcher(*services))
+}
+
+/**
+ * A function to gather paths for spring security matchers.
+ */
+fun serviceMatchers(vararg services: KVServiceManager<*>): ServerWebExchangeMatcher {
+ return ServerWebExchangeMatchers.matchers(*getServerWebExchangeMatcher(*services))
+}
+
+/**
+ * A function to gather paths for spring security matchers.
+ */
+fun getServerWebExchangeMatcher(vararg services: KVServiceManager<*>): Array<ServerWebExchangeMatcher> {
val matchers = mutableListOf<ServerWebExchangeMatcher>()
val getPaths = services.flatMap { it.getRequests.keys }.toTypedArray()
if (getPaths.isNotEmpty()) matchers.add(ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, *getPaths))
@@ -46,5 +60,5 @@ fun ServerHttpSecurity.AuthorizeExchangeSpec.serviceMatchers(vararg services: KV
*optionsPaths
)
)
- return this.matchers(*matchers.toTypedArray())
+ return matchers.toTypedArray()
}