rana01221727
@rana01221727
Reviews Written
-
Average Rating
-
Posts
Q&A
๋์ปค ์ปจํ ์ด๋๋ก ๋์ํ ๋ user-service์์ 403 forbidden ์ค๋ฅ ๊ด๋ จ
์ ๋ ๋์ปค๋ก ๋ฐฐํฌํ ๋ ๋์ปค ๋ด๋ถ ๋คํธ์ํฌ ip ์ง์ ์ํด์ฃผ๋๊น ๊ฒ์ดํธ์จ์ด์์ user-service ๋ก ๋ก๋ ๋ฐธ๋ฐ์ฑ์ด ์๋๋๋ผ๊ตฌ์์๋ ์ฝ๋์ฒ๋ผ ๋ด๋ถ ์์ดํผ๋ ์ถ๊ฐ ํด์ฃผ๋๊น ๋์ปค์์ ์ ์๋์ํ๊ธฐ ์์ํ์ต๋๋ค!์ดํ๋ง์ ํด๊ฒฐํ๊ฑฐ๋ผ,, ์ฒ์์ผ๋ก q&n์ฌ๋ ค๋ด ๋๋ค!@Bean protected SecurityFilterChain configure(HttpSecurity http) throws Exception {// ๊ถํ ๊ด๋ จ ๋ฉ์๋ // Configure AuthenticationManagerBuilder AuthenticationManagerBuilder authenticationManagerBuilder = http.getSharedObject(AuthenticationManagerBuilder.class); authenticationManagerBuilder.userDetailsService(userService).passwordEncoder(bCryptPasswordEncoder); AuthenticationManager authenticationManager = authenticationManagerBuilder.build(); http.csrf( (csrf) -> csrf.disable()); http.authorizeHttpRequests((authz) -> authz .requestMatchers(new AntPathRequestMatcher("/actuator/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/actuator/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/h2-console/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/users", "POST")).permitAll() .requestMatchers(new AntPathRequestMatcher("/welcome")).permitAll() .requestMatchers(new AntPathRequestMatcher("/health-check")).permitAll() .requestMatchers(new AntPathRequestMatcher("/swagger-ui/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/swagger-resources/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/v3/api-docs/**")).permitAll() // .requestMatchers("/**").access(this::hasIpAddress) // .requestMatchers("/**").access( // new WebExpressionAuthorizationManager( // "hasIpAddress('127.0.0.1') " + // "or hasIpAddress('192.168.45.83')"+ // "or hasIpAddress('172.17.0.0/32')")) // host pc ip address // .anyRequest().authenticated() // IP ์ฃผ์ ์ฒดํฌ์ ๋ก๊ทธ ์ฐ๊ธฐ .requestMatchers("/**").access((authentication, httpServletRequest) -> { // ํด๋ผ์ด์ธํธ IP ์ฃผ์ ๊ฐ์ ธ์ค๊ธฐ String clientIp = httpServletRequest.getRequest().getRemoteAddr(); log.info("Request from IP: {}", clientIp); // ๋ก๊ทธ ์ถ๋ ฅ // IP ์ฃผ์๊ฐ ํ์ฉ๋ ๋ฒ์ ๋ด์ธ์ง ํ์ธ if (clientIp.equals("127.0.0.1") || clientIp.equals("192.168.45.83") || clientIp.startsWith("172.18.")) { log.info("Access granted for IP: {}", clientIp); // ํ์ฉ๋ IP์ ๋ํ ๋ก๊ทธ return new AuthorizationDecision(true); // ์ธ์ฆ ํต๊ณผ } else { log.warn("Access denied for IP: {}", clientIp); // ํ์ฉ๋์ง ์์ IP์ ๋ํ ๋ก๊ทธ return new AuthorizationDecision(false); // ์ธ์ฆ ์คํจ } }) .anyRequest().authenticated() ) .formLogin(Customizer.withDefaults()) .authenticationManager(authenticationManager); // .sessionManagement((session) -> session // .sessionCreationPolicy(SessionCreationPolicy.STATELESS)); http.addFilter(getAuthenticationFilter(authenticationManager)); http.headers((headers) -> headers.frameOptions((frameOptions) -> frameOptions.sameOrigin())); return http.build(); }
- 1
- 2
- 299
Q&A
login ์์ฒญํ๋ฉด 404 ์๋ฌ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ ๋ ์ด๋ถ๋ถ ๊ถ๊ธํด์ ์ฐพ์๋ณด์๋๋ฐ์... ๋ค๋ฅธ userservice url์ ๋์ํ๊ธฐ ๋๋ฌธ์ gateway์ค์ ๋ฌธ์ ๋ ์๋ ๊ฒ ๊ฐ๊ธดํฉ๋๋ค..(๋ณต๋ถํด์ ๋์ผํ๊ฒ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์)์ , user-service ํฌํธ๋ก login ์ฐ๊ฒฐํ๋ฉด 200์ผ๋ก ์๋ต์ค๊ณ , ๊ฒ์ดํธ ์จ์ด ํตํด์ login ์ฐ๊ฒฐํ๋ฉด 404๊ฐ ๋ณ๋๋ฐ gateway filter - RemoveRequestHeader=Cookie๋ฅผ ์ฃผ์์ฒ๋ฆฌํ๋ ๋์ผํ๊ฒ 200์ผ๋ก ์๋ต์ด ์ค๋๋ผ๊ตฌ์... ์ ๊ทธ๋ฐ์ง๋ ์ ํํ ์ ๋ชจ๋ฅด๊ฒ ์ด์ ํน์ ์์๋ถ์๋ ํด์ ๋๊ธ ๋ฌ์๋ด ๋๋ค..
- 0
- 2
- 1.1K
Q&A
Deploy๋ฅผ ๊ณ์ ์คํจํฉ๋๋ค.
์ฌ๋ฌ๋ถ๋ค!! ๋ก๊ทธ์ ์๋ ๊ฒ์ฒ๋ผ eb-engine.log ๋ค์ด๋ฐ์์ ํ์ธํด๋ณด์ธ์! ์ docker-compose.yml ํ์ผ์ ports ๋์ด์ฐ๊ธฐ ์ํ๋ค๊ณ ๋์์ ์์ ํ๋๋ ๋ฌ์ต๋๋ค!(์ฌ์ง)(์ฌ์ง)
- 3
- 4
- 1.3K




