Skip to content

Commit 3a862e1

Browse files
authored
Merge branch 'develop' into feat/#31-record-post
2 parents 96b3bb4 + 7195a37 commit 3a862e1

73 files changed

Lines changed: 2161 additions & 71 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ out/
3939
### .DS_Store
4040
.DS_Store
4141
### Sensitive configuration
42+
.env
4243
application-local.yaml
4344

4445
### K8s secrets (contains real credentials)

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies {
2121
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
2222
implementation 'org.springframework.boot:spring-boot-starter-web'
2323
implementation 'org.springframework.boot:spring-boot-starter-security'
24+
implementation 'org.springframework.boot:spring-boot-starter-validation'
2425
compileOnly 'org.projectlombok:lombok'
2526
runtimeOnly 'org.postgresql:postgresql'
2627
annotationProcessor 'org.projectlombok:lombok'
@@ -42,6 +43,9 @@ dependencies {
4243

4344
// FCM
4445
implementation 'com.google.firebase:firebase-admin:9.8.0'
46+
47+
// Redis
48+
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
4549
}
4650

4751
jar { enabled = false }

k8s/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ resources:
77
- postgres/deployment.yaml
88
- postgres/service.yaml
99
- postgres/pvc.yaml
10+
- redis/deployment.yaml
11+
- redis/service.yaml
12+
- redis/pvc.yaml
1013
images:
1114
- name: ghcr.io/semosan/semosan_be
1215
newTag: d478edb1ff6f35bd62da2ca5902af0b38a4914fe

k8s/redis/deployment.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: redis
5+
namespace: semosan
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: redis
11+
template:
12+
metadata:
13+
labels:
14+
app: redis
15+
spec:
16+
containers:
17+
- name: redis
18+
image: redis:7-alpine
19+
ports:
20+
- containerPort: 6379
21+
volumeMounts:
22+
- name: redis-data
23+
mountPath: /data
24+
volumes:
25+
- name: redis-data
26+
persistentVolumeClaim:
27+
claimName: redis-pvc

k8s/redis/pvc.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: redis-pvc
5+
namespace: semosan
6+
spec:
7+
accessModes:
8+
- ReadWriteOnce
9+
resources:
10+
requests:
11+
storage: 1Gi

k8s/redis/service.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: redis
5+
namespace: semosan
6+
spec:
7+
selector:
8+
app: redis
9+
ports:
10+
- port: 6379
11+
targetPort: 6379
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.semosan.api.common.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.data.redis.connection.RedisConnectionFactory;
6+
import org.springframework.data.redis.core.StringRedisTemplate;
7+
8+
@Configuration
9+
public class RedisConfig {
10+
11+
@Bean
12+
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory connectionFactory) {
13+
return new StringRedisTemplate(connectionFactory);
14+
}
15+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.semosan.api.common.config;
2+
3+
import jakarta.annotation.PostConstruct;
4+
import lombok.RequiredArgsConstructor;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.data.redis.RedisSystemException;
7+
import org.springframework.data.redis.connection.stream.ReadOffset;
8+
import org.springframework.data.redis.core.StringRedisTemplate;
9+
10+
@Configuration
11+
@RequiredArgsConstructor
12+
public class RedisStreamConfig {
13+
14+
private final StringRedisTemplate redisTemplate;
15+
private final TrackingProperties trackingProperties;
16+
17+
@PostConstruct
18+
public void createConsumerGroup() {
19+
try {
20+
redisTemplate.opsForStream().createGroup(
21+
trackingProperties.getStreamKey(),
22+
ReadOffset.from("0"),
23+
trackingProperties.getConsumerGroup()
24+
);
25+
} catch (RedisSystemException e) {
26+
// consumer group already exists
27+
}
28+
}
29+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.semosan.api.common.config;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
import org.springframework.boot.context.properties.ConfigurationProperties;
6+
import org.springframework.stereotype.Component;
7+
8+
@Getter
9+
@Setter
10+
@Component
11+
@ConfigurationProperties(prefix = "tracking")
12+
public class TrackingProperties {
13+
14+
private String streamKey;
15+
private String consumerGroup;
16+
}

src/main/java/com/semosan/api/common/jwt/JwtFilter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.semosan.api.common.config.SecurityConfig;
55
import com.semosan.api.common.exception.GeneralException;
66
import com.semosan.api.common.response.ApiResponse;
7+
import com.semosan.api.common.status.ErrorStatus;
78
import jakarta.servlet.FilterChain;
89
import jakarta.servlet.ServletException;
910
import jakarta.servlet.http.HttpServletRequest;
@@ -56,6 +57,9 @@ protected void doFilterInternal(
5657
// SecurityConfig의 .anyRequest().authenticated()에서 인가 처리됨
5758
if (accessToken != null) {
5859
jwtService.validateAccessToken(accessToken);
60+
if (jwtService.isAccessTokenBlacklisted(accessToken)) {
61+
throw new GeneralException(ErrorStatus.JWT_BLACKLISTED);
62+
}
5963
Long userId = jwtService.getUserIdFromJwtToken(accessToken);
6064

6165
UsernamePasswordAuthenticationToken authentication =

0 commit comments

Comments
 (0)