diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-10-22 12:08:19 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-10-22 12:08:19 +0200 |
commit | 5f109a1e92cd02df8b5588743ed141bc93542817 (patch) | |
tree | 2e7b12657fab70864049a8e9581e9dbe14d8974e | |
parent | 0eaecc43bdb0f87e5b8397cdb70508cdf4ac6311 (diff) | |
download | kvision-5f109a1e92cd02df8b5588743ed141bc93542817.tar.gz kvision-5f109a1e92cd02df8b5588743ed141bc93542817.tar.bz2 kvision-5f109a1e92cd02df8b5588743ed141bc93542817.zip |
Add helper functions for spring security.
-rw-r--r-- | kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt | 16 |
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() } |