1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package gaf3.demo.allinone
- import gaf3.core.cloud.GafCloudConfiguration
- import gaf3.core.gateway.GatewayController
- import gaf3.core.gateway.filter.factory.JwtParserGatewayFilterFactory
- import gaf3.core.jpa.GafJpaConfiguration
- import gaf3.core.services.GafCoreServicesConfiguration
- import gaf3.demo.services.AllServicesConfiguration
- import org.slf4j.LoggerFactory
- import org.springframework.boot.autoconfigure.SpringBootApplication
- import org.springframework.boot.runApplication
- import org.springframework.cloud.gateway.support.ServerWebExchangeUtils
- import org.springframework.cloud.openfeign.EnableFeignClients
- import org.springframework.context.annotation.Bean
- import org.springframework.context.annotation.Configuration
- import org.springframework.context.annotation.Import
- import org.springframework.core.annotation.Order
- import org.springframework.http.HttpStatus
- import org.springframework.stereotype.Controller
- import org.springframework.web.server.WebFilter
- @SpringBootApplication
- @Configuration
- @Controller
- @Import(GafCloudConfiguration::class, GafJpaConfiguration::class, AllServicesConfiguration::class)
- @EnableFeignClients
- class AllInOneApplication {
- @Bean
- fun statusControllerAdvice(): StatusControllerAdvice {
- return StatusControllerAdvice()
- }
- @Bean
- fun gatewayController(): GatewayController {
- return GatewayController()
- }
- @Bean
- @Order(-1)
- fun apiAccessFilter(): WebFilter {
- return WebFilter { exchange, chain ->
- log.debug("[ApiAccess] start...")
- val path = exchange.request.path.value()
- log.debug("[ApiAccess] path : {}", path)
- if(path.startsWith("/xms")
- || path.startsWith("/gaf")) {
- ServerWebExchangeUtils.setResponseStatus(exchange, HttpStatus.FORBIDDEN)
- exchange.response.setComplete()
- } else {
- chain.filter(exchange.mutate().build())
- }
- }
- }
- companion object {
- internal val log = LoggerFactory.getLogger(AllInOneApplication::class.java)
- }
- }
- fun main(args: Array<String>) {
- runApplication<AllInOneApplication>(*args)
- JwtParserGatewayFilterFactory.doInit()
- }
|