http://localhost:8888/ecommerce/default 에서는 { name : "ecommerce", profiles : [ "default" ], label : null, version : "f45bf692a6cb54252ea12041f0aa92a71964a5f7", state : null, propertySources : [ { name : "file:///C:\\Users\\ydj90\\Downloads\\git/file:C:\Users\ydj90\Downloads\git\ecommerce.yml", source : { token.expiration_time : 864000000, gateway.ip : "172.30.1.33", token.secret : "userToken_token" } } ] } http://localhost:8888/user-service/default 에서는 { name : "user-service", profiles : [ "default" ], label : null, version : "f45bf692a6cb54252ea12041f0aa92a71964a5f7", state : null, propertySources : [ { name : "file:///C:\\Users\\ydj90\\Downloads\\git/file:C:\Users\ydj90\Downloads\git\user-service.yml", source : { spring.datasource.url : "jdbc:h2:mem:testdb", spring.datasource.driver-class-name : "org.h2.Driver", spring.datasource.generate-unique-name : false, token.expiration_time : 864000000, gateway.ip : "172.30.1.33", order_service.url : " http://ORDER-SERVICE/order-service/%s/orders ", spring.datasource.username : "sa", token.secret : "userToken_token" } } ] } 이와 같이 token.secret이 같은데 왜 subject가 null값이 되는지 이유를 알 수 가 없습니다. login하고 나온 header값을 가지고 bearer에 넣어 인증하는 방식이 아닙니까? 이유를 잘 모르겠습니다. JWT token is not valid 이게 왜 뜨는지 subject = Jwts.parser().setSigningKey(env.getProperty("token.secret")) .parseClaimsJws(jwt).getBody() .getSubject(); 여기서 왜 null값으로 값을 반환하는지 이해를 할 수가 없습니다.
많은 분들이 남겨준 것처럼 typeorm 0.3.x 버전 오류로 인해 저도 조금 고생했습니다. 공식문서 참조하며 해결했습니다. https://docs.nestjs.com/techniques/database#repository-pattern typeorm 0.3.x 버전은 @EntityRepository 가 deprecated 됐기 때문에 custom Repository를 생성해주었습니다. custom Repository 생성은 아래 블로그를 참조했습니다. https://velog.io/@pk3669/typeorm-0.3.x-EntityRepository-%EB%8F%8C%EB%A0%A4%EC%A4%98 위 링크 내용을 참조로 typeorm-ex.decorator.ts 파일과 typeorm-ex.module.ts 파일을 생성합니다. 해당 링크가 문제가 될 시 링크 바로 삭제하도록 하겠습니다 ㅠ.. typeorm.config.ts entities 를 불러오기 위해 경로 또는 저희가 설정한 entitiy 를 바로 집어 넣었습니다. autoLoadEntities: true - entities를 빼고 해당 옵션을 넣어서 자동으로 불러올 수도 있습니다. (본인이 직접 컨트롤 하는 것이 아니기 때문에 부정확해질 수도 있음.) board.repository.ts 저희 repository에 @EntityRepository 대신 CustomRepository(Board) 을 넣어줍니다. board.module.ts imports는 custom Repository를 불러와야 하기 때문에, 저희가 만든 TypeOrmExModule class의 forCustomRepository에 저희 Repository를 넣어줍니다. board.service.ts 기존에 @EntityRepository 를 사용한 경우 @InjectRepository 데코레이터를 사용했지만 해당 부분을 유지하면 오류가 발생한다고 합니다. 따라서 @CustomRepository 를 생성하여 사용하는 경우 @InjectRepository 를 제거하고 사용합니다. 이러면 아직 findOne 메소드의 id는 빨간줄인데 findOne 메소드는 options 로 FindOneOptions Parameter를 받게 되어 있고 해당 FindOneOptions 중 저희가 사용할 것은 where 옵션을 사용해야 해당 id 를 통해 데이터를 불러올 수 있습니다. 그래서 최종적으로 findOne 메소드는 아래 그림과 바꿔주면 해당 메소드를 사용할 수 있게 됩니다.
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
안녕하세요? 초보부터 중급까지 아주 재미있게 진행해 나가고 있습니다. 강의와 직접적인 연관은 아니지만, 간접적인 연관인 부분이 궁금해서 질문 드립니다. 클라이언트 기반의 로직은 대부분 강의에 나와 있어서 프로세스가 이해가 되는데요. 서버쪽은 대략은 짐작이 되나, 구체적으로 어떻게 돌아가는지 알고 싶은데, 어떤 자료를 어디서 참고해야 될지 조언을 구합니다. 예를 들면 인증 API 중에 /auth/login API를 사용하면 정해진 유저 ( test@codefactory.ai :testtest)에 대해 Base64로 인코딩된 값으로 서버로 던지면 서버에서 디코딩해서 원래의 값을 찾은 후 DB를 검색할 거 같은데, PPT에 설명해주신 자료에 보면 DB를 사용하지 않는다? 라고 하셔서 그럼 어떻게 인증을 하지? 라는 궁금증이 생겼습니다. 결론적으로 토큰기반 인증시스템에 대해 서버쪽 프로세스를 알고 싶은데, 관련 자료 알고 계신부분이 있다면 조언 부탁드립니다. 아울러 자바 (또는 스프링) 기반의 샘플 소스 코드도 있다면 더욱 좋고요.. 두서 없이 질문 드려서 죄송합니다.
authenticationManagerBuilder.getObject(); This object has not been built at org.springframework.security .config.annotation.AbstractSecurityBuilder.getObject( AbstractSecurityBuilder.java:51 ) ~[spring-security-config-5.7.4.jar:5.7.4] 왜그러는걸까요 추가로 DaoAuthenticationProvider에서 자동으로 additionalAuthenticationChecks해줘서 String presentedPassword = authentication.getCredentials().toString(); if (!this.passwordEncoder.matches(presentedPassword, userDetails.getPassword())) { this.logger.debug("Failed to authenticate since password does not match stored value"); throw new BadCredentialsException(this.messages .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); } 패스워드를 체크할 수 있다는 글을 보았는데 확인해보니 deprecation이 되어있습니다. 사용하지 않는게 좋나요?
이거 강의 다시 찍어주시면 안되나여 인터넷 자료만 보고 따라 하기 넘 어렵 ; stackover flow 에서 뭐라는건지 잘몰겠습니다 ㅋㅋ; https://stackoverflow.com/questions/71557301/how-to-workraound-this-typeorm-error-entityrepository-is-deprecated-use-repo
signWith(SignatureAlgorithm.HS256, env.getProperty("token.secret")) jwt 버전 0.10 버전이상부터는 관련 내용이 문자열이 작다고 합니다. 혹시 0.11버전에 맞춰서 한다면 어떤 방식으로 해야합니까? 추가적으로 signWith의 deprecated 또한 해결 하는 방법에 대해 알려주시면 감사하겠습니다. => document 사이트 위치라도 알려주시면 직접찾아보겠습니다. 전체적으로 따라해봤는데 해쉬값이 작다고 하여 관련내용에 대해 이해를 하지 못해서 작성합니다.
WebSecurityConfigurerAdapter 가 이제 더 이상 지원을 하지 않는다고 하여 WebSecurityFilterChain으로 하래서 시도중인데 계속하여 401 에러가 뜹니다... @EnableWebSecurity public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception{ http .authorizeRequests() .antMatchers("api/hello").permitAll() .anyRequest().authenticated(); return http.build(); } }
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 11분 42초에 나오는 시점에 permitAll() 때문에 로그아웃 상태일때 처럼 되야되는데 login 창이 계속 나옵니다. user,manager도 403이 안나오고 login으로 갑니다..
Description: Parameter 0 of constructor in com.example.demo.service.CustomUserDetailsService required a bean of type 'com.example.demo.repository.UserRepository' that could not be found. Action: Consider defining a bean of type 'com.example.demo.repository.UserRepository' in your configuration. 구글링을 해봐도 전혀 해결되지 않아요 ㅠㅠ
저는 id => { id, user} 로 변경하니 type 에러가 발생했습니다. 그래서 (mac기준) 커맨드 + delete 함수 클릭 criteria 변수에 { id:number, user:User} 타입 추가 저장 이 방법으로 해결했습니다. 별거 아니지만 저는 엄청 헤매서 공유차 남깁니다..!
강의 잘 듣고 있습니다 감사합니다! 혹시 스프링 2.7.3 사용, 자바 11 사용 중인데 java: package io.jsonwebtoken.io does not exist import io.jsonwebtoken.*; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; 요 3개를 import 하지 못합니다... java: package io.jsonwebtoken.io does not exist 오류가 뜹니다... 바쁘신데 죄송합니다.
안녕하세요 좋은 강의 잘듣고 있습니다. 다름이 아니라 강의를 듣는중에 의문이 들어 질문 드립니다. 세션과 JWT의 차이가 세션을 유지하냐 안하냐의 차이로 알고 있는데 JWT를 쓸때 authenticaion 객체가 session 영역에 저장됨 . 이라고 하셨는데, 인증정보를 세션 저장소에 저장하게 되면 결국 해당 세션을 유지하는 것 아닌가요? 차이가 없어지는 것 아닌가 싶어서 질문 남깁니다. 아, 그리고 추가로 github에 @AuthenticationPrincipal가 사용불가능이라 하셨는데 컨트롤러에서 불러와 보니까 잘 불러와지던데 제가 뭘 잘못한 걸까요?
@Component public class CustomBCryptPasswordEncoder extends BCryptPasswordEncoder { } 위 처럼 따로 BcryptPasswordEncoder를 만들어주고 컨테이너에 등록합니다! //해당 메서드의 리턴되는 오브젝트를 IoC로 등록해준다. /* @Bean() public BCryptPasswordEncoder encoder(){ return new BCryptPasswordEncoder(); } */ 그리고 위의 코드(SecurityConfig)를 저처럼 주석으로 처리해주세요! 순환 참조가 나는 이유: 1. SpringContainer에서 처음 빈으로 등록하기 위해 객체를 생성 하여 줍니다(싱클톤) 2. 그래서 SecurityConfig 객체를 생성하던 중 PrincipalOauth2UserService객체를 의존하고있네요? 그래서 PrincipalOauth2UserService를 만들어 주는데.. 3. 어라? PrincipalOauth2UserService에서도 SecurityConfig에서 빈으로 등록한 BCryptPasswordEncoder를 참조하고있네?? 4. 오잉? 스프링 :참조가 순환되넹?아아아아아악! => 오류 즉, SecurityConfig -> PrincipalOauth2UserService, 다시 PrincipalOauth2UserService->SecurityConfig 그래서 저는 SecuritiConfig -> PrincipalOauth2UserService-> CustomBCryptPasswordEncoder 로 구조를 변경하였습니다.
안녕하세요. 강의 너무 잘 듣고 있습니다. 다름이 아니라 Authentication authentication = authenticationManager.authenticate(authenticationToken); 를 실행하는 과정에서 WARN 24292 --- [nio-8080-exec-1] o.s.s.c.bcrypt.BCryptPasswordEncoder : Empty encoded password 위와 같은 경고창이 뜨면서 실행되지 않습니다. 강의를 3번 돌려보았고, 소스상에는 문제가 없는데 왜이러는지 모르겠습니다. 참고로 회원가입을할때 Password를 똑같이 "1234"로 입력하여도 DB에 Encoding 된 비밀번호는 동일하지 않습니다.