terry960302 / sample-spring-graphql Goto Github PK
View Code? Open in Web Editor NEW(Kotlin, SpringBoot, DGS graphql)Spring Boot + Graphql 을 학습하기 위해 넷플릭스 DGS 프레임워크를 적용하여 프로젝트를 만들었습니다. 사이드프로젝트에 적용하기 위해 공부용으로 제작했습니다.
(Kotlin, SpringBoot, DGS graphql)Spring Boot + Graphql 을 학습하기 위해 넷플릭스 DGS 프레임워크를 적용하여 프로젝트를 만들었습니다. 사이드프로젝트에 적용하기 위해 공부용으로 제작했습니다.
안녕하세요 spring, graphql, dgs 찾아보다가 오게되었습니다.
테스트해보던중 CredentialService.signIn 에 password 비교부분에 아래 블로그 내용과 동일한 문제가 있는거 같아요
passwordEncoder.matches(password, userCred.get().password) 비교하게 변경해보니 잘되는것 같습니다.
작성해주신 sapmle로 많이 도움이되었습니다. 재미있게 보고 갑니다 감사합니다.
참조 : https://cantcoding.tistory.com/69
원인
원인을 파악하기 위해 여러가지를 찍어보던중 해쉬로 encode되는 값이 매번 달라지는 것을 알아냈다.
System.out.println(result.getPassword());
System.out.println(bCryptPasswordEncoder.encode("12345"));
같아야 하는 값이 계속 다르게 출력되고 있었다. 그래서 BCrypt에 대해서 조사해봤다.
BCrypt는 해쉬에 솔트를 더하여 매번 다르게 값이 출력되게 만들어서 보안을 더 높인 암호화 방식이다.
따라서 솔트가 매번 다르기 때문에 encode된 값과 equals로 비교가 항상 다르기 때문에 테스트가 통과될 수 없는 구조였다. 해쉬를 하면 매번 같은 값이 나올것이라는 착각이였다.
해결방법
equals로 비교할 수 없는 BCryptPasswordEncoder은 비교 메서드 matches를 제공한다.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.