inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

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

Ajax 인증시 인가코드가 발급 되지 않는 원인 문의

해결됨

스프링 시큐리티 OAuth2

Spring Authorization 1.0,1 기반으로 개발을 하고 있습니다. 인가코드를 발급 할떄 FormLogin 기본 설정을 사용하면 인가코드가 발급이 되는데 Ajax 로 로그인을 하면 인가코드가 발급되지 않고 있습니다. 디버깅을 해보면 로그인인 후 OAuth2AuthorizationEndpointFilter 는 실행되는데 @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (!this.authorizationEndpointMatcher.matches(request)) { filterChain.doFilter(request, response); return; } try { Authentication authentication = this.authenticationConverter.convert(request); if (authentication instanceof AbstractAuthenticationToken) { ((AbstractAuthenticationToken) authentication) .setDetails(this.authenticationDetailsSource.buildDetails(request)); } Authentication authenticationResult = this.authenticationManager.authenticate(authentication); if (!authenticationResult.isAuthenticated()) { // If the Principal (Resource Owner) is not authenticated then // pass through the chain with the expectation that the authentication process // will commence via AuthenticationEntryPoint filterChain.doFilter(request, response); return; } if (authenticationResult instanceof OAuth2AuthorizationConsentAuthenticationToken) { if (this.logger.isTraceEnabled()) { this.logger.trace("Authorization consent is required"); } sendAuthorizationConsent(request, response, (OAuth2AuthorizationCodeRequestAuthenticationToken) authentication, (OAuth2AuthorizationConsentAuthenticationToken) authenticationResult); return; } this.authenticationSuccessHandler.onAuthenticationSuccess( request, response, authenticationResult); } catch (OAuth2AuthenticationException ex) { if (this.logger.isTraceEnabled()) { this.logger.trace(LogMessage.format("Authorization request failed: %s", ex.getError()), ex); } this.authenticationFailureHandler.onAuthenticationFailure(request, response, ex); } } FormLogin 적용시에는 authenticationResult의 principal 에 UsernamePasswordAuthenticationToken이 설정되어 인가 코드가 정상적으로 발급되는데 AjaxLogin 적용시에는 authenticationResult의 principal 에 AnonymousAuthenticationToken이 설정되어 인가 코드가 정상적으로 발급되지 않고 403 예외가 발생합니다. AuthenticationProvider 구현체에서는 정상적으로 토큰을 저장하고 있습니다. AuthenticationProvider 구현체 소스 @Component @RequiredArgsConstructor public class CustomAuthenticationProvider implements AuthenticationProvider { private final CustomUserDetailsService customUserDetailsService; private final PasswordEncoder passwordEncoder; @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { if(authentication == null){ throw new InternalAuthenticationServiceException("Authentication is null"); } LoginRequestDto loginRequestDto = (LoginRequestDto)authentication.getPrincipal(); String password = loginRequestDto.getLoginPassword(); UserAdapter userAdapter = (UserAdapter) customUserDetailsService.loadUserByLoinRequestDto(loginRequestDto); if (!passwordEncoder.matches(password, userAdapter.getCurrentUser().getLoginPwd())) { throw new BadCredentialsException("BadCredentialsException"); } CustomAuthenticationToken result = CustomAuthenticationToken.authenticated(userAdapter.getCurrentUser(), authentication.getCredentials(), userAdapter.getAuthorities()); result.setDetails(authentication.getDetails()); return result; } @Override public boolean supports(Class<?> authentication) { return CustomAuthenticationToken.class.isAssignableFrom(authentication); } } 이외 Custom 소스 Spring Security 설정 @EnableWebSecurity @RequiredArgsConstructor @Configuration public class DefaultSecurityConfig { private final CustomAuthenticationProvider customAuthenticationProvider; // private final CustomUserDetailsService customUserDetailsService; @Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { return authenticationConfiguration.getAuthenticationManager(); } @Bean public CustomAuthenticationProcessingFilter customAuthenticationProcessingFilter() throws Exception { CustomAuthenticationProcessingFilter filter = new CustomAuthenticationProcessingFilter(); // filter.setAuthenticationManager(authenticationManager(null)); filter.setAuthenticationManager(new ProviderManager(customAuthenticationProvider)); // filter.setAuthenticationSuccessHandler(customAuthenticationSuccessHandler()); // filter.setAuthenticationFailureHandler(customAuthenticationFailureHandler()); return filter; } // @formatter:off @Bean SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception { http .authorizeHttpRequests(authorizeRequests ->authorizeRequests .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() .requestMatchers(new AntPathRequestMatcher("/")).permitAll() .requestMatchers(new AntPathRequestMatcher("/login/**")).permitAll() .requestMatchers("/api/login/**").permitAll() .requestMatchers("/api/registered-client/**").permitAll() .anyRequest().authenticated() ); http.addFilterBefore(customAuthenticationProcessingFilter(), UsernamePasswordAuthenticationFilter.class); http.exceptionHandling(httpSecurityExceptionHandlingConfigurer -> httpSecurityExceptionHandlingConfigurer .authenticationEntryPoint(new CustomLoginAuthenticationEntryPoint()) .accessDeniedHandler(customAccessDeniedHandler()) ); // http.userDetailsService(customUserDetailsService); // http.formLogin(); http.csrf().disable(); return http.build(); } // @formatter:on @Bean public AccessDeniedHandler customAccessDeniedHandler() { return new CustomAccessDeniedHandler(); } @Bean public AuthenticationSuccessHandler customAuthenticationSuccessHandler() { return new CustomAuthenticationSuccessHandler(); } @Bean public AuthenticationFailureHandler customAuthenticationFailureHandler() { return new CustomAuthenticationFailureHandler(); } } Ajax 로그인 처리 필터 소스 public class CustomAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter { private final ObjectMapper objectMapper = new ObjectMapper(); private static final AntPathRequestMatcher DEFAULT_ANT_PATH_REQUEST_MATCHER = new AntPathRequestMatcher("/api/login", HttpMethod.POST.name()); public CustomAuthenticationProcessingFilter() { super(DEFAULT_ANT_PATH_REQUEST_MATCHER); } public CustomAuthenticationProcessingFilter(AuthenticationManager authenticationManager) { super(DEFAULT_ANT_PATH_REQUEST_MATCHER, authenticationManager); } @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { if (!request.getMethod().equals("POST")) { throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); } LoginRequestDto loginRequestDto = objectMapper.readValue(request.getReader(), LoginRequestDto.class); if(StringUtils.isEmpty(loginRequestDto.getLoginId())||StringUtils.isEmpty(loginRequestDto.getLoginPassword())) { throw new IllegalStateException("Username or Password is empty"); } CustomAuthenticationToken authRequest = CustomAuthenticationToken.unauthenticated(loginRequestDto, loginRequestDto.getLoginPassword()); authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request)); return getAuthenticationManager().authenticate(authRequest); } } CustomAuthenticationToken 소스 public class CustomAuthenticationToken extends AbstractAuthenticationToken { private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; private final Object principal; private Object credentials; public CustomAuthenticationToken(Object principal, Object credentials) { super(null); this.principal = principal; this.credentials = credentials; setAuthenticated(false); } public CustomAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) { super(authorities); this.principal = principal; this.credentials = credentials; super.setAuthenticated(true); // must use super, as we override } public static CustomAuthenticationToken unauthenticated(Object principal, Object credentials) { return new CustomAuthenticationToken(principal, credentials); } public static CustomAuthenticationToken authenticated(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) { return new CustomAuthenticationToken(principal, credentials, authorities); } @Override public Object getCredentials() { return this.credentials; } @Override public Object getPrincipal() { return this.principal; } }

  • java
  • oauth
  • spring-boot
  • spring
신석균 댓글 2 좋아요 1 조회수 1390

이 강의를 들을 때 필요한 언어공부가 있을까요? 추천 부탁드립니다,

해결됨

탄탄한 백엔드 NestJS, 기초부터 심화까지

제가 백엔드 공부도 처음이고 언어 공부에서도 c 이후로 는 거의 하지 않았습니다. 프로젝트 단계로 넘어가기 전 언어 공부를 해야 더 도움이 될거같은데 typescript 나 자바스크립트를 선행 언어 공부를 한 후에 들어야 도움이 더 잘 될까요? 아니면 공부 없이도 듣기 괜찮을 까요?

  • ssr
  • NestJS
  • express
  • mongodb
  • nodejs
최준희 댓글 1 좋아요 0 조회수 404

JdbcTemplate 테스트에서의 중복 회원 예외 오류가 뜨는 이유를 모르겠습니다.

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (비슷한 내용은 있었지만 원하는 해답을 찾지 못했습니다) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 여기에 질문 내용을 남겨주세요. 차근차근 강의 예제를 따라가면서 잘 오고 있었는데 테스트 하는 부분에서 갑작스런 오류로 인해 해답을 찾던 도중 어려움을 겪어서 프로젝트 링크와 오류 사진을 남기겠습니다 https://drive.google.com/file/d/1DIAzsFD6RnTCv73h-kNpeDWUE5CsF8oC/view?usp=share_link

  • spring-boot
  • MVC
  • mvc
  • spring
  • java
김동우 댓글 2 좋아요 1 조회수 738

static 메소드와 instance 메소드의 접근?

해결됨

나도코딩의 자바 기본편 - 풀코스 (20시간)

안녕하세요 ㅎㅎ 다름이 아니라 나도코딩 자바편에서 메소드를 공부하면서 궁금증이 생겨, 이렇게 또 다시 질문을 남깁니다...ㅎ 나도코딩 자바편을 보는 것과 동시에, 제 스스로 나름 예제들도 풀면서 개념을 익히고 있는데요...ㅎ 방금 전에 제가 문자열(String)배열과 charAt()을 이용하여, 전치행렬을 만드는데 성공했습니다...ㅎ 결과도 잘 출력했구요 ㅎㅎ 이 예제를 푸는 데는 String, String[], length(), charAt()에 대한 선생님의 도움과 답변이 없었으면 풀지 못했을 건데, 선생님의 자세한 답변 덕분에 문제를 빠르게 잘 풀 수 있었습니다. 감사합니다 ㅎㅎ 아래가 제가 쓴 코드고, 출력한 결과입니다: 여기서부터가 제 질문인데요...ㅎ static 메소드(public static void main(String[] args) {...})에서 일반 메소드를 접근하려면, 에러 메시지로 'non-static variable/method cannot be referenced fromstatic context.'라고 나오는데, 이럴 경우에 에러를 없애고, 결과를 잘 출력하려면: pubilc static void main 메소드 앞에 첫 번째 방법으로 void transpose 메소드를 static void tranpose라고 바꾸거나, 아니면 2번째 방법으로 static 메소드 안에서 이렇게 Question_03 making = new Question_03(); 즉, (클래스 이름) (객체 이름) = new (클래스 이름)(); 이런 식으로 객체화를 해서 메소드를 접근해야 하나요?

  • 객체지향
  • java
  • 메소드
  • oop
  • static
댓글 1 좋아요 0 조회수 751

31강 대출기능에서 테이블 생성에 대한 질문입니다.

해결됨

자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]

대출기능을 개발하려고 하니, 저희가 가진 두 테이블, User와 Book은 서로를 가리킬 필드가 없어서 '대출했다.'라는 정보를 표시할 수 없었습니다. 그래서 user_loan_history 테이블을 새로 만드는 내용이 강의의 주된 내용이 되는데요, 제가 궁금한건 여기서 User와 Book 테이블을 수정하여, 예를들면 User테이블에는 OneToMany로 Book의 id를 가리킬 수 있는 필드를, Book테이블에는 ManyToOne으로 User의 id를 가리킬 수 있는 필드를 추가하여 개발할 수도 있지 않나 싶어서요! 객체지향적으로 생각했을 때 User와 Book은 객체지만, '대출기록'은 객체가 아니라 객체간의 관계 같아서 테이블로 만드는 것에 거부감이 생기는 것 같습니다. 어떤 이유에서 기존의 테이블을 수정하지 않고, 새로운 테이블을 만들었는지 궁금합니다!

  • spring
  • spring-boot
  • JPA
  • java
  • jpa
  • aws
  • mysql
Dompoo 댓글 1 좋아요 2 조회수 473

SpringConfig에 JdbcMemberRepsoitory반환 오류

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

[질문 내용] SpringConfig클래스에 MemoryMemberRepsoitory 메소드에 retrun new JdbcMemberRepository();를 하고 dataSource 객체 생성 후 생성자까지 만들어주었습니다. 여기까지는 ()에 오류가 생기는데 여기에 dataSource를 넣어주면 전체오류가 생기여 옵션엔터를 눌러 해결하면 메소드 이름을 MemoryMemberRepository가 아닌 JdbcMemeberRepository로 바꿔라 합니다. 이를 변경하면 위에 MemberService도 바꿔야하며 전체코드에 이상이 생깁니다. package hello.hellospring; import hello.hellospring.repository.JdbcMemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import hello.hellospring.service.MemberService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.sql.DataSource; @Configuration public class SpringConfig { DataSource dataSource; public SpringConfig(DataSource dataSource) { this.dataSource = dataSource; } @Bean public MemberService memberService(){ return new MemberService(memberRepository()); } @Bean public MemoryMemberRepository memberRepository(){ //return new MemoryMemberRepository(); return new JdbcMemberRepository(dataSource); //오류발생 } } java: incompatible types: hello.hellospring.repository.JdbcMemberRepository cannot be converted to hello.hellospring.repository.MemoryMemberRepository 이러한 오류내용이 뜹니다. 수업 소스코드와 동일하게 해봤는데 이럽니다!

  • MVC
  • mvc
  • java
  • spring
  • spring-boot
  • spring-boot
nskynet5374 댓글 1 좋아요 0 조회수 667

API-Gateway2 섹션 Apollo 서버 구동 에러

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

Auth와 Resource App 시작 시 아래 사진과 같은 에러가 발생합니다. 강의와 노션에 있는 코드를 그대로 작성했다고 생각하여 패키지 버전 문제로 추정됩니다. 현재 제가 사용중인 패키지입니다. 강의 중 사용중인 패키지 버전을 공유받고 싶습니다. 해당 오류에 대한 구글링에 실패해서 추가적으로 혹시 알고계신 레퍼런스 있으시면 알려주시면 감사드리겠습니다.

  • nodejs
  • node.js
  • rest-api
  • express
  • tdd
  • javascript
  • nestjs
  • docker
  • NestJS
제리제리 댓글 3 좋아요 1 조회수 745

Spring Boot 3.0.2~ nativeQuery 작성시 에러

해결됨

재고시스템으로 알아보는 동시성이슈 해결방법

안녕하세요 강의듣다가 막혔다 해결한 부분이 있어서 혹여나 동일한 문제를 겪고 있으신 분이 계실까봐 공유드립니다. named lock파트의 native query를 작성하는 부분에서 강의 코드와 동일하게 작성하였음에도 불구하고 스프링 빈을 초기화 하는 과정에서 다음과 같은 에러를 만나게 되었습니다. 작성한 코드 @Query("select get_lock(:key, 3000)", nativeQuery = true) fun getLock(key: String) @Query("select release_lock(:key)", nativeQuery = true) fun releaseLock(key: String) 발생한 에러 Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void com.waterfogsw.cucurrentsolutions.domain.LockRepository.getLock(java.lang.String); Reason: Cannot invoke "String.contains(java.lang.CharSequence)" because "variable" is null at app//org.springframework.data.repository.query.QueryCreationException.create(QueryCreationException.java:101) at app//org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:115) at app//org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.mapMethodsToQuery(QueryExecutorMethodInterceptor.java:99) at app//org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$new$0(QueryExecutorMethodInterceptor.java:88) at java.base@17.0.6/java.util.Optional.map(Optional.java:260) at app//org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.<init>(QueryExecutorMethodInterceptor.java:88) at app//org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:357) at app//org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:279) at app//org.springframework.data.util.Lazy.getNullable(Lazy.java:245) at app//org.springframework.data.util.Lazy.get(Lazy.java:114) at app//org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:285) at app//org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1798) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1748) ... 122 more Caused by: java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because "variable" is null at org.springframework.data.jpa.repository.query.QueryUtils.createCountQueryFor(QueryUtils.java:620) at org.springframework.data.jpa.repository.query.DefaultQueryEnhancer.createCountQueryFor(DefaultQueryEnhancer.java:49) at org.springframework.data.jpa.repository.query.StringQuery.deriveCountQuery(StringQuery.java:111) at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.<init>(AbstractStringBasedJpaQuery.java:82) at org.springframework.data.jpa.repository.query.NativeJpaQuery.<init>(NativeJpaQuery.java:58) at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:53) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:170) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:252) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:95) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:111) ... 134 more 동일한 강의를 수강중이던 지인분과 함께 비교해본 결과 스프링 부트 버전 문제임을 확인하였습니다. 지인분은 data jpa 3.0.1 버전을 사용중이셨고, 저는 data jpa 3.0.3버전을 사용하였는데 3.0.2 이상 버전에서 nativeQuery=true 사용시 NullPointerException이 발생하는 이슈가 있음을 알려드립니다. 저는 부트버전을 3.0.1로 다운그레이드하여 정상적으로 실습 진행할 수 있었습니다 :) https://github.com/spring-projects/spring-data-jpa/issues/2812

  • spring
  • java
  • 동시성
ddd 댓글 2 좋아요 3 조회수 2172

CalculatorAddRequest 질문

미해결

자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]

안녕하세요 선생님. CalculatorAddRequest 클래스에서 number1과 number2를 private final로 설정하는 이유가 무엇인가요? 감사합니다.

  • java
  • mysql
  • spring
  • JPA
  • jpa
  • spring-boot
  • aws
댓글 1 좋아요 1 조회수 440

loanBook 메소드 만들 때 유저정보 가져오는 코드에서 오류가 납니다

해결됨

자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]

예외 처리 부분이니까 주석 처리하면 실행될까 했는데 아래와 같은 에러메시지가 나옵니다. 혹시 몰라 전체 코드를 깃헙에 업로드해놓겠습니다! https://github.com/you-eun-hye/library-app-Inflearn

  • java
  • mysql
  • aws
  • spring-boot
  • jpa
  • JPA
  • spring
유은혜 댓글 1 좋아요 1 조회수 398

getVideoFileCount 변수 선언하는 이유

미해결

나도코딩의 자바 기본편 - 풀코스 (20시간)

안녕하세요 선생님🙇‍♀️ 클래스_메소드 강의를 보다 궁금한 점이 생겨 질문 남깁니다. BlockBox 클래스에 두 메소드를 넣었고, 04_Method클래스에 두 메소드를 활용한 문장이 있었는데요. insertMemoryCard()는 그대로 사용했지만, getVideoFileCount()는 다시 변수로 선언한 이유가 무엇인가요? 감사합니다. void inserMemoryCard(int capacity) { System.out.println("메모리 카드가 삽입되었습니다."); System.out.println("용량은 " + capacity + "GB 입니다."); } void getVideoFileCount(int type) { if ( type == 1) { return 9; } else if ( type == 2) { return 1; } return 10; } b1.insertMemoryCard(256); int fileCount = b1.getVideoFileCount(1);

  • oop
  • 객체지향
  • java
고 예진 댓글 3 좋아요 0 조회수 677

'수업 노트를 확인해 주세요 :)'의 수업노트 위치가 어디인가요?

해결됨

탄탄한 백엔드 NestJS, 기초부터 심화까지

'첫 시작' 챕터 영상 레이아웃의 하단에 '수업 노트를 확인해 주세요 :)'가 있는데 해당하는 수업노트가 어디 있는건가요?

  • node.js
  • express
  • nodejs
  • nestjs
  • mongodb
  • ssr
  • NestJS
skkfea07 댓글 1 좋아요 2 조회수 389

csrf 토큰 시큐리티 6버전 변경사항

해결됨

스프링 시큐리티

안녕하세요 강의 잘 보고있습니다. csrf 토큰 값을 헤더에 넣어서 실습하는 부분 따라해봤는데 잘 안되서 코드를 뜯어봤습니다. 이번에 시큐리티 버전이 6으로 올라가면서 csrf 토큰을 인코딩해서 전달하고 이걸 디코딩하는 부분이 영상과 다른것같았습니다. 그래서 기본으로 제공하는 로그인 페이지에서 디버깅을 해보았는데 클라이언트에 전달한 csrf 토큰값이랑 실제 서버가 가지는 csrf 토큰값이 서로 달랐습니다. 이렇게되면 영상에서 보여주신 실습은 제대로 동작하지 않는게 맞나요? 해당 사진은 CsrfFilter에서 actualToken을 받아오기 위한XorCsrfTokenRequestAttributeHandler 클래스 내부에 존재하는 resolveCsrfTokenValue 함수의 소스코드입니다. 예제 따라하면 항상 마지막에 사이즈 비교하는 부분에서 걸렸습니다.

  • spring-boot
  • java
  • spring-security
  • Spring Security
  • spring-boot
김민종 댓글 2 좋아요 0 조회수 1319

암호화/인증 & 인가 과제 중 질문

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

updateUserPwd 구현 중에, 파라미터로 업데이트할 패스워드를 받도록 했습니다. 이 때, API 호출 시, 해당 파라미터의 최소 길이를 8 이상으로 하고 싶은데 따로 방법이 있을까요?

  • tdd
  • node.js
  • rest-api
  • javascript
  • express
  • docker
  • nestjs
  • nodejs
  • NestJS
ZZAMBA 댓글 1 좋아요 0 조회수 426

모임 만들기 페이지에서 시간을 설정할 때, 연월일 제외하고 시간만 입력하려면 어떻게 하면 되는지요?

미해결

스프링과 JPA 기반 웹 애플리케이션 개발

안녕하세요. 모임 만들기 페이지에서 시간을 설정할 때, 연월일 제외하고 시간만 입력하려면 어떻게 하면 되는지요? fragments.html 의 <div th:fragment="event-form (mode, action)"> 에서 <input id="endEnrollmentDateTime" type="datetime-local" 의 type 부분을 type="time" 으로 하고 Event 클래스에서 private LocalDateTime endEnrollmentDateTime; 을 private DateTime endEnrollmentDateTime; 로 변경하고 실행하면 html 상에서는 시간이 입력되나, DB 에는 insert 되어 있지 않습니다. 어떻게 하면 가능한지요? 자세한 설명 부탁드립니다. 그리고, 제공해 주신 소스를 다운로드해서 프로젝트를 실행한 후, 오른쪽 드롭다운 메뉴 중 스터디를 클릭해도 아무 동작이 일어나지 않습니다. 소스를 보면 <a class="dropdown-item" >스터디</a> 이렇게만 나와있고 th:href="@{}" 로 연결된 페이지가 없습니다. 이 부분 기능 구현은 안 해 놓으신 건지요? 프로필 페이지에서도 왼쪽 프로필 사진 밑에 있는 스터디 버튼을 누르면 Study 라고만 나오고 별다른 페이지가 나오지 않습니다. 이 부분도 기능 구현은 안 해 놓으신 건지요?

  • java
  • spring
  • spring-boot
  • JPA
  • jpa
  • spring-boot
  • thymeleaf
박종성 댓글 1 좋아요 0 조회수 480

Postman 406, 404 에러

미해결

실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화

첫번째 PostMapping 으로 했을때 값 등록은 잘되는데 406 에러가 나옵니다. 두번째 update 할때는 값도 변경안되고 404 에러가 납니다..

  • spring
  • spring-boot
  • jpa
  • JPA
  • java
114tla 댓글 4 좋아요 0 조회수 1716

안녕하세요 강의를 따라가던 중 한 번의 이벤트임에도 두 번이 발생합니다.

미해결

탄탄한 백엔드 NestJS, 기초부터 심화까지

위에 이미지처럼 클라이언트에서 emit을 발생시켰을 때 서버에서 2번이 찍히고, username을 클라이언트로 전달해줄 때도, 클라이언트에서 2번이 찍힙니다. afterInit()함수 내부의 로거도 두번 작동하는데 왜 이럴까요?

  • node.js
  • mongodb
  • express
  • nodejs
  • nestjs
  • ssr
  • NestJS
TTAE TTAE 댓글 1 좋아요 1 조회수 524

고아 객체 생성 조건

미해결

자바 ORM 표준 JPA 프로그래밍 - 기본편

안녕하세요 영한님! 질문드립니다. 고아 객체는 부모 엔티티와 연관관계가 끊어진 자식 엔티티 라고 이해했습니다. 고아 객체가 생성되는 조건은 부모 엔티티 삭제 부모 엔티티가 삭제 되면 자식 엔티티를 고아객체로 판단 합니다. e.g) em.remove(parent); 부모 엔티티에 있는 자식 엔티티 컬렉션 제거 연관관계가 끊어진 자식 객체를 고아객체로 판단 합니다. e.g) parent.getChild().remove(0); 결과적으로 orphanRemoval = true 를 설정하면 자식 엔티티(고아 객체)는 부모 엔티티와 함께 삭제 되거나 자식 엔티티(고아 객체)만 삭제 된다. 맞게 이해하고 있는 것 일까요? 감사합니다.^^

  • jpa
  • java
  • JPA
