무료
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결Spring Boot JWT Tutorial
AuthenticationManager 와 authenticationmanagerbuilder 차이점이 궁금합니다..
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 좋은 강의 감사합니다. authenticationtoken 에 넣는 이유와 AuthenticationManager와 authenticationmanagerbuilder 차이가 궁금합니다..
- 미해결Spring Boot JWT Tutorial
USER 테이블 생성이 안됩니다.
AUTHORITY, USER_AUTHORITY 테이블은 제대로 생성이 되는데, USER 테이블만 생성이 되지 않습니다.
- 미해결Spring Boot JWT Tutorial
AuthController관련 문의 드려요!
AuthController에서 38번 행의authenticationManagerBuilder.getObject().authenticate(authenticationToken); 을 진행했을 때 CustomUserDetailsService의 loadUserByUsername가 실행된다고 했는데, 호출하지 않았는데 어떻게 실행되는건가요?? ㅠㅠ
- 미해결Spring Boot JWT Tutorial
User Entity와 UserDetails
안녕하세요 User Entity에 대해 궁금한 점이 생겨 질문 드립니다. SpringSecurity는 UserDetails 객체를 통해 권한 정보를 관리하기 때문에 User 클래스에 UserDetails 를 구현하고 추가 정보를 재정의 해야한다는데, 여기서는 그냥 UserDetails를 implement를 안한 User을 쓰고 따로 TokenProvider에서 User가 필요한 곳에는 org.springframework.security.core.userdetails.User; 을 import하는 방향으로 하셨더라구요 . UserDetails를 따로 구현하지 않아도 괜찮나요??
- 미해결Spring Boot JWT Tutorial
data.sql 파일 실행이 안됩니다
application.yml spring: h2: console: enabled: true datasource: url: jdbc:h2:mem:testdb driver-class-name: org.h2.Driver username: sa password: initialization-mode: never jpa: database-platform: org.hibernate.dialect.H2Dialect hibernate: ddl-auto: none properties: hibernate: format_sql: true show_sql: true defer-datasource-initialization: true sql: init: mode: alwaysjwt: header: Authorization secret: c2lsdmVybmluZS10ZWNoLXNwcmluZy1ib290LWp3dC10dXRvcmlhbC1zZWNyZXQtc2lsdmVybmluZS10ZWNoLXNwcmluZy1ib290LWp3dC10dXRvcmlhbC1zZWNyZXQK token-validity-in-seconds: 86400logging: level: me.silvernine: DEBUG 인터넷 찾아 보면서 위 내용으로 수정 했는데도 실행이 될 때 data.sql 의 쿼리가 동작 하지 않습니다.
- 미해결Spring Boot JWT Tutorial
6:46에 설명란이 어디죠...
6:46에 설명란이 어디죠..... 복붙해서 사용해 보려고 했는데 어딜봐도 링크를 못찾겟습니다...
- 미해결Spring Boot JWT Tutorial
블로그 작성
안녕하세요. 은구님! 일단 너무나 훌륭한 강의를 만들어주셔서 정말 감사합니다. jwt 강의를 올려주신 덕분에 참고해서 개인토이프로젝트에 적용중인데요! 혹시 강의해주신 내용을 참고해서 블로그에 글을 작성해도 될까요 ??? 출처는 꼭 남기겠습니다!
- 미해결Spring Boot JWT Tutorial
포스트맨 결과 500 서버 에러 뜨시는 분!
application.yml 에서 jwt.secret 값이 64바이트 이상이여야 합니다...
- 미해결Spring Boot JWT Tutorial
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [FKASNMJAR8JR5GAXVD7966P19IR]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
안녕하세요? 이 강의를 보고, 이 강의를 토대로 토이 프로젝트를 진행하고 있습니다. 근데 계속 아래와 같은 Exception이 터지고 있습니다. 다수 회원을 생성 합니다! Hibernate: insert into member (member_id, modify_date, register_date, about_me, activated, email, name, nickname, password, phone) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?) Hibernate: insert into member_authority (member_id, authority_name) values (?, ?) 2022-02-09 23:42:57.821 WARN 11871 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 23506, SQLState: 23506 2022-02-09 23:42:57.821 ERROR 11871 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : Referential integrity constraint violation: "FKASNMJAR8JR5GAXVD7966P19IR: PUBLIC.MEMBER_AUTHORITY FOREIGN KEY(AUTHORITY_NAME) REFERENCES PUBLIC.AUTHORITY(AUTHORITY_NAME) ('ROLE_FAMILY')"; SQL statement: insert into member_authority (member_id, authority_name) values (?, ?) [23506-200] 2022-02-09 23:42:57.823 INFO 11871 --- [ main] o.h.e.j.b.internal.AbstractBatchImpl : HHH000010: On release of batch it still contained JDBC statements org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [FKASNMJAR8JR5GAXVD7966P19IR]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:276) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:233) at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:566) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:654) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:407) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) at com.sun.proxy.$Proxy142.save(Unknown Source) at org.comunity.hongga.repository.MemberRepositoryTest.lambda$회원_100명_생성_상세_조회$0(MemberRepositoryTest.java:76) at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104) at java.base/java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:593) at org.comunity.hongga.repository.MemberRepositoryTest.회원_100명_생성_상세_조회(MemberRepositoryTest.java:57) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:59) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:37) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200) at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46) at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1352) at org.hibernate.action.internal.CollectionRecreateAction.execute(CollectionRecreateAction.java:50) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604) at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478) at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:344) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40) at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1402) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:493) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3285) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2420) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:449) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101) at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:562) ... 87 more Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referential integrity constraint violation: "FKASNMJAR8JR5GAXVD7966P19IR: PUBLIC.MEMBER_AUTHORITY FOREIGN KEY(AUTHORITY_NAME) REFERENCES PUBLIC.AUTHORITY(AUTHORITY_NAME) ('ROLE_FAMILY')"; SQL statement: insert into member_authority (member_id, authority_name) values (?, ?) [23506-204] at org.h2.message.DbException.getJdbcSQLException(DbException.java:527) at org.h2.message.DbException.getJdbcSQLException(DbException.java:496) at org.h2.message.DbException.get(DbException.java:227) at org.h2.message.DbException.get(DbException.java:203) at org.h2.constraint.ConstraintReferential.checkRowOwnTable(ConstraintReferential.java:311) at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:252) at org.h2.table.Table.fireConstraints(Table.java:1163) at org.h2.table.Table.fireAfterRow(Table.java:1181) at org.h2.command.dml.Insert.insertRows(Insert.java:188) at org.h2.command.dml.Insert.update(Insert.java:135) at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:61) at org.h2.command.CommandContainer.update(CommandContainer.java:173) at org.h2.command.Command.executeUpdate(Command.java:252) at org.h2.server.TcpServerThread.process(TcpServerThread.java:408) at org.h2.server.TcpServerThread.run(TcpServerThread.java:191) at java.base/java.lang.Thread.run(Thread.java:831) at org.h2.message.DbException.getJdbcSQLException(DbException.java:459) at org.h2.engine.SessionRemote.done(SessionRemote.java:611) at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237) at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:191) at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:152) at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197) ... 107 more @Test public void 회원_100명_생성_상세_조회() { // given System.out.println("다수 회원을 생성 합니다!"); // 50번까지 FAMILY // 100번까지 GUEST IntStream.rangeClosed(1, 100).forEach(i -> { if (i <= 50) { Authority authority = Authority.builder() .authorityName("ROLE_FAMILY") .build(); Member memberMany = Member.builder() .email("whoami"+i+"@hongga.com") .password(passwordEncoder.encode("1234")) .name("손님" + i) .nickname("손님이에영" + i) .phoneNumber("010-3948-4934") .activated(true) .authorities(Collections.singleton(authority)) .build(); // when Member saveManyFamily = memberRepository.save(memberMany); // then System.out.println(assertThat(memberMany).isEqualTo(saveManyFamily)); } else { Authority authority = Authority.builder() .authorityName("ROLE_GUEST") .build(); Member memberMany = Member.builder() .email("whoami"+i+"@hongga.com") .password(passwordEncoder.encode("1234")) .name("손님" + i) .nickname("손님이에영" + i) .phoneNumber("010-3948-4934") .activated(true) .authorities(Collections.singleton(authority)) .build(); // when Member saveManyGuest = memberRepository.save(memberMany); // then System.out.println(assertThat(memberMany).isEqualTo(saveManyGuest)); } // if-else 끝 }); System.out.println("==============================================================="); System.out.println("회원 조회를 시작 합니다!"); //given IntStream.rangeClosed(1, 100).forEach(i -> { String email = "whoami"+i+"@hongga.com"; // when Member byEmail = memberRepository.findByEmail(email); // then System.out.println(assertThat(email).isEqualTo(byEmail)); });} // 회원_상세_조회() 끝 이렇게 TEST 코드를 작성해서 여러 회원을 검색하고, 비교 해 보려고 하는데 안 됩니다. 의심 가는 건 저는 회원 등급을 GUEST, FAMILY, ADMIN으로 사용하고 싶은데, 혹시 이걸 Check하거나 뭐 그러는 곳이 있나요?? 조언 부탁 드리겠습니다! https://github.com/junyharang-personal-project/hongga-community-server
- 미해결Spring Boot JWT Tutorial
JPA관련 질문드립니다!
먼저 좋은 강의 감사합니다! JWT를 공부하고싶지만 너무 막막해서 강의를 찾아보던 중 강사님 강의 알게되서 현재 수강중입니다 다름이 아니라 현재 강사님도 그렇고 다른 JWT관련 자료들을 찾아보면 JWT를 적용시키는 프로젝트에서는 JPA를 같이 사용하던데 저는 현재 스프링 부트로만 구현중입니다 이런 상황에서는 JPA 관련된 부분만 알아서 수정해서 적용시키면 될까요??
- 미해결Spring Boot JWT Tutorial
AuthController 질문있습니다
안녕하세요, 우선 좋은 강의 감사합니다. ^___^ 다름이 아니라 강의를 실습하는 중 문제가 생겨 한 가지 여쭙고 싶습니다! /api/authenticate 경로로 요청을 보내면 JwtFilter의 doFilter 로직을 타더라구요. 그래서 요청 헤더에 아무런 값이 없기 때문에 "유효한 JWT 토큰이 없습니다" 문장이 로그에 찍힙니다. SecurityConfig에 /api/authenticate 경로는 .permitAll() 을 해줬기 때문에 해당 doFilter 로직을 타면 안될 것 같은데, 혹시 제 생각이 맞는지 여쭤보고 싶습니다. 혹시 추가로... 강사님 깃허브 코드랑 비교해봐도 크게 다른점이 잘 안보이고.. 포스트맨으로 POST 요청까지 크게 다른 점을 모르겠는데.. 혹시 "유효한 JWT 토큰이 없습니다" 라고 뜨는 경우에 코드상에 살펴볼만한 포인트가 있을까요..? 감사합니다.
- 미해결Spring Boot JWT Tutorial
postman 실행 결과
안녕하세요. 강의 잘 듣고 있는 학생입니다! 다름이 아니라 이클립스를 통해 프로젝트를 생성하고 예제 소스와 똑같이 만들었는데 postman으로 테스트 결과 저렁게 나오네요... 구글링해도 잘 모르겠어서 댓글 남깁니다.
- 미해결Spring Boot JWT Tutorial
시큐리티를 적용하고 호스팅에 올리면 오류가 납니다.
샘플 프로젝트를 스프링 부트 최신버전으로 하고 jdk는 1.8로하고 그래이들로 만들었습니다.HomeController @Controller public class HomeController { @GetMapping("/") public String index() { return "login"; } @GetMapping("/login") public String login() { return "/index__"; } } 이렇게 해서 도메인 접속 시 login페이지로 이동하게 했는데 war로 cafe24에 배포를 하면 정상적으로 login페이지가 보여집니다. 여기까지는 문제가 없는데 문제는 Spring Security를 적용했을 때 발생합니다.ㅠㅠ CustomAuthenticationEntryPoint는 public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } } 이렇게 되어있고, SecurityConfig 파일은 @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/").permitAll() .and() .formLogin() .loginPage("/login"); http.exceptionHandling() .authenticationEntryPoint(new CustomAuthenticationEntryPoint()); } } 이렇게 되어있습니다. 원래 SecurityConfig에 설정을 다 넣었었는데 Security만 적용을 하고 cafe24에 배포를 하면 404오류가 계속 나와서 아무리 이리저리 방법을 찾아봐도 도저히 방법을 찾을 수 없어서 기본 설정만 저렇게 넣어놓고 테스트를 했는데도 404오류가 나옵니다.ㅠㅠ분명 로그인 페이지를 /login 으로 하고 기본 로그인 페이지도 이동하는 매핑을 했는데 왜 안되는지 모르겠네요.ㅠㅠ 오류 메시지는 2021-12-02 16:50:12.197 INFO 48329 --- [com-startStop-1] com.example.sample.ServletInitializer : Started ServletInitializer in 7.449 seconds (JVM running for 9.477) 02-Dec-2021 16:50:12.204 심각 [sample.cafe24.com-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter errorPageSecurityFilter java.lang.AbstractMethodError at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:112) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4708) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5348) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:974) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1850) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 02-Dec-2021 16:50:12.205 심각 [sample.cafe24.com-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file 02-Dec-2021 16:50:12.205 심각 [sample.cafe24.com-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors 02-Dec-2021 16:50:12.207 정보 [sample.cafe24.com-startStop-1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext 02-Dec-2021 16:50:12.229 경고 [sample.cafe24.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [SeedGenerator Thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: sun.security.provider.SeedGenerator$ThreadedSeedGenerator.run(SeedGenerator.java:362) java.lang.Thread.run(Thread.java:745) 02-Dec-2021 16:50:12.230 경고 [sample.cafe24.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [SeedGenerator Thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Thread.sleep(Native Method) sun.security.provider.SeedGenerator$ThreadedSeedGenerator$BogusThread.run(SeedGenerator.java:475) java.lang.Thread.run(Thread.java:745) 입니다. 오류로그를 보면 정확히는 모르겠는데 추측해보면 에러페이지 시큐리티 관련 필터를 불러오지 못해서 발생하는 오류인 것 같은데.. 검색을 해 봐도 해결이 안되네요.ㅠㅠ왜 로컬에서는 잘 되는데 war로 묶어서 cafe24 호스팅에 배포를 하면 위와같은 오류가 나오고 안될까요?ㅠㅠ jdk버전은 로컬이나 cafe24모두 openJdk1.8버전입니다.
- 미해결Spring Boot JWT Tutorial
User 엔티티와 Authority 엔티티를 나눈 이유가 무엇인가요?
권한에 대한 컬럼을 User에 함께 넣으면 안되는 걸까요??
- 미해결Spring Boot JWT Tutorial
AuthController에서 loadByUsername 메서드 실행 경로
authenticationManagerBuilder.getObject().authenticate(authenticationToken);이 실행되면 loadUserByUsername으로 어떻게 넘어가지는지 이해가 되지 않습니다. loadUserByUsername은 customUserDatailSevice의 메서드인데 어째서 authenticationdml authentiacate메서드를 실행하면 CustomUserDatailService의 메서드가 호충되는 건가요?
- 미해결Spring Boot JWT Tutorial
로그인 api 질문
반환 값에 왜 비밀먼호와 activated 관련 정보는 안나오는지 궁금합니다.
- 미해결Spring Boot JWT Tutorial
genericFilterBean
genericFilterBean에 doFilter라는 메소드가 없네요.. ㅠㅠ 이제 바뀐걸까요?
- 미해결Spring Boot JWT Tutorial
jwt secretkey설정
yml에 jwt secret key설정을 64바이트이상 사용해야한다하셨는데 왜 그런건지 궁금하고, 저런 secret key값은 어디서 찾아서 yml에 넣을 수 있나요?
- 미해결Spring Boot JWT Tutorial
permitAll()질문드립니다.
기존질문 - security config에서 antMatchers.permitAll()이 작동하지 않는 것 같습니다. 찾아보니 csrf때문이란 말도 있어 csrf.disable사용해봐도 똑같이 계속 401에러가 뜹니다. ㅠ 왜 이러는 걸까요.. ++해결 config파일을 메인클래스와 같은 패키지안에 넣지않아서 bean을 인식하지 못하는 경우였습니다. 같은 패키지안에 넣으니 해결되었습니다!! 추가질문!!! 근데 추가적으로 왜 메인클래스안에 넣지않으면 인식이 되지않는 것인지 궁금합니다. 이게 스프링부트 작동순서와 연관된 것 인가요?
- 미해결Spring Boot JWT Tutorial
dependency설정
spring start에서 dependency넣지않고 나중에 따로 넣는다했을때 공식적으로 어떤 dependency를 써야한다고 적힌 문서는 어떻게 찾아야하나요? 구글에 spring security gradle dependency 등등 여러가지로 쳐봐도 공식문서를 못찾겠네요 ㅠ