Skip to content

Instantly share code, notes, and snippets.

Tatsiana888

Block or report user

Report or block Tatsiana888

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ConfigFilter.groovy
package config
import grails.util.Holders
import org.springframework.web.filter.GenericFilterBean
import javax.servlet.FilterChain
import javax.servlet.ServletException
import javax.servlet.ServletRequest
import javax.servlet.ServletResponse
import javax.servlet.http.HttpServletRequest
View application.yml
grails:
plugin:
springsecurity:
filterChain:
chainMap:
- pattern: /config/**
filters: configFilter
config:
View ConfigFilter.groovy
package config
import grails.util.Holders
import org.springframework.web.filter.GenericFilterBean
import javax.servlet.FilterChain
import javax.servlet.ServletException
import javax.servlet.ServletRequest
import javax.servlet.ServletResponse
import javax.servlet.http.HttpServletRequest
View ConfigFilter.groovy
package com.biid.config
import grails.util.Holders
import org.springframework.web.filter.GenericFilterBean
import javax.servlet.FilterChain
import javax.servlet.ServletException
import javax.servlet.ServletRequest
import javax.servlet.ServletResponse
import javax.servlet.http.HttpServletRequest
View resources.groovy
import config.ConfigFilter
beans = {
configFilter(ConfigFilter) {
urisToFilter = grailsApplication.config.getProperty(
"config.uri", List, [])
}
SpringSecurityUtils.registerFilter "configFilter",
SecurityFilterPosition.FORM_LOGIN_FILTER.order - 10
View application.yml
grails:
plugin:
springsecurity:
filterChain:
chainMap:
- pattern: /config/**
filters: configFilter //name of the custom filter
config:
View bootstrap.yml
spring:
application:
name: client-service
environments:
development:
spring:
cloud:
config:
authorization: authorizationTokenShouldBeHere // I used Spring Security Filter Chain for security.
View bootstrap.yml
spring:
application:
name: client-service
cloud:
config:
uri: http://localhost:8088/config
View build.gradle
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-config:1.3.0.RELEASE')
}
View ConfigurationController.groovy
// in bootstrap.yml is defined spring.cloud.config.server.prefix = /config and client microservice call to
// org.springframework.cloud.config.server.resource.ResourceController. So in UrlMappings we need write our
// mapping for call - get "/config/${serviceName}/${profile}"(controller: 'configuration', action: 'config')
def config(String serviceName, String profile) {
def propertySources = [:]
propertySources.name = "${serviceName}.properties"
propertySources.source = [:]
You can’t perform that action at this time.