[ADD] SWAGGER 수정

main
bjkim 10 months ago
parent 4f8519bb2f
commit 4bda28c8b6

@ -14,4 +14,6 @@ public interface RefreshTokenRepository extends JpaRepository<RefreshToken, Long
@Modifying @Modifying
int deleteByUser(User user); int deleteByUser(User user);
void deleteByUserId(Long userId);
} }

@ -23,16 +23,16 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class JwtUtils { public class JwtUtils {
@Value("${bezkoder.app.jwtSecret}") @Value("${cuuva.app.jwtSecret}")
private String jwtSecret; private String jwtSecret;
@Value("${bezkoder.app.jwtExpirationMs}") @Value("${cuuva.app.jwtExpirationMs}")
private int jwtExpirationMs; private int jwtExpirationMs;
@Value("${bezkoder.app.jwtCookieName}") @Value("${cuuva.app.jwtCookieName}")
private String jwtCookie; private String jwtCookie;
@Value("${bezkoder.app.jwtRefreshCookieName}") @Value("${cuuva.app.jwtRefreshCookieName}")
private String jwtRefreshCookie; private String jwtRefreshCookie;
public ResponseCookie generateJwtCookie(UserDetailsImpl userPrincipal) { public ResponseCookie generateJwtCookie(UserDetailsImpl userPrincipal) {
@ -108,8 +108,18 @@ public class JwtUtils {
.build(); .build();
} }
private String getCookieValueByName(HttpServletRequest request, String name) { // private String getCookieValueByName(HttpServletRequest request, String name) {
Cookie cookie = WebUtils.getCookie(request, name); // Cookie cookie = WebUtils.getCookie(request, name);
return cookie != null ? cookie.getValue() : null; // return cookie != null ? cookie.getValue() : null;
} // }
private String getCookieValueByName(HttpServletRequest request, String name) {
Cookie cookie = WebUtils.getCookie(request, name);
if (cookie == null) {
System.out.println("Cookie with name '" + name + "' not found");
return null;
}
System.out.println("Found cookie: " + cookie.getName() + " = " + cookie.getValue());
return cookie.getValue();
}
} }

@ -4,10 +4,10 @@ import java.time.Instant;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import kr.re.etri.autoflow.exception.TokenRefreshException; import kr.re.etri.autoflow.exception.TokenRefreshException;
import kr.re.etri.autoflow.models.RefreshToken; import kr.re.etri.autoflow.models.RefreshToken;
@ -16,7 +16,7 @@ import kr.re.etri.autoflow.repository.UserRepository;
@Service @Service
public class RefreshTokenService { public class RefreshTokenService {
@Value("${bezkoder.app.jwtRefreshExpirationMs}") @Value("${cuuva.app.jwtRefreshExpirationMs}")
private Long refreshTokenDurationMs; private Long refreshTokenDurationMs;
@Autowired @Autowired
@ -29,6 +29,7 @@ public class RefreshTokenService {
return refreshTokenRepository.findByToken(token); return refreshTokenRepository.findByToken(token);
} }
@Transactional
public RefreshToken createRefreshToken(Long userId) { public RefreshToken createRefreshToken(Long userId) {
RefreshToken refreshToken = new RefreshToken(); RefreshToken refreshToken = new RefreshToken();
@ -50,7 +51,7 @@ public class RefreshTokenService {
} }
@Transactional @Transactional
public int deleteByUserId(Long userId) { public void deleteByUserId(Long userId) {
return refreshTokenRepository.deleteByUser(userRepository.findById(userId).get()); refreshTokenRepository.deleteByUserId(userId);
} }
} }

@ -17,15 +17,13 @@ spring.jpa.defer-datasource-initialization=true
# App Properties # App Properties
bezkoder.app.jwtCookieName= bezkoder-jwt cuuva.app.jwtCookieName=cuuva-jwt
bezkoder.app.jwtRefreshCookieName= bezkoder-jwt-refresh cuuva.app.jwtRefreshCookieName=cuuva-jwt-refresh
bezkoder.app.jwtSecret= 275511b31c520562d69802ce4a913773102563891563a24062f44b3f312ca2bd034440e81836d1b4ccf4195f43db4c81a4e489a41f1ae0967afe468c9a361f4d cuuva.app.jwtSecret= 275511b31c520562d69802ce4a913773102563891563a24062f44b3f312ca2bd034440e81836d1b4ccf4195f43db4c81a4e489a41f1ae0967afe468c9a361f4d
#bezkoder.app.jwtExpirationMs= 86400000
#bezkoder.app.jwtRefreshExpirationMs= 86400000
## For test ## For test
bezkoder.app.jwtExpirationMs= 60000 cuuva.app.jwtExpirationMs= 60000
bezkoder.app.jwtRefreshExpirationMs= 180000 cuuva.app.jwtRefreshExpirationMs= 180000
# SQL ?? ?? # SQL ?? ??
spring.jpa.show-sql=true spring.jpa.show-sql=true

Loading…
Cancel
Save