수강이 제한됩니다.
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결스프링 시큐리티
master branch와 강좌
안녕하세요. 제가 아직 강의를 수강 중이라 모르는 점이 있어 질문을 드립니다. https://github.com/onjsdnjs/corespringsecurity 의 master branch 코드들은 '섹션 6. 실전프로젝트 - 인가 프로세스 DB 연동 서비스 계층 구현' 과 그 이전 강의의 학습 내용들을 담고 있는 것인가요? 읽어주셔서 감사합니다.
- 미해결스프링 시큐리티
FilterChainProxy 질문 드립니다.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. "springSecurityFilterChain" 이름, FilterChainProxy 빈 이름 라는 뜻이 이렇게 되는게 맞나요??
- 미해결스프링 시큐리티
로그아웃 커스텀 처리
아래처럼 securityConfig에 커스텀 로그아웃 경로에 대해 어떠한 permitAll 같은 권한 설정을 하지 않았는데도 제가 작성한 컨트롤러까지 잘 들어가서 로그아웃처리가 됩니다. 왜 허용이 되어있는거죠? 별도로 로그아웃 경로에 대해 permitAll 하지 않으면 접근이 막혀야 하는 것 아닌가요? @Configuration@EnableWebSecurity@RequiredArgsConstructorpublic class SecurityConfig extends WebSecurityConfigurerAdapter { private final UserDetailsService userDetailsService; @Bean public AuthenticationProvider authenticationProvider() { return new FormAuthenticationProvider(userDetailsService, passwordEncoder()); } @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(authenticationProvider()); } @Bean public PasswordEncoder passwordEncoder() { return PasswordEncoderFactories.createDelegatingPasswordEncoder(); } @Override public void configure(WebSecurity web) throws Exception { web.ignoring().requestMatchers(PathRequest.toStaticResources().atCommonLocations()); } @Override protected void configure(final HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/users").permitAll() .antMatchers("/myPage").hasRole("USER") .antMatchers("/messages").hasRole("MANAGER") .antMatchers("/config").hasRole("ADMIN") .anyRequest().authenticated() .and() .formLogin() .loginPage("/login") .loginProcessingUrl("/login_proc") .defaultSuccessUrl("/") .permitAll(); }}
- 미해결스프링 시큐리티
@EnableGlobalAuthentication 관련 질문입니다.
@EnableWebSecurity 어노테이션 안에 @Configuration 어노테이션이 포함되어 있는데 그러면@EnableWebSecurity이 있는 클래스에 @Configuration 를 안붙여도 괜찮을까요?
- 미해결스프링 시큐리티
Refresh token
안녕하세요. 1) 프론트엔드에서 받은 JWT가 기한이 만료되었을 때, JWT를 새로 발급받으려 한다면 Filter를 사용해서 처리하는 게 맞는 방법일까요? 2) 제가 아직 수강을 많이 안 한 상태인데, 혹시 수업 중에 이에 대한 설명이 있는지요? 읽어주셔서 감사합니다.
- 미해결스프링 시큐리티
몇 가지 문의사항
안녕하세요, 선생님. 최근에 수강을 시작한 학생입니다. 좋은 강의 잘 듣고 있습니다. 질문드리고 싶은 것이 있는데요. 1) 수업에서 작성하시는 코드는 Github에 올려 주신다는 수강평을 본 것 같은데, 혹시 주소를 알 수 있을까요? 2) Oauth2를 Spring Security와 연동해서 사용한다면, Resource Server(예: 네이버와 같은 서비스 업체의 서버)에서 받은 토큰을 시큐리티 컨텍스트에 넣어서 활용하는 것인가요? 강의에서는 이에 대해서 다루지 않는 것 같은데, 혹시 Oauth2에 대한 강의도 만들어 주실 수 있나요? 아울러 이와 관련해 추천해 주실 자료가 있을까요? 읽어주셔서 감사합니다.
- 미해결스프링 시큐리티
rememberMeParameter는 어떤건가여??
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. rememberMeParameter 가 쿠키 명인줄 알았는데, remember로 변경해도 쿠키명은 remember-me로 나오고 문제없이 동작하길래 파라미터가 어떤건지 궁금합니다.
- 미해결스프링 시큐리티
SecurityConfig의 rememberMe 질문입니다.
의존성 주입을 받음에도 불구하고 Remember me on this computer. 체크박스를 클릭하고 로그인시 아래와 같은 에러가 발생합니다. SecurityConfig의 코드는 아래와 같습니다. @Autowired도 해봤지만 결과가 같고, 체크박스 표시를 하지 않으면 로그인이 됩니다. 뭐가 문제인지 잘 모르겠습니다 ㅠㅠ package spring.security;import lombok.RequiredArgsConstructor;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Configuration;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;import org.springframework.security.core.Authentication;import org.springframework.security.core.AuthenticationException;import org.springframework.security.core.userdetails.UserDetailsService;import org.springframework.security.web.authentication.AuthenticationFailureHandler;import org.springframework.security.web.authentication.AuthenticationSuccessHandler;import org.springframework.security.web.authentication.logout.LogoutHandler;import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.IOException;@Configuration@EnableWebSecurity@RequiredArgsConstructorpublic class SecurityConfig extends WebSecurityConfigurerAdapter { private final UserDetailsService userDetailsService; @Override protected void configure(HttpSecurity http) throws Exception { // 인가 http.authorizeRequests() .anyRequest() .authenticated(); // 인증 // FormLogin 인증 방식 api http.formLogin() .defaultSuccessUrl("/") .failureUrl("/login") .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"); } }) .and() .logout() .logoutSuccessUrl("/login") .addLogoutHandler(new LogoutHandler() { @Override public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { HttpSession session = request.getSession(); session.invalidate();; } }) .logoutSuccessHandler(new LogoutSuccessHandler() { @Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { response.sendRedirect("/login"); } }) .and() .rememberMe() .tokenValiditySeconds(3600) // default : 14일 .userDetailsService(userDetailsService()); }}
- 해결됨스프링 시큐리티
Role 인식 질문입니다.
DB에는 ROLE_AMDIN 이런식으로 ROLE_ 을 붙혔는데 CONFIG에서는 ADMIN 만 되어있는데 ROLE_ <- 알아서 생략하는건가요?
- 해결됨스프링 시큐리티
안녕하세요
좋은 강의 감사히 보고있습니다. WebSecurityConfigurerAdpater 를 상속받고 configure(HttpSecurity http) 메서드를 재정의 할대 파트1에서는 http 를 여러개 생성하는 경우가 있었는데 하나의 http에 다 붙힐려니까 안붙는것들이 있더라구요. 설정에 순서가 있어서 순서가 다르면 뒤에서 호출하지 못하는것으로 생각했는데 제 생각이 맞는지 그리고 순서를 맞춰서 하나의 http만 재정의하는것과 여러개의 http를 생성해서 각 설정을 걸어줄때의 차이점이 궁금합니다.
- 해결됨스프링 시큐리티
Anonymous 유저도 Authentication 객체가 있는데 AuthenticationException이 발생할 수 있나요?
안녕하세요 강의 감사히 잘 보고 있습니다. SpringSecurity를 자세히 설명해주는 강의가 이만한게 없네요 ㅎㅎ 다름이 아니라 FilterSecurityInterceptor 에서 Authentication 객체가 null인 경우 AuthenticationExceptin이 발생한다고 해서 궁금한점이 생겼습니다. Anomumous 유저도 Authentication 객체가 생긴다면 결국 SpringSecurity에서는 Authentication 객체가 null 경우는 존재하지 않게 되는 것 아닌가 해서요. 어떻게 AuthenticationException이 발생할 수 있나요?
- 해결됨스프링 시큐리티
ConcurrentSessionControlAuthenticationStrategy는 어떻게 같은 user를 인증한 서로 다른 세션이 있는지, 또 그 수가 얼마나 있는지 알 수 있는 것인가요?
ConcurrentSessionControlAuthenticationStrategy는 어떻게 같은 user를 인증한 서로 다른 세션이 있는지, 또 그 수가 얼마나 있는지 알 수 있는 것인가요? 유저가 인증 요청을 할 때마다, 해당 유저와 동일한 유저의 인증된 세션이 존재하는지, 서버에 있는 모든 세션들을 순회하면서 Authentication객체를 열어보고, 거기에 있는 principal 객체의 username이 현재 인증 요청을 한 username과 일치하는지 항상 확인하는 것인가요? 그럼 굉장히 느리고 비효율적일 것 같고 그렇게 구현되지는 않았을 것 같은데, 그럼 어떻게 구현되어 있는 것인지 궁금합니다.
- 미해결스프링 시큐리티
Controller에 Authentication타입 파라미터를 주입하는 HandlerMethodArgumentResolver의 구현체가 무엇인가요?
안녕하세요 강의 잘 보고 있습니다. 다름이 아니라 제가 Spring Security로 예제를 만들어보고 있었습니다. 그런데 익명 사용자인 경우 컨트롤러의 Authentication 파라미터로 주입되지 않더라고요. @GetMapping("/authentication")@ResponseBodypublic String authenticationTest(Authentication authentication) 예를 들면 컨트롤러에 이런 함수를 만들면 일반적인 인증 사용자인 경우에는 Authentication 객체가 주입되지만 익명 사용자인 경우에는 Authentication객체가 주입되지 않았습니다. 이유를 찾아보니 표준 서블릿 API 스펙을 따르기 위해서라고 합니다. 다른 응용 프로그램이 spring security의 구현에 의지하지 않도록 하기 위해서고 굳이 익명 사용자인 경우에도Authentication 객체를 주입받고 싶으면 spring security의 getContext().getAuthentication() api를 사용하면 된다고 합니다. 그래서 이유에 대해서는 제가 이렇게 찾아서 궁금한 부분은 아닌데요. https://github.com/spring-projects/spring-security/issues/4011 이 링크에 가보시면 내부적으로 왜 Authentication 객체가 익명 사용자인 경우 컨트롤러에 주입이 안 되는지 나온 부분이 있습니다. SecurityContextHolderAwareRequestWrapper이 객체에 아래와 같은 부분이 있다는 것입니다. private Authentication getAuthentication() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (!trustResolver.isAnonymous(auth)) { return auth; } return null; } SecurityContextHolderAwareRequestWrapper 객체는 HttpServletRequest가 RequestCacheAwareFilter를 통과하면서 재구성된 request 객체라고 합니다. 그래서 SecurityContextHolderAwareRequestWrapper객체에서 getAuthentication()라는 함수를 호출해서 Controller의 Authentication 타입 파라미터에 주입해주는 Security전용 HandlerMethodArgumentResolver가 있을 것 같은데, 제가 아무리 찾아봐도 정확히 이런 Resolver가 있다는 글을 못 찾겠더라고요.혹시 아신다면 알려주시면 감사하겠습니다.
- 미해결스프링 시큐리티
마지막에 AuthenticationManager에게 다시 인증처리를 맡기는 이유가 무엇인가요?
remember-me 토큰을 비교해서 user 계정이 존재하면 그것으로 인증처리가 된 것으로 생각되는데 마지막에 RememberMeAuthenticationToken을 AuthenticationManager에게 넘겨서 인증처리를 또 하는 이유가 무엇인가요?
- 미해결스프링 시큐리티
inMemoryAuthentication 관련 질문
강의를 처음부터 들으면서 코드를 누적해서 작성하고 있었습니다. 이번강의에서 auth.inMemoryAuthentication().withUser()메서드를 3번 사용하여 각각 user, admin, sys이름을 가진 계정을 생성하셨는데, admin, sys 계정으로 접속이 안되길래 알아보니 ppt 30페이지 내용의 http.rememeberMe().userDetailsSevice(userDetailsService)코드가 문제였던것 같습니다. 해당 코드를 삭제하니 강의 내용처럼 정상적으로 작동합니다. 여기서 드리고싶은 질문은, 인메모리 상에서 인증객체을 생성하는 것과 UserDetailsSevice는 같이 사용할 수 없는 건가요?
- 미해결스프링 시큐리티
인가 질문입니다.
안녕하세요 강사님, 강사님 강의를 수강한 덕분에 액세스 토큰과 리프레시 토큰을 사용한 인증, 인가를 구현할 수 있었습니다. 개인 앱 프로젝트를 진행하고 있는 중에 각각의 회원마다 자동으로 매 규칙적인 시간마다 REST API를 실행할 수 있도록 @Scheduled 사용했습니다. 저 어노테이션을 사용할 때는 인가가 필요한 지 궁금합니다. 사용자가 앱을 사용하지 않을 때도 REST API가 실행되야 하는데 인가로 사용한 antMatcher로 설정하지 않으면 될까요? 항상 좋은 강의 감사합니다.
- 해결됨스프링 시큐리티
안녕하세요. 강사님 문의드릴게 있습니다.
안녕하세요 강사님. 완강 후 현재 2회차 수강중에 있습니다. 몇 가지 여쭤볼게 있어서 이렇게 문의드립니다. 제가 공부한 내용을 정리하는 개인 블로그가 있는데 출처를 남기고 강사님의 강의 내용을 토대로 공부한 내용을 정리해서 포스팅해도 괜찮을까요? 혹시 괜찮으시다면 강의때 사용하셨던 ppt 의 이미지 같은 부분들을 인용해서 정리해도 괜찮으실까요? 출처는 반드시 남기겠습니다! 좋은 강의 감사드립니다.
- 해결됨스프링 시큐리티
로그인 후 로그인 페이지 접속
로그인 후 로그인 페이지에 접속되는데 이건 제어하는 방법이 없나요?
- 미해결스프링 시큐리티
UserDetailsService에 대해 질문이 있습니다
안녕하세요 스프링시큐리티 아키텍처를 공부하는데 엄청난 도움을 받고 있습니다. UserDetailsService를 구현하는 구현체를 만들면서 궁금증이 생겼습니다. username과 password를 검증하는 Provider가 UserDetailsService를 의존해서 loadUserByUsername()메서드를 통해서 DB에 있는 사용자 정보를 가져와서 검증을 하게 되는데 만약 Provider에서 UserDetailsService의 구현체가 아닌 그냥 커스텀한 UserService를 의존해서 UserDetails타입이 아닌 커스텀한 User를 가져와 검증을 해도 상관없는지 궁금합니다. 실제로 그렇게 해봤을때 인증이 되긴 하는데 다른 사이드 이펙트가 발생할 수 있는지 궁금합니다.
- 미해결스프링 시큐리티
모바일 앱 만들 때의 api에도 적용가능한가요?
선생님 안녕하세요! 혹시 Form 방식이 모바일앱에도 적용 가능한가요? 수강설명에는 '다수의 웹에서 Form 인증 방식을 사용'이라고 나타나있어서요. 혹시 브라우저 환경에서만 적용 가능한 방식인지 궁금합니다. 원래는 JWT 방식으로 구현하려고 했는데, 이 강의를 보면서 Form 방식으로 구현해보려고 합니다!