개발하는쿼카 댓글 1 좋아요 4 조회수 682

액세스토큰을 변수로 저장하면 생기는 문제점

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

안녕하세요. 강의중에 액세스토큰을 변수로 req.header에 저장하면 아래와 같이 3가지 문제점이 있다는 것을 구글링을 통해서 확인했습니다. 1.보안: 액세스토큰을 req.header에 변수로서의 토큰은 공격자에 의해 가로채기에 취약합니다. 2.확장성: 애플리케이션에 많은 수의 요청이 있는 경우 req.header 의 변수는 크기가 커지고 성능 문제가 발생할 수 있습니다. 3.지속성: req.header 에 액세스 토큰을 저장하는 것은 영구적이지 않습니다. 사용자가 페이지를 새로 고치거나 브라우저를 닫으면 액세스 토큰이 손실됩니다. 이로 인해 사용자가 보호된 리소스 에 액세스하기 위해 다시 로그인해야 할 수 있습니다. 질문1) 3번 지속성문제의 경우, 브라우저를 새로고침하게 되면, 액세스 토큰이 사라지게 되니 오히려 보안이 좋다고 생각해야 할까요? accessToken이 수업에서는 10분으 로 만료기간을 설정했는데, restoreAccessToken API가 있기 때문에 acessToken을 req.header에 변수로 저장해도 문제가 되지 않을까요? 질문2) 액세스토큰 만료시간을 10분 ~30분 으로 짧게 잡으신 이유가 1번 문제점 보안의 이유라고 생각하면 될까요? 질문3) 선생님, 좋은 강의 해주셔서 진심으로 감사합니다. 저는 선생님의 백엔드와 프론트 강의를 수강후 실제 웹 서비스를 런칭하기위해서 수업을 듣고 있습니다. 현재는 백엔드 강의를 수강중입니다. 실제 웹 서비스런칭시 accessToken을 req.header에 변수로서 저장하고, refreshToken은 쿠키에 저장하는 게 올바른 방법인가요? refreshToken을 수업에서 가르쳐주신 대로 secure : true, httponly: true와 같이 배포환경으로 바꿔서 배포하게 된다면 보안상 안전할까요? 질문4) 구글링을 해보니, 리프레시 토큰을 Redis에 저장하고, 액세스토큰은 쿠키에 저장하는 방법도 있는 것을 확인했습니다. 액세스토큰의 만료기간을 10분으로 잡고, 리프레시토큰의 만료기간을 2주로 잡을 경우, restoreRefreshToken API 때문에 Redis DB에 자주 접속하게 되어서 DB 사용료가 많이 청구 되지는 않을까요? 서버를 stateless 상태로 웹 서비스를 런칭하기 위해서는 액세스토큰과 리프레시 토큰을 어떻게 저장해야 할까요? 가장 안전한 방법이라고 할 수 있을까요? 감사합니다.

  • NestJS
  • node.js
  • express
  • docker
  • rest-api
  • nodejs
  • rest-api
  • nestjs
  • javascript
  • tdd
LI 댓글 1 좋아요 0 조회수 868

GqlExecutionContext가 없다고 나옵니다.

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

import { GqlExecutionContext } from '@nestjs/graphql'; @nestjs/graphql 모둘에 내보낸 맴버 GqlExecutionContext가 없다고 에러가 뜹니다

  • node.js
  • nodejs
  • tdd
  • docker
  • rest-api
  • express
  • javascript
  • nestjs
  • NestJS
Han Lee 댓글 1 좋아요 0 조회수 303

인기 태그

인프런 TOP Writers

주간 인기글