diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 616039b..89565df 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -2,9 +2,7 @@ name: CI / CD on: push: - branches: [ "master", "develop" ] - pull_request: - branches: [ "master", "develop" ] + branches: [ "develop" ] jobs: ci-cd: @@ -12,12 +10,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Prepare secure key manager certKey file - run: - echo ${{ secrets.SECURE_KEY_MANAGER_CERT_KEY }} > t3team-skm-cert.txt - mkdir src/main/resources/key - base64 -d t3team-skm-cert.txt > src/main/resources/key/t3team-skm-cert.p12 - - name: Set up JDK 11 uses: actions/setup-java@v3 with: @@ -26,7 +18,7 @@ jobs: cache: maven - name: build - run: ${{ secrets.MAVEN_OPTION_PACKAGES }} + run: mvn package - name : sonar qube run: mvn sonar:sonar -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} -Dsonar.login=${{ secrets.SONAR_LOGIN_TOKEN }} @@ -50,4 +42,4 @@ jobs: key: ${{ secrets.SSH_KEY }} port: ${{ secrets.SSH_PORT }} script_stop: true - script: "kill $(lsof -i:9090 -t) & nohup java -jar ~/target/*.jar > ~/nohup.log 2>&1 &" + script: "kill $(lsof -i:8080 -t) & nohup java -jar ~/target/*.jar > ~/nohup.log 2>&1 &" diff --git a/src/main/java/com/t3t/apigateway/common/JwtUtils.java b/src/main/java/com/t3t/apigateway/common/JwtUtils.java index 998ed08..f906485 100644 --- a/src/main/java/com/t3t/apigateway/common/JwtUtils.java +++ b/src/main/java/com/t3t/apigateway/common/JwtUtils.java @@ -2,20 +2,20 @@ import com.t3t.apigateway.exception.TokenNotAuthenticatedExceptions; import com.t3t.apigateway.exception.TokenNotConsistedProperly; -import com.t3t.apigateway.keymanager.properties.SecretKeyProperties; -import com.t3t.apigateway.keymanager.service.SecretKeyManagerService; import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.JwtException; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.security.Keys; import io.jsonwebtoken.security.SignatureException; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import java.security.Key; import java.time.Duration; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Base64; + +import java.security.Key; import java.util.Date; /** @@ -26,8 +26,7 @@ public class JwtUtils { private Key key; - public JwtUtils(SecretKeyManagerService secretKeyManagerService, SecretKeyProperties secretKeyProperties) { - String secret = secretKeyManagerService.getSecretValue(secretKeyProperties.getJwtSecretKeyId()); + public JwtUtils(@Value("${t3t.secret.key}") String secret) { byte[] byteSecretKey = Base64.getDecoder().decode(secret); key = Keys.hmacShaKeyFor(byteSecretKey); } diff --git a/src/main/java/com/t3t/apigateway/config/RedisConfig.java b/src/main/java/com/t3t/apigateway/config/RedisConfig.java index 23fbb50..4383ecd 100644 --- a/src/main/java/com/t3t/apigateway/config/RedisConfig.java +++ b/src/main/java/com/t3t/apigateway/config/RedisConfig.java @@ -1,11 +1,8 @@ package com.t3t.apigateway.config; -import com.t3t.apigateway.keymanager.properties.SecretKeyProperties; -import com.t3t.apigateway.keymanager.service.SecretKeyManagerService; -import com.t3t.apigateway.property.RedisProperties; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; @@ -16,35 +13,32 @@ @Configuration @EnableRedisRepositories public class RedisConfig { - @Bean - public RedisProperties redisProperties(SecretKeyManagerService secretKeyManagerService, - SecretKeyProperties secretKeyProperties, - Environment environment){ + @Value("${spring.redis.host}") + private String host; - String activeProfile = environment.getActiveProfiles()[0]; + @Value("${spring.redis.port}") + private int port; - return RedisProperties.builder() - .host(secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisIpAddressKeyId())) - .port(Integer.valueOf(secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisPortKeyId()))) - .password(secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisPasswordKeyId())) - .database(20) - .build(); - } + @Value("${spring.redis.database}") + private int database; + + @Value("${spring.redis.password}") + private String password; @Bean - public RedisConnectionFactory redisConnectionFactory(RedisProperties redisProperties){ - RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(redisProperties.getHost(), redisProperties.getPort()); - configuration.setPassword(redisProperties.getPassword()); - configuration.setDatabase(redisProperties.getDatabase()); + public RedisConnectionFactory redisConnectionFactory(){ + RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(host, port); + configuration.setPassword(password); + configuration.setDatabase(database); return new LettuceConnectionFactory(configuration); } @Bean - public RedisTemplate redisTemplate(RedisProperties redisProperties){ + public RedisTemplate redisTemplate(){ RedisTemplate redisTemplate = new RedisTemplate<>(); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new StringRedisSerializer()); - redisTemplate.setConnectionFactory(redisConnectionFactory(redisProperties)); + redisTemplate.setConnectionFactory(redisConnectionFactory()); return redisTemplate; } } diff --git a/src/main/java/com/t3t/apigateway/property/RedisProperties.java b/src/main/java/com/t3t/apigateway/property/RedisProperties.java deleted file mode 100644 index ed67799..0000000 --- a/src/main/java/com/t3t/apigateway/property/RedisProperties.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.t3t.apigateway.property; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class RedisProperties { - private String host; - private Integer port; - private Integer database; - private String password; -} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fa28295..101e8b3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,6 +8,11 @@ spring: profiles: active: dev + redis: + host: ${redisHost} + port: ${redisPort} + password: ${redisPassword} + database: ${redisDatabase} auth: host: ${authHost} @@ -22,6 +27,9 @@ eureka: t3t: + secret: + key: ${jwtSecretKey} + secretKeyManager: certKeyPath: ${secretKeyManagerCertKeyPath} certKeyType: ${secretKeyManagerCertKeyType}