Compare commits

..

1 Commits

6 changed files with 13 additions and 47 deletions

View File

@@ -1,12 +0,0 @@
FROM openjdk:11-jre-slim
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY build/libs/server-0.0.1-SNAPSHOT.jar application.jar
EXPOSE 8443
EXPOSE 8080
CMD ["java", "-jar", "application.jar"]

View File

@@ -28,8 +28,9 @@ public class RefreshToken {
this.token = token;
}
public void changeToken(String token) {
public RefreshToken changeToken(String token) {
this.token = token;
return this;
}
}

View File

@@ -27,6 +27,7 @@ public class JwtProvider {
private static final String AUTHORITIES_KEY = "auth";
private static final String AUTHORITIES_DELIMITER = ",";
private static final String ROLE = "ROLE_";
private final Key key;
private final String prefix;
@@ -89,7 +90,7 @@ public class JwtProvider {
}
private String makeRoleName(String role) {
return "ROLE_" + role.toUpperCase();
return role.contains(ROLE) ? role.toUpperCase() : ROLE + role.toUpperCase();
}
public Authentication getAuthentication(String token) {

View File

@@ -5,8 +5,8 @@ import com.ticketing.server.global.redis.RefreshRedisRepository;
import com.ticketing.server.global.redis.RefreshToken;
import com.ticketing.server.global.security.jwt.JwtProperties;
import com.ticketing.server.global.security.jwt.JwtProvider;
import com.ticketing.server.user.service.dto.TokenDTO;
import com.ticketing.server.user.service.dto.DeleteRefreshTokenDTO;
import com.ticketing.server.user.service.dto.TokenDTO;
import com.ticketing.server.user.service.interfaces.AuthenticationService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -40,8 +40,14 @@ public class AuthenticationServiceImpl implements AuthenticationService {
// refresh 토큰이 있으면 수정, 없으면 생성
refreshRedisRepository.findByEmail(email)
.ifPresentOrElse(
tokenEntity -> tokenEntity.changeToken(tokenDto.getRefreshToken()),
() -> refreshRedisRepository.save(new RefreshToken(email, tokenDto.getRefreshToken()))
tokenEntity -> refreshRedisRepository.save(
tokenEntity.changeToken(
tokenDto.getRefreshToken()
)
),
() -> refreshRedisRepository.save(
new RefreshToken(email, tokenDto.getRefreshToken())
)
);
return tokenDto;

View File

@@ -1,30 +0,0 @@
server:
port: 8443
address: 0.0.0.0
http:
port: 8080
ssl:
key-store: classpath:keystore/ticketing.p12
key-store-password: ENC(OMvGcpZLpggFTiGNkqNe66Zq/SmJXF6o)
key-store-type: PKCS12
spring:
datasource:
url: jdbc:mysql://ticketing-db/ticketing?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
username: ENC(LowN1n4w0Ep/DqLD8+q5Bq6AXM4b8e3V)
password: ENC(OMvGcpZLpggFTiGNkqNe66Zq/SmJXF6o)
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
properties:
hibernate:
show_sql: true
format_sql: true
hibernate:
ddl-auto: validate
redis:
host: 172.18.0.3
port: 6379