Commit bfe2431a authored by gkhan's avatar gkhan

security changes added

parent 0d2603e2
package com.safeway.pricing.config;
import com.safeway.pricing.handler.PricingHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
import org.springframework.security.authentication.ReactiveAuthenticationManager;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
import org.springframework.security.web.server.authentication.WebFilterChainServerAuthenticationSuccessHandler;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
import reactor.ipc.netty.NettyContext;
import reactor.ipc.netty.http.server.HttpServer;
@EnableWebFluxSecurity
public class SecurityConfig {
@Autowired
PricingHandler pricingHandler;
@Bean
public SecurityWebFilterChain configure( ServerHttpSecurity http ) throws Exception {
http.csrf().disable().authorizeExchange()
.pathMatchers(HttpMethod.POST,"/oauth2/**", "/login/**").permitAll()
//.hasAnyRole()
.pathMatchers("/oauth2/**", "/login/**").permitAll()
.pathMatchers(HttpMethod.GET,"/getDefaultFilterDetails").permitAll()
.anyExchange().authenticated().and().oauth2Login()
.authenticationSuccessHandler(new WebFilterChainServerAuthenticationSuccessHandler());
.pathMatchers(HttpMethod.GET,"/api/**")
.authenticated().and().oauth2Login();
return http.build();
}
......
......@@ -19,7 +19,8 @@ public class AppRouterConfig {
public RouterFunction<ServerResponse> routerFunction(){
return RouterFunctions.route()
.GET("/getDefaultFilterDetails",pricingHandler::getDefaultFilterDetails)
.GET("/getCRCDetails",pricingHandler::getCRCDetails)
.GET("/api/getCRCDetails",pricingHandler::getCRCDetails)
.GET("/api/getCRCDetails2",pricingHandler::getCRCDetails)
.build();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment