HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
🧚
[1기]최종 프로젝트 데브코스
/
📜
[팀13] 사각사각 ✏️
/
🎊
기술 문서
/
🔐
로그인
🔐

로그인

DB설계
 
notion image
 
data.sql
INSERT INTO permission(id, name) VALUES (1, 'ROLE_USER'), (2, 'ROLE_AUTHOR'), (3, 'ROLE_ADMIN'), ; INSERT INTO part(id, name) VALUES (1, 'USER_GROUP'), (2, 'AUTHOR_GROUP'), (3, 'ADMIN_GROUP)' ; -- USER_GROUP (ROLE_USER) -- AUTHOR_GROUP (ROLE_USER, ROLE_AUTHOR) INSERT INTO part_permission(id, part_id, permission_id) VALUES (1, 1, 1), (2, 2, 1), (3, 2, 2), (4, 3, 3) ; -- user1 비밀번호 : user123 -- user2 비밀번호 : user123 -- author 비밀번호 : author123 -- admin 비밀번호 : user123 INSERT INTO user(email, password, username, nickname, part_id) VALUES ('user1@test.com', '$2a$10$B32L76wyCEGqG/UVKPYk9uqZHCWb7k4ci98VTQ7l.dCEib/kzpKGe', 'user', 'userNick1', 1), ('user2@test.com', '$2a$10$B32L76wyCEGqG/UVKPYk9uqZHCWb7k4ci98VTQ7l.dCEib/kzpKGe', 'user', 'userNick2', 1), ('author@test.com', '$2a$10$SGKM3w/VgEWA8BwCuqvJsOTewYo5rFpTn3UZdrFJGP7ePQE7TdgBG', 'author', 'authorNick', 2), ('admin@test.com', '$2a$10$B32L76wyCEGqG/UVKPYk9uqZHCWb7k4ci98VTQ7l.dCEib/kzpKGe', 'admin', 'admin', 3), ; INSERT INTO writer(follow_count,user_id ) VALUES (0,6);
 
  1. JWT 관련 설정을 yml파일에 넣는다.
jwt: header: token issuer: prgrms client-secret: EENY5W0eegTf1naQB2eDeyCLl5kRS2b8xa5c4qLdS0hmVjtbvo8tOyhPMcAmtPuQ expiry-seconds: 3600 // 만료시간을 1시간으로 지정
[JWT 토큰]
  1. JwtConfig를 만든다.
@Component @Getter @Setter @ConfigurationProperties(prefix = "jwt") public class JwtConfig { private String header; private String issuer; private String clientSecret; private int expirySeconds; }
 
email을 통해서 토큰을 생성
notion image
위에서 만든 토큰을 디코딩할 경우 밑에 응답값으로 내려짐
notion image
 
1차 로그인
→ 이메일과 비밀번호를 통해 로그인 진행
[사용자]
notion image
[작가]
notion image
Spring security hasRole, hasAuthority 차이점
Role 은 그냥 신분증이라고 생각하면 되고 Authority 할 수 있는 기능으로 생각하며 된다. hasRole("ADMIN") 이라고 작성시 userDetailsService 에서 Authority 를 가져와서 확인할 때 자동으로 ROLE 이라는 접두..
Spring security hasRole, hasAuthority 차이점
https://devnot.tistory.com/132
Spring security hasRole, hasAuthority 차이점