-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π :: Api-v0.1.0-1
- Loading branch information
Showing
6 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
DuDoong-Api/src/main/java/band/gosrock/api/config/ServletFilterConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package band.gosrock.api.config; | ||
|
||
|
||
import javax.servlet.Filter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; | ||
import org.springframework.web.filter.ForwardedHeaderFilter; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
@Profile({"prod", "staging"}) | ||
public class ServletFilterConfig implements WebMvcConfigurer { | ||
|
||
private final HttpContentCacheFilter httpContentCacheFilter; | ||
private final ForwardedHeaderFilter forwardedHeaderFilter; | ||
|
||
@Bean | ||
public FilterRegistrationBean securityFilterChain( | ||
@Qualifier(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME) | ||
Filter securityFilter) { | ||
FilterRegistrationBean registration = new FilterRegistrationBean(securityFilter); | ||
registration.setOrder(Integer.MAX_VALUE - 2); | ||
registration.setName(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME); | ||
return registration; | ||
} | ||
|
||
@Bean | ||
public FilterRegistrationBean setForwardedHeaderFilterOrder() { | ||
FilterRegistrationBean registrationBean = new FilterRegistrationBean(); | ||
registrationBean.setFilter(forwardedHeaderFilter); | ||
registrationBean.setOrder(Integer.MAX_VALUE - 1); | ||
return registrationBean; | ||
} | ||
|
||
@Bean | ||
public FilterRegistrationBean setHttpContentCacheFilterOrder() { | ||
FilterRegistrationBean registrationBean = new FilterRegistrationBean(); | ||
registrationBean.setFilter(httpContentCacheFilter); | ||
registrationBean.setOrder(Integer.MAX_VALUE); | ||
return registrationBean; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters