inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

CSRF 세션클러스터링

미해결

스프링 시큐리티

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 서버가 이중화되어 있고 웹서버와 WAS 사이 클러스터링은 처리가 되어 있습니다. 서버 A에서 로그인 후 서버 B에서 로그인이 잘 되는것을 확인했습니다. 크롬 개발자 도구에서 POST방식으로 호출 시 헤더에 CSRF 토큰이 존재하는 것 까진 확인하였는데 401에러가 발생합니다. 오류 원인 예상가는 부분은 CSRF 토큰이 각 서버에 공유되지 않아 발생하는게 아닌가 싶습니다... 혹시 이 상황을 어떻게 해결해야할까요,,,

  • java
  • spring-boot
  • spring-security
reyeol 댓글 1 좋아요 0 조회수 702

memProfile 이름을 UUID로 주기

미해결

스프링 프레임워크는 내 손에 [스프1탄]

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 강사님 혹시 newProfile변수에 UUID값을 줘도 되나요?

  • jsp
  • spring
  • mvc
  • spring-security
이동영 댓글 1 좋아요 0 조회수 473

필터 동작 순서에 따라 login결과가 달라지는 이유

미해결

스프링부트 시큐리티 & JWT 강의

안녕하세요. 선생님 좋은 강의 제공해주셔서 감사합니다. 선생님 덕분에 거의 마지막 강의까지 진행하고 있습니다. 그러다가 25강에서 '/login'요청에서 response헤더에 토큰이 포함되었음에도 불구하고 자꾸 404에러가 뜨는 것을 확인하였습니다. 확인 결과 SecurityConfig에서 아래의 코드를 넣느냐 빼느냐에 따라서 결과가 달라지는데요. 여기서 2가지 이해가 가지 않는 점이 생겼습니다. 필터 동작 순서를 바꾼다고 해도 결국 그 뒤에 FiterChain이 동작하기 때문에 MyFilter3에서 정상적으로 처리하고 FilterChain으로 넘어갔다면 '/login' 요청도 제대로 처리되어야 하는거 아닌가요? @Bean SecurityFilterChain filterChain(HttpSecurity http) throws Exception { // http.addFilterBefore(new MyFilter3(), SecurityContextPersistenceFilter.class); 선생님께서 포스트맨으로 로그인 시도하신 것을 보면 password가 일치하지 않을 경우 401 에러가 뜨던데 저 같은 경우에는 password가 일치하든 불일치 하든 상관없이 http body에는 공백이 뜨고 헤더에 토큰이 반환되느냐 마느냐의 차이만 있고 콘솔에 아래처럼 인증에 실패했다는 로그만 뜨는데 왜 저는 결과가 다르게 뜰까요?

  • spring
  • spring-security
  • jwt
박민 댓글 1 좋아요 0 조회수 659

JwtProperties의 내용을 application.properteis로 옮기고 싶습니다.

미해결

스프링부트 시큐리티 & JWT 강의

강사님 안녕하세요. JwtProperties에 있는 내용을 application.properteis로 옮기고 @Value 어노테이션으로 받아와서 사용하고싶습니다. @Value를 사용하기 위해 JwtAuthenticationFilter에 @Component를 붙여주었으나, authenticationManager의 빈 등록을 먼저 하라고 하더군요. @Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { return authenticationConfiguration.getAuthenticationManager(); } 그래서 이러한 코드를 SecurityConfig에 추가했습니다. 하지만 계속 AuthenticationManager를 빈으로 등록시키라는 에러메세지만 뜨네요. 이거 어떻게 해야하죠?... 바쁘신 와중에 답변 달아주시면 감사하겠습니다.

  • spring
  • spring-security
  • jwt
poohharry 댓글 1 좋아요 0 조회수 538

17:27초 질문입니다

미해결

스프링 프레임워크는 내 손에 [스프2탄]

formData.find('#id').remove(); formData.find('#title').remove(); formData.find('#content').remove(); formData.find('#writer').remove(); 에서 modify.jsp 파일에는 id 속성을 가지고 있는 태그가 없는데 #태그를 사용해서 remove()하는 이유가 무엇인가요?? #태그는 id속성과 일치하는 값을 가져오는 것으로 알고 있었는데 혼란스럽네요. https://github.com/bitcocom/spring2/blob/main/SpringMVC09/src/main/webapp/WEB-INF/views/board/modify.jsp

  • spring
  • jquery
  • mvc
  • jpa
  • spring-security
휴식중인너구리 댓글 1 좋아요 0 조회수 250

ajax 인증 유지

미해결

스프링 시큐리티

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요 security6로 ajax 로그인 구현을 따라하고 있습니다. 그런데 /api/login을 호출할 떄는 인증이 잘 되는데 그 후 /api/messages 를 호출하면 user, manager 둘다 항상 unauthorized로 나와서 보니 /api/messages를 호출할 때 securitycontext에 이전에 등록한 authentication을 찾을 수 없는데 원인과 해결방법을 찾을 수 없어 질문드립니다. github https://github.com/jjoylee/security-demo/tree/master/src/main/java/com/example/securitydemo/security/config

  • java
  • spring-boot
  • spring-security
Jeonghee Lee 댓글 2 좋아요 0 조회수 588

UsernamePasswordAuthenticationToken 생성 질문입니다.

미해결

스프링 시큐리티

new UsernamePasswordAuthenticationToken(accountContext.getAccount(), null, accountContext.getAuthorities()); 아래처럼 토큰을 생성하신 이유가 궁금합니다. UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(accountContext.getAccount(),null, accountContext.getAuthorities()); 강사님께서 다른 질문에 답변해주신걸 보면 1. pricipal 객체는 UserDetails 타입의 Wrapper 객체가 아닌 실제 객체(?)를 참조하는게 더 낫다. 2. credentials는 이미 우리가 만든 CustomAuthenticationProvider에서 비밀번호를 검증했으므로 null로 세팅했다. 라고 이해햇습니다. 그렇다면 역으로 1. 다음 필터에서 principal 객체는 유저의 이름만 필요하다고하면 유저이름만 세팅해도 무방한가요? 즉, 어플리케이션에서 필요로하는 principal 객체가 무엇이냐에 따라 다르게 세팅하면 되는게 맞나요? 2. 다음 필터에서 credentials 항목을 필요로 한다면, 해당 항목도 null이아닌 account객체에 있는 패스워드로 채우는게 맞나요?

  • java
  • spring-boot
  • spring-security
이화평 댓글 1 좋아요 0 조회수 1417

enum 타입의 getAuthorities

미해결

스프링부트 시큐리티 & JWT 강의

강사님 안녕하세요. 강사님 강의를 듣고 jwt를 배우고 있습니다. Users entity의 role를 enum타입으로 변경하고 싶은데 , PrincipalDetails의 getAuthorities을 어떻게 설정하면 될까요? Users Role enum 클래스 PrincipalDetails 클래스

  • spring
  • spring-security
  • jwt
김희연 댓글 1 좋아요 0 조회수 1492

마지막 강의 질문있습니다.

미해결

스프링부트 시큐리티 & JWT 강의

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. toString을 사용하지 않고 asString을 사용하는 이유가 있을까요? JWT.require(Algorithm.HMAC512("cos")).build().verify(token).getClaim("username").asString();

  • spring
  • spring-security
  • jwt
송원 댓글 1 좋아요 0 조회수 437

authenticationProvider, secret_key 관련 질문

해결됨

스프링 시큐리티

현재 문제 상황이 이렇습니다. secret_key value 가 "secret" 이 아니여도 정상적으로 로그인 되버립니다. 그래서 SecurityConfig 설정을 잘못해서 authenticationProvider 나 authenticationDetailSource 가 정상적으로 작동을 안하는지 의심되서 각각 코드에 break 를 걸고 debug 를 돌렸더니 break 가 걸려서 돌아갑니다. 그리고 진짜 진짜 신기한게 secret_key 가 null 인게 debug 모드에서 확인됩니다.그리고 secret_key == null 이 true 인게 확인됩니다. 그런데 exception 이 작동을 안하고 그냥 로그인이 되버립니다. 대체 이게 무슨일인거죠.. https://github.com/Hosung-Ahn/backend-practice/tree/main/demo-security 코드로 봐주시면 너무 감사할 것 같습니다..

  • java
  • spring-boot
  • spring-security
안호성 댓글 1 좋아요 0 조회수 549

Ajax에서 진도를 못나가고 막혀 있습니다.

미해결

스프링 시큐리티

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. WebSecurityConfigurerAdapter Deprecated 되서 사용을 못하는데 이거에 대한 소스 코드 공유를 해주시면 안될까요? 수업 따라가기가 벅찹니다. 돈을 주고 강의를 듣는데 이런 부분은 업데이트가 필요하다고 생각합니다.

  • java
  • spring-boot
  • spring-security
송원 댓글 1 좋아요 0 조회수 733

스프링부트 whitelabel error page

미해결

스프링부트 시큐리티 & JWT 강의

안녕하세요. 첫강의에서 config 설정하고 스프링부트 실행할때 나오는 패스워드로 로그인창에 user/패스워드 입력하면 whitelabel error page 에러가 나옵니다. 인터넷 찾아보니 경로를 못잡아서 그럴수 있다고하는데 index.html 경로는 선생님 디렉토리와 동일하게 맞춰놨고 config 설정하는 자바에서도 prefix, suffix 설정 동일하게 맞췄습니다. 그 application.yml 에서는 mvc 부분은 삭제했구요(넣어도 안되더라구요) 혹시 어느부분에서 그럴수있는지 알려주시면 감사하겠습니다.

  • spring
  • spring-security
  • jwt
ktw2375 댓글 1 좋아요 0 조회수 635

네이버 response 에 구글 이메일이 들어가 있는데

미해결

스프링부트 시큐리티 & JWT 강의

네이버로 회원가입 시 getAttributes() 안 response 의 email에 구글메일이 들어가있는데 왜그런지 아시는분 계신가요?

  • spring
  • spring-security
  • jwt
김민지 댓글 1 좋아요 0 조회수 285

아이디중복확인 ajax

미해결

스프링 프레임워크는 내 손에 [스프1탄]

아이디 중복확인 ajax작성할때 /memRegisterCheck.do에서 리턴값 1 또는 0 받는데 ajax에 dataType 안적는 이유는 뭔가요?

  • jsp
  • spring
  • mvc
  • spring-security
도전적인 뱀 댓글 1 좋아요 0 조회수 399

스프링 시큐리티 6부터는 아예 로직이 바뀐 듯 싶습니다.

미해결

스프링 시큐리티

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 질문이라고 보기에는 조금 어려울 수도 있는 글이긴 한데, 물론 강의는 스프링 시큐리티 5로 되어있긴 하지만 저는 시큐리티 6로 따라보고 있는데요. 지금까지 강의 내용은 완벽히 일치하진 않아도 소스 보면서 비슷한 부분이 많이 남아 있었는데, 6버전부터는 아예 Vote 작업과 관련된 내용이 모두 deprecate 되고 모든 처리는 AuthorizationFilter 에서 진행되는 듯 합니다. 사실 강의 보면서도 Voting 작업의 실제 필요성에 대해서 의문이 있긴 했는데, 아마 그러한 의견이 반영되었는지는 잘 모르겠습니다.

  • java
  • spring-boot
  • spring-security
Yu Byung Suk 댓글 1 좋아요 0 조회수 759

안녕하세요 강사님.

해결됨

스프링 시큐리티

안녕하세요 강사님 강의 내용을 듣고 제가 이해한 부분이 맞는지 여부와 추가적으로 질문드리고 싶은 내용이 있습니다. 유저가 최초 로그인을(인증) 하게 되면 SecurityContextPersistenceFilter에 HttpSessionSecurityContextRepository를 통해 SecurityContext를 생성하고 UsernamePasswordAuthenticaionFilter에서 인증 처리를 거친 후에 SecurityContextPersistenceFilter에서 Session에 저장하여 SecurityContext를 저장한다. 인증 이후에 유저가 요청하게 되면 SecurityContextPersistenceFilter에 HttpSessionSecurityContextRepository를 통해 Session에서 SecurityContext를 가져와서 SecurityContextHolder에 저장한다. 우선 제가 이해한 부분은 이렇습니다. 맞게 이해했는지 궁금합니다. 그리고 여기서 추가로 여쭤보고 싶은 점이 1. SecurityContextPersistenceFilter에 설명 강의 부분에서 최종 응답 시 공통 로직으로 SecurityContextHolder에서 clearContext()를 한다고 설명해주셨는데 SecurityContextHolder를 clear하지 않고 유지해야 Authentication객체를 계속 유지하는 게 아닌지 궁금합니다. 또한 로그인한 유저 객체를 가져올 때 SecurityContextHolder.getContext().getAuthentication()을 통해서 가져오는데 최종 응답 시에 clearContext()를 한다면 어떻게 가져오는지 궁금합니다. 2. ajax 방식을 연습할 겸 따로 프로젝트를 만들어서 진행해봤습니다. 거기서 FormLogin방식 자체를 사용하지 않았더니 filterChainProxy에 UsernamePasswordAuthenticationFilter 자체가 등록되지 않는 것 같습니다. UsernamePasswordAuthenticationFilter는 FormLogin 방식에서만 등록되는 필터인가요? 그리고 인증 이후 SecurityContextPersistenceFilter에서 SecurityContextHolder에 값을 저장하는 로직이 궁금합니다. 자체 필터를 등록하고 해당 필터에서 HttpSession에 SecurityContext key("SPRING_SECURITY_CONTEXT")로 authentication을 저장해도 SecurityContextPersistenceFilter에서 SecurityContextHolder에 SecurityContext를 설정하지 않는 것 같습니다.

  • java
  • spring-boot
  • spring-security
장재준 댓글 1 좋아요 0 조회수 402

Testcase 상에서 @Trasactional 사용시

미해결

호돌맨의 요절복통 개발쇼 (SpringBoot, Vue.JS, AWS)

당연히 구글링 해보셨져? 원하는 결과를 못찾으셨나요? 어떤 검색어를 입력했는지 알려주세 문제가 발생한 코드(프로젝트)를 Github에 올리시고 링크를 알려주세요. 안녕하세요. 호돌맨님 강의 잘 보고 있습니다! Post 관련 테스트를 작성할 때, 저는 @Transactional을 이용해서 DB에 데이터가 반영되지 않도록 시도했습니다.그리고 테스트를 진행하였습니다. 메서드를 각각 테스틀 할 때는 통과했지만, 메서드 모두 동시에 돌릴 때는 테스트 통과에 실패하였습니다. @Transcational, 영속성 컨텍스트로 구글링을 시도했었습니다. @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)를 사용하면 영속성 컨텍스트를 새로 생성함으로써 테스트가 모두 통과가 되었지만, 매번 영속성 컨텍스트를 새로 생성하는 것은 비효율적이라고 생각했습니다.. 결론적으로 제가 본 바로는 유의미한 결과를 얻을 수 없었습니다.. 아래 코드와 그에 출력되는 결과를 이미지로 첨부해두었습니다. 혹시 어떤 것이 원인인건지 힌트라도 알려주실 수 있을까요?? 구글링 키워드를 알려주셨으면 좋겠습니다..! (해결법은 제가 찾겠습니다!!) PostService.java @Service @RequiredArgsConstructor @Transactional(readOnly = true) public class PostService { private final PostRepository postRepository; @Transactional public void save(PostCreateDto postCreate){ // Post post = new Post(postCreate.getTitle(), postCreate.getContent()); Post post = Post.builder() .title(postCreate.getTitle()) .content(postCreate.getContent()) .build(); postRepository.save(post); } public Long findPostById(Long postId){ Post post = postRepository.findById(postId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 게시물입니다.")); return post.getId(); } } PostServiceTest.java import com.toktok.core.domain.post.Post; ... @SpringBootTest @Transactional. //똑같이 영속성 컨텍스트를 공유하고 있기 때문에 save가 롤백되어야 하지 않나요??.. class PostServiceTest { @Autowired private PostService postService; @Autowired private PostRepository postRepository; @Test @DisplayName("데이터가 저장 되어야합니다.") void save_test(){ //given PostCreateDto postDto = PostCreateDto.builder() .title("제목입니다.") .content("내용입니다.") .build(); //when postService.save(postDto); //then Post post = postRepository.findAll().get(0); assertThat(post.getId()).isEqualTo(1L); assertThat(post.getTitle()).isEqualTo(postDto.getTitle()); } @Test @DisplayName("데이터는 하나 조회") void find_test(){ //given Long postId = 1L; PostCreateDto postDto = PostCreateDto.builder() .title("글 제목입니다.") .content("글 내용입니다.") .build(); postService.save(postDto); //when Long postById = postService.findPostById(1L); //then assertThat(postById).isEqualTo(1L); } @Test @DisplayName("존재하지 않는 데이터 확인") void not_exist_post(){ //given Long notExistPostId = 2L; Post post = Post.builder() .title("글 제목입니다.") .content("글 내용입니다.") .build(); Post savedPost = postRepository.save(post); //when postService.findPostById(savedPost.getId()); //then assertThrows(IllegalArgumentException.class, ()-> postService.findPostById(notExistPostId)); } }

  • vue.js
  • aws
  • spring-boot
  • jpa
  • spring-security
정윤수 댓글 1 좋아요 3 조회수 668

Lombok 안되는 분들 참고

미해결

스프링부트 시큐리티 & JWT 강의

Lombok 안되시는 분들 있을 수 도 있어 남깁니다. 스프링부트 시작할 때 플러그인 넣어도 안되는 경우 프로젝트 폴더 내 lombok 우클릭 -> Run As -> Java Application 눌러서 실행하면 설치 화면이 나옵니다. 1. Specify location 누르신 후 IDE 실행파일 선택 2. Install / Update 눌러서 실행 3. Quit Installer 눌러서 나가기 4. 이클립스 실행 하면 되는데 만약 이클립스 눌러도 반응이 없으신분들은 이클립스 설치 폴더 안에 eclipse.ini 파일이 있습니다. 눌러서 확인해보면 경로가 한글이 섞여 있는 경우는 이클립스 실행이 안되니 경로를 영어로 다 바꾸시면 됩니다. ※바탕화면이 한글로 되어 있는데 어떻게 Desktop 으로 바꾸죠 ?? ㄴ 이건 인터넷 검색해보시면 되겠습니다. ※Lombok 설치 후 이클립스가 느려졌어요!! ㄴ eclipse.ini 파일 내부에 -Xms256m -Xmx2048m 여기 메모리 관련 부분을 수정 -Xms2048m -Xmx4086m 로 변경해서 사용하면 이전 처럼 빠르게 사용할 수 있습니다.

  • spring
  • spring-security
  • jwt
정정모 댓글 1 좋아요 1 조회수 2373

접근이 거부되었습니다. 예외가 발생합니다.

미해결

스프링 시큐리티

5) 웹 기반 인가처리 DB 연동 - FilterInvocationSecurityMetadataSource (2) 강의 관련 질문입니다. 참고로, 현재 SecurityConfig 파일이 파일명으로 구분해서 Ajax 인증용과 폼인증 두개 입니다. 문제는 로그인까지 성공하고 /mypage 로 들어가면 접근 거부 예외가 생깁니다. ' org.springframework.security .access.AccessDeniedException: 접근이 거부되었습니다.' SecurityConfig , AjaxSecurityConfig 설정파일명으로 구분했고 마지막에 설정 코드도 올렸지만 authenticationManager 같은 Bean 메서드들도 이름으로 구분했습니다. 사용자정보, 권한정보등 제대로 갖고 왔는데 어디가 잘못된건지 잘모르겠네요.. 혹시 시큐리티 설정파일에서 서비스 클래스 두가지를 사용해서 그런지 의심도 되고 그렇네요.. private final SecurityResourceService securityResourceService; private final UserDetailsService userDetailsService; 아래에 도움이 될까 해서 디버깅화면 캡쳐해서 올렸습니다. 그리고 코드는 아래 깃허브에 올렸습니다. walnutnamu/corespringsecurity ( github.com ) 감사합니다. AbstractSecurityInterceptor 클래스 UrlFilterInvocationSecurityMetadataSource 클래스 RoleVoter 클래스 ExceptionTranslationFilter 클래스 FormAccessDeniedHandler 클래스 AccessDeniedException 클래스 웹페이지에는 흰 배경만 나타나고 302 코드를 반환하네요. Request URL: http://localhost:8080/mypage Request Method: GET Status Code: 302 Remote Address: [::1]: 8080 Referrer Policy: strict-origin-when-cross-orig 시큐리티 설정파일 @Configuration @RequiredArgsConstructor @Order(1) public class SecurityConfig { @Bean public WebSecurityCustomizer configure() { return (web) -> web.ignoring().mvcMatchers( "/css/**", "/js/**", "/error" ); } private final AuthenticationConfiguration authenticationConfiguration; private final AuthenticationDetailsSource authenticationDetailsSource; private final AuthenticationSuccessHandler formAuthenticationSuccessHandler; private final AuthenticationFailureHandler formAuthenticationFailureHandler; private final SecurityResourceService securityResourceService; private final UserDetailsService userDetailsService; public PasswordEncoder passwordEncoder() { return PasswordEncoderFactories.createDelegatingPasswordEncoder(); } @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/users", "user/login/**", "/login*").permitAll() .antMatchers("/mypage").hasRole("USER") .antMatchers("/messages").hasRole("MANAGER") .antMatchers("/config").hasRole("ADMIN") .anyRequest().authenticated() .and() .exceptionHandling() //.accessDeniedPage("/denied") .accessDeniedHandler(accessDeniedHandler()) .and() .addFilterBefore(customFilterSecurityInterceptor(), FilterSecurityInterceptor.class) ; http .formLogin() .loginPage("/login") .loginProcessingUrl("/login_proc") .authenticationDetailsSource(authenticationDetailsSource) .defaultSuccessUrl("/") .successHandler(formAuthenticationSuccessHandler) .failureHandler(formAuthenticationFailureHandler) .permitAll() ; //http.csrf().disable(); return http.build(); } public FormAuthenticationProvider formAuthenticationProvider() { return new FormAuthenticationProvider(userDetailsService, passwordEncoder()); } @Bean public AccessDeniedHandler accessDeniedHandler(){ FormAccessDeniedHandler accessDeniedHandler = new FormAccessDeniedHandler(); accessDeniedHandler.setErrorPage("/denied"); return accessDeniedHandler; } @Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { ProviderManager authenticationManager = (ProviderManager) authenticationConfiguration.getAuthenticationManager(); authenticationManager.getProviders().add(formAuthenticationProvider()); return authenticationManager; } @Bean public FilterSecurityInterceptor customFilterSecurityInterceptor() throws Exception { FilterSecurityInterceptor filterSecurityInterceptor = new FilterSecurityInterceptor(); filterSecurityInterceptor.setSecurityMetadataSource(urlFilterInvocationSecurityMetadataSource()); filterSecurityInterceptor.setAccessDecisionManager(affirmativeBased()); filterSecurityInterceptor.setAuthenticationManager(authenticationManager(authenticationConfiguration)); return filterSecurityInterceptor; } public AccessDecisionManager affirmativeBased() { AffirmativeBased affirmativeBased = new AffirmativeBased(getAccessDecisionVoters()); return affirmativeBased; } private List<AccessDecisionVoter<?>> getAccessDecisionVoters() { return Arrays.asList(new RoleVoter()); } /** * 자원/권한 정보를 저장하고 있는 클래스를 빈으로 생성 * @return * @throws Exception */ @Bean public FilterInvocationSecurityMetadataSource urlFilterInvocationSecurityMetadataSource() throws Exception { return new UrlFilterInvocationSecurityMetadataSource(urlResourcesMapFactoryBean().getObject()); } private UrlResourcesMapFactoryBean urlResourcesMapFactoryBean() { UrlResourcesMapFactoryBean urlResourcesMapFactoryBean = new UrlResourcesMapFactoryBean(); urlResourcesMapFactoryBean.setSecurityResourceService(securityResourceService); return urlResourcesMapFactoryBean; } }

  • java
  • spring-boot
  • spring-security
원데이 댓글 1 좋아요 0 조회수 2911

@ModelAttribute 사용시 @Valid

미해결

호돌맨의 요절복통 개발쇼 (SpringBoot, Vue.JS, AWS)

@RequestBody @Valid 사용시에 오류가 발생하면 ControllerAdvice @ExceptionHandler(MethodArgumentNotValidException.class)로 잡을 수 있었습니다. 하지만 @ModelAttribute를 사용하면 ControllerAdvice @ExceptionHandler(MethodArgumentNotValidException.class)로 잡히지가 않습니다.. 제가 잘못한 부분이 있을까요? /author/presentation/AuthorController getAuthorListByNickname에서 오류가 잡을 수가 없습니다. ControllerAdvice는 /global/error/ControllerAdvice에 있습니다. 감사합니다~ https://github.com/320Hwany/Webtoon

  • vue.js
  • aws
  • spring-boot
  • jpa
  • spring-security
yhwjd 댓글 1 좋아요 0 조회수 1658

인기 태그

인프런 TOP Writers

주간 인기글