수강이 제한됩니다.
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결스프링 시큐리티
SecurityContextHolder.clearContext()
는 최종 응답시 공통으로 실행되는데는모든 정보를 삭제하는게 아니라 현재 사용자의 로컬 쓰레드만 삭제하는것이죠 ?(다른 사용자들의 로그인 인증정보까지 삭제하면 안되니깐)제 생각이 맞는건가요?
- 미해결스프링 시큐리티
SecurityContext
SecurityContext 안에 null 이 저장된 상태라는 것은SecurityContext 안에 Anonymous AuthenticationToken 을 저장했다고 생각하면 일치한가요 ? 이 그림에서 SecurityContext 안에 null 이라는말을Anonymous AuthenticationToken 이 저장되어 있다고 대체가 가능하냐는 질문이였습니다 ! 감사합니다
- 미해결스프링 시큐리티
ConcurrentSessionFilter 매 요청 시 만료 여부 판단
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.ConcurrentSessionFilter는 매 요청 시 세션 만료 여부 즉 session.isExpired를 판단한다고 하셨습니다. 이 Filter를 설명해주실 때 사용자1, 2를 나눠서 설명해주셨는데 사용자1이 Logout 처리가 된 이후 사용자2가 요청을 보낼 때에도 사용자2의 세션 만료 여부를 체크하는지 궁금합니다.
- 미해결스프링 시큐리티
인가 프로세스 DB 연동 웹 계층 구현 - 2) 관리자 시스템 - 권한 도메인, 서비스, 리포지토리 구성 질문
안녕하세요 강사님. 인가 프로세스 DB 연동 웹 계층 구현 섹션에서 "2) 관리자 시스템 - 권한 도메인, 서비스, 리포지토리 구성" 강의 수강 중 궁금한 점이 있어 질문 드립니다. Resources 테이블과 연관된 메뉴인 "리소스 관리"에서 순서 필드는 어떤 용도로 사용될까요?단순히 리소스 데이터를 조회할 때 order by 를 통한 정렬을 위한 필드인지, 다른 용도로도 사용되는지 궁금합니다.
- 미해결스프링 시큐리티
세션 클러스터링을 한 이후 동시로그인 제한이 안되는데요
안녕하십니까강사님 강의를 듣고 여기 커뮤니티에 나름 최신 소스 받아서 시큐리티 구현중인데요이중화 환경에서 톰캣을 통해 세션을 공유하는것까지는 되었는데요동시 로그인제한이 안되는데 추가적인 설정을 무엇을 해야할지 모르겠는데도움좀 받을수 있을까요? 스프링 2.7.10스프링 시큐리티 5.7.7 // 시큐리티 설정부분@Slf4j @RequiredArgsConstructor @EnableWebSecurity @Configuration public class WebSecurityConfig { private final MemberRepository memberRepository; @Bean public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception { // 경로 설정 http. authorizeRequests() .antMatchers().permitAll() .anyRequest().authenticated() ; // 동시 로그인 제한을 설정 http .sessionManagement() .maximumSessions(1) .expiredUrl("/error/expired") .and().sessionCreationPolicy(SessionCreationPolicy.ALWAYS) ; http.logout() .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) .invalidateHttpSession(true) .clearAuthentication(true) .deleteCookies("JSESSIONID") ; // 로그인... 인증 권한 체크... // 로그인 return http.build(); } /** * 여기에 Authentication 을 설정하도록 */ @Bean AuthenticationManager authenticationManager(AuthenticationConfiguration authConfiguration) throws Exception { return authConfiguration.getAuthenticationManager(); } @Bean public static PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } } // 톰캣 클러스터링 부분 (https://happy-jjang-a.tistory.com/155를 참조했습니다.)@Configuration public class TomcatClusterConfig implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> { @Override public void customize(final TomcatServletWebServerFactory factory) { factory.addContextCustomizers(new TomcatClusterContextCustomizer()); } } class TomcatClusterContextCustomizer implements TomcatContextCustomizer { @Override public void customize(final Context context) { context.setDistributable(true); DeltaManager manager = new DeltaManager(); manager.setExpireSessionsOnShutdown(false); manager.setNotifyListenersOnReplication(true); context.setManager(manager); configureCluster((Engine) context.getParent().getParent()); } private void configureCluster(Engine engine) { //cluster SimpleTcpCluster cluster = new SimpleTcpCluster(); cluster.setChannelSendOptions(6); //channel GroupChannel channel = new GroupChannel(); //membership setting McastService mcastService = new McastService(); mcastService.setAddress("228.0.0.4"); mcastService.setPort(45564); // TCP&UDP port 오픈 필요 mcastService.setFrequency(500); mcastService.setDropTime(3000); channel.setMembershipService(mcastService); //receiver NioReceiver receiver = new NioReceiver(); receiver.setAddress("auto"); receiver.setMaxThreads(6); receiver.setPort(5000); // TCP port 오픈 필요 channel.setChannelReceiver(receiver); //sender ReplicationTransmitter sender = new ReplicationTransmitter(); sender.setTransport(new PooledParallelSender()); channel.setChannelSender(sender); //interceptor channel.addInterceptor(new TcpPingInterceptor()); channel.addInterceptor(new TcpFailureDetector()); channel.addInterceptor(new MessageDispatchInterceptor()); cluster.addValve(new ReplicationValve()); cluster.addValve(new JvmRouteBinderValve()); cluster.setChannel(channel); cluster.addClusterListener(new ClusterSessionListener()); engine.setCluster(cluster); } }
- 미해결스프링 시큐리티
강의 ppt 그림 질문입니다.
강의안 ppt를 보면서 진행중인데그림이 상이해서 헷갈려 질문드립니다.67번 슬라이드에서 인증 결과를 저정하는 그림에서는ThreadLocal > SecurityContextHolder > SecurityContext 처럼 표기되어있는데74번 슬라이드에서는SecurityContextHolder > ThreadLocal > SecurityContext 처럼 표기되어있어서 혼란이오는데 어느 슬라이드의 그림이 맞는건가요?
- 해결됨스프링 시큐리티
Ajax Custom DSLs - customConfigurerAjax(HttpSecurity http) 에서 loginProcessingUrl(/api/login) 처리할 때 null
customConfigurerAjax(HttpSecurity http) 에서 loginProcessingUrl("/api/login") 처리할 때private void customConfigurerAjax(HttpSecurity http) throws Exception { http .apply(new AjaxLoginConfigurer<>()) .successHandlerAjax(ajaxAuthenticationSuccessHandler()) .failureHandlerAjax(ajaxAuthenticationFailureHandler()) .setAuthenticationManager(authenticationManager(authenticationConfiguration)) .loginProcessingUrl("/api/login") ; }AbstractAuthenticationFilerConfigurer 클래스의 loginProcessingUrl을 호출하던데 여기서 authFilter 가 null 이어서 예외가 발생하는데public T loginProcessingUrl(String loginProcessingUrl) { this.loginProcessingUrl = loginProcessingUrl; this.authFilter.setRequiresAuthenticationRequestMatcher(createLoginProcessingUrlMatcher(loginProcessingUrl)); return getSelf(); }어떻게 해결해야할지 모르겠습니다. ㅠㅠhttps://github.com/pdh9311/core-spring-security추가로 ajax security 시작한 이후로 localhost:8080 으로 접속하니까 화면이 안나오고 401 에러가 발생하는데 어디가 문제인지 모르겠습니다. ㅠㅠ
- 미해결스프링 시큐리티
세션 삭제
안녕하세요 시큐리티 이번에 처음 공부하게 되었는데 강의가 너무 좋네요 질문은임의로 세션을 삭제하면 다시 인증을 받아야 하는데SecurityContext에는 인증 정보가 들어있지 않나요 ?
- 해결됨스프링 시큐리티
4-2 강의에서 소스 확인 부탁드립니다.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 4-2 강의를 보고 있는데 해당 이전 강의에서는 authenticationEntryPoint, LoginUrlAuthenticationEntryPoint, FormAccessDeniedHandler 에 대한 설명 없었는데 4-2 강의에서는 소스에 해당 내용으로 바뀌어 있습니다. 누락된 것인지 아니면 제가 못 찾는 것인지 확인 부탁드립니다.
- 미해결스프링 시큐리티
스프링 시큐리티 멀티 로그인 관련 질문드립니다.
@Configuration @EnableWebSecurity public class SecurityConfig { @Bean public SecurityFilterChain adminfilterChain(HttpSecurity http) throws Exception { http.authorizeRequests() .requestMatchers("/admin/**").hasRole("ADMIN") .anyRequest().authenticated() .and() .httpBasic() ; return http.build(); } @Bean static final public InMemoryUserDetailsManager kk() { //DB연동을 안할 경우, 테스트 용으로 하는 것이다. UserDetails user = User.withDefaultPasswordEncoder() .username("user") .password("1111") .roles("USER") .build(); UserDetails admin = User.withDefaultPasswordEncoder() .username("admin") .password("1111") .roles("ADMIN") .build(); return new InMemoryUserDetailsManager(user, admin); } } @Configuration class config2 { @Bean public SecurityFilterChain userfilterChain(HttpSecurity http) throws Exception { http.authorizeRequests() .requestMatchers("/user/**").hasRole("USER") .anyRequest().authenticated() .and() .formLogin() ; return http.build(); } } 스프링 시큐리티가 최근부터 Bean으로 설정을 해야하며, 강의에서 나온 antmatchers()와 같은 함수명이 바뀌어 구글링을 하며 만들어보고자 도전해보고 있습니다. 해당 강의 중 "다중 보안 설정"에 대한 내용과 유사하게 구현해보고자 하였으나, 마음처럼 되지 않아 질문을 남김니다.제가 구현하고 싶은 형태는 localhost:8080/user >> formLogin() 페이지로 이동하게 되고, 이와 다르게 localhost:8080/admin >> httpBasic() 페이지로 이동하도록 구현하고자 합니다. 하지만, 생각과는 다르게 admin 경로가 처리가 안되는 것을 확인하였습니다. 이에 대해 조언을 구하고자 합니다.
- 미해결스프링 시큐리티
SessionManagementFilter 동작여부
선생님 안녕하세요.질좋은 강의로 열심히 공부중에 질문이 생겨 글 남겨봅니다. 현재 ajaxLoginProcessingFilter 및 AjaxAuthenticationProvider 만들어서 http.addFilterBefore(ajaxLoginProcessingFilter(), UsernamePasswordAuthenticationFilter.class); 와 같이 설정해서 사용중인데 SessionManagementFilter까지 작동을 안하지는 sessionManagement 기능이 작동을 안합니다. 혹시 커스텀 객체들을 사용하면서 세션 제어를 할 수 있는 방법이 있을까요?
- 미해결스프링 시큐리티
질문있어요 ~!
@Slf4jpublic class FormAuthenticationProvider implements AuthenticationProvider { @Autowired private UserDetailsService userDetailsService; private PasswordEncoder passwordEncoder; public FormAuthenticationProvider(PasswordEncoder passwordEncoder) { this.passwordEncoder = passwordEncoder; } @Override @Transactional public Authentication authenticate(Authentication authentication) throws AuthenticationException { ...} @Autowired로 (private UserDetailsService userDetailsService 를)의존성 주입해서 쓰고 있는 FormAuthenticationProvider class는 왜 !? @Component annotation이 없는 거죠?!?!의존성 주입해서 사용하려는 class는 같은 spring에서 관리해야 하는거 아닌가요?!?!
- 미해결스프링 시큐리티
formLogin - deprecated..
그래서 해당 강의에서 config 메서드를 제가 구글링 해보면서 해봤는데 인증을 아에 거치질 않네요.. 아래 메서드 한 번 확인해주시고 틀린 부분 있으면 말씀 부탁드립니다..추가로 앞으로 계속 코드가 달라질 거 같은데 이런 부분은 어떻게 해결해야 하는지.. 계속 구글링 해가면서 해야하는건가요..? @Beanpublic SecurityFilterChain filterChain(HttpSecurity http) throws Exception {http.authorizeRequests(authorizeRequests ->authorizeRequests.anyRequest().authenticated()).httpBasic(withDefaults()).formLogin(formLogin ->formLogin.loginPage("/loginPage").defaultSuccessUrl("/").usernameParameter("userId").passwordParameter("passwd").loginProcessingUrl("/login_proc").successHandler(new AuthenticationSuccessHandler() {@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {System.out.println("authentication : "+ authentication.getName());response.sendRedirect("/");}}).failureHandler(new AuthenticationFailureHandler() {@Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {System.out.println("exception : "+ exception.getMessage());response.sendRedirect("/login");}}).permitAll());return http.build();}
- 미해결스프링 시큐리티
요청을 확인할 수 있는 방법이 있을까요??
안녕하세요 선생님 좋은강의 정말 감사드립니다!선생님 혹시 사용자의 어떤 request에 의해서 CustomAccessDeniedHandler 여기로 오게 되는지 디버그를 이용해서 확인하고 싶다면 어떤 필터를 확인하면 알 수 있을까요??
- 미해결스프링 시큐리티
AuthenticationProvider 등록 관해서 질문이 있습니다.
안녕하세요 선생님.스프링 부트 2.7.x 버전에서 하기 스크린샷과 같이 설정 하였을때 인증프로바이더가 중복으로 등록 되는 문제가 발생하였습니다. 하기와 같이 인증매니저를 설정을 수정하니인증프로바이더가 정상적으로 1개 등록되었습니다.왜 이런 일이 발생하는지 잘 이해가 되지 않아서요..선생님께서 이유를 아신다면 설명해주시면 감사하겠습니다.
- 미해결스프링 시큐리티
스프링부트 dependencies 필요하신분
//타임리프 implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' // 스프링 시큐리티 implementation 'org.springframework.boot:spring-boot-starter-security' //jpa implementation 'org.springframework.boot:spring-boot-starter-data-jpa' //web implementation 'org.springframework.boot:spring-boot-starter-web' //postgresql 드라이버 runtimeOnly 'org.postgresql:postgresql' //모델 mapper implementation 'org.modelmapper:modelmapper:3.1.1' // lombok compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' // devtools developmentOnly 'org.springframework.boot:spring-boot-devtools' testImplementation 'org.springframework.boot:spring-boot-starter-test'
- 미해결스프링 시큐리티
authenticationEntryPoint 에서 sendRedirect말고 formLogin을 다시 띄워주는 방법
제목과 일치합니다.response.sendredirect하지않고 security에서 제공하는 formLogin을 띄워주려면 어떻게 코드를 작성 해야 하나요?
- 미해결스프링 시큐리티
9:03쯤에 프로그램 실행 후 갑자기 브레이크 포인트가 잡히는 이유
브레이킹 포인트 잡는것도 생략하시고, 이건 강사님께서 매번 그러시는것 같고,제가 여쭤보고싶은건 지금 form에다가 아이디와 패스워드를 입력하고 로그인 버튼 누른과정을 생략하시고 브레이킹 포인트가 잡힌부분이 갑자기 보이게끔 편집을 하신건가요??
- 미해결스프링 시큐리티
deprecate된 authorizeRequests와 access인자 관련
강의를 따라가다 antMatchers와access 관련해서 도움이 되고자 글을 남깁니다.(1) access스프링 시큐리티에서 authorizeRequests가 deprecate되면서 hasRole('ADMIN') or hasRole('SYS')에 인자로 문자열만 받을 수 있게 되었습니다.이로 인해 특정 경로에 대한 인가를 2개 이상의 role에 주고 싶을시 hasAnyRole을 사용해야 합니다.(2) antMatchersdeprecate된 authorizeRequests 대신 스프링에서 사용을 권장하는 authorizeHttpRequests를 사용한 사용자별 인가를 설정하는 코드입니다. // 스프링 시큐리티 5.4에 맞춘 강의 예제 http .authorizeHttpRequests(authorizeHttpRequests -> authorizeHttpRequests .requestMatchers("/user").hasRole("USER") .requestMatchers("/admin/pay").hasRole("ADMIN") .requestMatchers("/admin/**").hasAnyRole("ADMIN", "SYS") .anyRequest().authenticated());
- 미해결스프링 시큐리티
UrlSecurityMetadataSource 클래스의 reload() 메서드 질문이 있습니다!
좋은 강의 잘 보고 있습니다. 감사합니다.섹션 5. "실전프로젝트 - 인가 프로세스 DB 연동 웹 계층 구현"의 "6) 웹 기반 인가처리 실시간 반영하기"강의를 보다 의문이 생겨 질문을 남기게 되었습니다.UrlSecurityMetadataSource 클래스에 다음과 같은 reload() 함수가 있습니다.여기서 "securityResourceService.getResourceList()"의 반환값과 "requestMap"의 타입이 똑같으니requestMap = securityResourceService.getResourceList();으로 바로 객체를 할당하면 될 것 같았는데, Iterator를 사용하여 put 하시는 것이 성능상의 문제나 다른 이슈가 있어서 이렇게 작성을 하신건지 의문이 들었습니다.새로운 List를 바로 할당하지 않고, 기존 List 객체를 유지하신 이유가 궁금합니다!감사합니다.// UrlSecurityMetadataSource 클래스 public void reload() { LinkedHashMap<RequestMatcher, List<ConfigAttribute>> reloadedMap = securityResourceService.getResourceList(); Iterator<Map.Entry<RequestMatcher, List<ConfigAttribute>>> iterator = reloadedMap.entrySet().iterator(); requestMap.clear(); while (iterator.hasNext()) { Map.Entry<RequestMatcher, List<ConfigAttribute>> entry = iterator.next(); requestMap.put(entry.getKey(), entry.getValue()); } }