Skip to content

Commit

Permalink
[FIX] 시큐리티 의존성 제거 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
kssumin authored Oct 7, 2023
2 parents 2a8ba81 + b61f276 commit 3c1153d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

// infra
implementation 'org.springframework.boot:spring-boot-starter-security'

// encryption
implementation group: 'org.mindrot', name: 'jbcrypt', version: '0.4'

// jwt
implementation "io.jsonwebtoken:jjwt-api:${jsonwebtokenVersion}"
implementation "io.jsonwebtoken:jjwt-impl:${jsonwebtokenVersion}"
implementation "io.jsonwebtoken:jjwt-jackson:${jsonwebtokenVersion}"

}

test {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/kakao/golajuma/auth/domain/helper/Encoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.kakao.golajuma.auth.domain.helper;

import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Component;

@Component
public class Encoder {
public String encode(String raw) {
return BCrypt.hashpw(raw, BCrypt.gensalt());
}

public boolean matches(String raw, String hashed) {
return BCrypt.checkpw(raw, hashed);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.kakao.golajuma.auth.infra.converter;

import com.kakao.golajuma.auth.domain.helper.Encoder;
import com.kakao.golajuma.auth.infra.entity.UserEntity;
import com.kakao.golajuma.auth.web.dto.request.SaveUserRequest;
import com.kakao.golajuma.common.support.converter.AbstractEntityConverter;
import lombok.RequiredArgsConstructor;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class UserEntityConverter implements AbstractEntityConverter<UserEntity, SaveUserRequest> {

private final PasswordEncoder passwordEncoder;
private final Encoder encoder;

@Override
public UserEntity toEntity(SaveUserRequest source) {
return UserEntity.builder()
.nickname(source.getNickname())
.email(source.getEmail())
.password(passwordEncoder.encode(source.getPassword()))
.password(encoder.encode(source.getPassword()))
.build();
}
}

0 comments on commit 3c1153d

Please sign in to comment.