Skip to content

Commit a1a0027

Browse files
authored
Merge pull request #317 from PSMRI/release-3.6.0
Release 3.6.0
2 parents 9ffa450 + 2b23cd6 commit a1a0027

94 files changed

Lines changed: 4751 additions & 291 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.

pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.iemr.common-API</groupId>
88
<artifactId>common-api</artifactId>
9-
<version>3.4.0</version>
9+
<version>3.6.0</version>
1010
<packaging>war</packaging>
1111

1212
<name>Common-API</name>
@@ -111,6 +111,12 @@
111111

112112
</exclusions>
113113
</dependency>
114+
115+
<dependency>
116+
<groupId>com.google.firebase</groupId>
117+
<artifactId>firebase-admin</artifactId>
118+
<version>9.4.3</version>
119+
</dependency>
114120
<dependency>
115121
<groupId>org.springframework.boot</groupId>
116122
<artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -257,7 +263,7 @@
257263
<artifactId>logback-core</artifactId>
258264
<scope>test</scope>
259265
</dependency>
260-
266+
261267
<dependency>
262268
<groupId>org.springdoc</groupId>
263269
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>

src/main/environment/common_ci.properties

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ identity-1097-api-url = @env.IDENTITY_1097_API_URL@
3232
send-sms=@env.SEND_SMS@
3333
sendSMSUrl = @env.SEND_SMS_URL@
3434
source-address=@env.SMS_SOURCE_ADDRESS@
35+
sms-consent-source-address = @env.SMS_CONSENT_SOURCE_ADDRESS@
3536
sms-username=@env.SMS_USERNAME@
3637
sms-password=@env.SMS_PASSWORD@
3738
send-message-url=@env.SMS_MESSAGE_URL@
@@ -40,6 +41,11 @@ send-message-url=@env.SMS_MESSAGE_URL@
4041
start-sms-scheduler=true
4142
cron-scheduler-sms=0 0/1 * * * ? *
4243

44+
# Firebase Configuration
45+
firebase.enabled=@env.FIREBASE_ENABLE@
46+
# if using file
47+
firebase.credential-file=@env.FIREBASE_CREDENTIAL@
48+
4349
#### Email Configuration
4450
send-email=@env.SEND_EMAIL@
4551
spring.mail.host=@env.MAIL_HOST@
@@ -167,8 +173,8 @@ grievancePassword = @env.GRIEVANCE_PASSWORD@
167173
grievanceUserAuthenticate = @env.GRIEVANCE_USER_AUTHENTICATE@
168174
grievanceDataSyncDuration = @env.GRIEVANCE_DATA_SYNC_DURATION@
169175

170-
springdoc.api-docs.enabled=false
171-
springdoc.swagger-ui.enabled=false
176+
springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@
177+
springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@
172178

173179

174180
isProduction=@env.IS_PRODUCTION@
@@ -185,4 +191,16 @@ cors.allowed-origins=@env.CORS_ALLOWED_ORIGINS@
185191

186192
video-call-url=@env.VIDEO_CALL_URL@
187193
jibri.output.path=@env.JIBRI_OUTPUT_PATH@
188-
video.recording.path=@env.VIDEO_RECORDING_PATH@
194+
video.recording.path=@env.VIDEO_RECORDING_PATH@
195+
196+
platform.feedback.ratelimit.enabled=@env.PLATFORM_FEEDBACK_RATELIMIT_ENABLED@
197+
platform.feedback.ratelimit.pepper=@env.PLATFORM_FEEDBACK_RATELIMIT_PEPPER@
198+
platform.feedback.ratelimit.trust-forwarded-for=@env.PLATFORM_FEEDBACK_RATELIMIT_TRUST_FORWARDED_FOR@
199+
platform.feedback.ratelimit.forwarded-for-header=@env.PLATFORM_FEEDBACK_RATELIMIT_FORWARDED_FOR_HEADER@
200+
platform.feedback.ratelimit.minute-limit=@env.PLATFORM_FEEDBACK_RATELIMIT_MINUTE_LIMIT@
201+
platform.feedback.ratelimit.day-limit=@env.PLATFORM_FEEDBACK_RATELIMIT_DAY_LIMIT@
202+
platform.feedback.ratelimit.user-day-limit=@env.PLATFORM_FEEDBACK_RATELIMIT_USER_DAY_LIMIT@
203+
platform.feedback.ratelimit.fail-window-minutes=@env.PLATFORM_FEEDBACK_RATELIMIT_FAIL_WINDOW_MINUTES@
204+
platform.feedback.ratelimit.backoff-minutes=@env.PLATFORM_FEEDBACK_RATELIMIT_BACKOFF_MINUTES@
205+
generateBeneficiaryIDs-api-url=@env.GEN_BENEFICIARY_IDS_API_URL@
206+

src/main/environment/common_docker.properties

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ identity-1097-api-url = ${IDENTITY_1097_API_URL}
3232
send-sms=${SEND_SMS}
3333
sendSMSUrl = ${SEND_SMS_URL}
3434
source-address=${SMS_SOURCE_ADDRESS}
35+
sms-consent-source-address=${SMS_CONSENT_SOURCE_ADDRESS}
3536
sms-username=${SMS_USERNAME}
3637
sms-password=${SMS_PASSWORD}
3738
send-message-url=${SMS_MESSAGE_URL}
@@ -169,8 +170,8 @@ grievancePassword = ${GRIEVANCE_PASSWORD}
169170
grievanceUserAuthenticate = ${GRIEVANCE_USER_AUTHENTICATE}
170171
grievanceDataSyncDuration = ${GRIEVANCE_DATA_SYNC_DURATION}
171172

172-
springdoc.api-docs.enabled=false
173-
springdoc.swagger-ui.enabled=false
173+
springdoc.api-docs.enabled=${SWAGGER_DOC_ENABLED}
174+
springdoc.swagger-ui.enabled=${SWAGGER_DOC_ENABLED}
174175

175176

176177
isProduction=${IS_PRODUCTION}
@@ -185,6 +186,24 @@ captcha.enable-captcha=${ENABLE_CAPTCHA}
185186

186187
cors.allowed-origins=${CORS_ALLOWED_ORIGINS}
187188

189+
# # Firebase Configuration
190+
firebase.enabled=${FIREBASE_ENABLE}
191+
# # if using file
192+
firebase.credential-file=${FIREBASE_CREDENTIAL}
193+
194+
188195
video-call-url=${VIDEO_CALL_URL}
189196
jibri.output.path={JIBRI_OUTPUT_PATH}
190-
video.recording.path={VIDEO_RECORDING_PATH}
197+
video.recording.path={VIDEO_RECORDING_PATH}
198+
199+
# Platform Feedback module
200+
platform.feedback.ratelimit.enabled=${PLATFORM_FEEDBACK_RATELIMIT_ENABLED}
201+
platform.feedback.ratelimit.pepper=${PLATFORM_FEEDBACK_RATELIMIT_PEPPER}
202+
platform.feedback.ratelimit.trust-forwarded-for=${PLATFORM_FEEDBACK_RATELIMIT_TRUST_FORWARDED_FOR}
203+
platform.feedback.ratelimit.forwarded-for-header=${PLATFORM_FEEDBACK_RATELIMIT_FORWARDED_FOR_HEADER}
204+
platform.feedback.ratelimit.minute-limit=${PLATFORM_FEEDBACK_RATELIMIT_MINUTE_LIMIT}
205+
platform.feedback.ratelimit.day-limit=${PLATFORM_FEEDBACK_RATELIMIT_DAY_LIMIT}
206+
platform.feedback.ratelimit.user-day-limit=${PLATFORM_FEEDBACK_RATELIMIT_USER_DAY_LIMIT}
207+
platform.feedback.ratelimit.fail-window-minutes=${PLATFORM_FEEDBACK_RATELIMIT_FAIL_WINDOW_MINUTES}
208+
platform.feedback.ratelimit.backoff-minutes=${PLATFORM_FEEDBACK_RATELIMIT_BACKOFF_MINUTES}
209+
generateBeneficiaryIDs-api-url={GEN_BENEFICIARY_IDS_API_URL}

src/main/environment/common_example.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,21 @@ captcha.enable-captcha=true
208208

209209
cors.allowed-origins=http://localhost:*
210210

211+
# ---Platform Feedback module ---
212+
# Rate limiter OFF locally (no Redis required)
213+
platform.feedback.ratelimit.enabled=true
214+
platform.feedback.ratelimit.pepper=dev-pepper-123 # dummy
215+
216+
# trust forwarded-for locally is harmless (localhost only)
217+
platform.feedback.ratelimit.trust-forwarded-for=false
218+
platform.feedback.ratelimit.forwarded-for-header=X-Forwarded-For
219+
220+
# Optional overrides (not needed if disabled)
221+
platform.feedback.ratelimit.minute-limit=10
222+
platform.feedback.ratelimit.day-limit=100
223+
platform.feedback.ratelimit.user-day-limit=50
224+
platform.feedback.ratelimit.fail-window-minutes=5
225+
platform.feedback.ratelimit.backoff-minutes=15
226+
227+
### generate Beneficiary IDs URL
228+
generateBeneficiaryIDs-api-url=/generateBeneficiaryController/generateBeneficiaryIDs

src/main/java/com/iemr/common/CommonApplication.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.data.redis.connection.RedisConnectionFactory;
3030
import org.springframework.data.redis.core.RedisTemplate;
3131
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
32-
import org.springframework.data.redis.serializer.StringRedisSerializer;
3332
import org.springframework.scheduling.annotation.EnableScheduling;
3433
import org.springframework.web.client.RestTemplate;
3534

src/main/java/com/iemr/common/config/CorsConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ public class CorsConfig implements WebMvcConfigurer {
1111

1212
@Value("${cors.allowed-origins}")
1313
private String allowedOrigins;
14-
1514
@Override
1615
public void addCorsMappings(CorsRegistry registry) {
1716
registry.addMapping("/**")
1817
.allowedOriginPatterns(
1918
Arrays.stream(allowedOrigins.split(","))
2019
.map(String::trim)
2120
.toArray(String[]::new))
22-
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
23-
.allowedHeaders("*")
21+
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
22+
.allowedHeaders("Authorization", "Content-Type", "Accept", "Jwttoken",
23+
"serverAuthorization", "ServerAuthorization", "serverauthorization", "Serverauthorization")
2424
.exposedHeaders("Authorization", "Jwttoken")
2525
.allowCredentials(true)
2626
.maxAge(3600);

src/main/java/com/iemr/common/config/RedisConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.fasterxml.jackson.databind.SerializationFeature;
3434
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
3535
import com.iemr.common.data.users.User;
36+
import org.springframework.data.redis.core.StringRedisTemplate;
3637

3738
@Configuration
3839
public class RedisConfig {
@@ -57,4 +58,10 @@ public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factor
5758
return template;
5859
}
5960

61+
// new bean for rate limiting & counters
62+
@Bean
63+
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
64+
return new StringRedisTemplate(factory);
65+
}
66+
6067
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.iemr.common.config.firebase;
2+
3+
import com.google.auth.oauth2.GoogleCredentials;
4+
import com.google.firebase.FirebaseApp;
5+
import com.google.firebase.FirebaseOptions;
6+
import com.google.firebase.messaging.FirebaseMessaging;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import org.springframework.beans.factory.annotation.Value;
10+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
11+
import org.springframework.context.annotation.Bean;
12+
import org.springframework.context.annotation.Configuration;
13+
import org.springframework.core.io.ClassPathResource;
14+
15+
import java.io.ByteArrayInputStream;
16+
import java.io.FileInputStream;
17+
import java.io.IOException;
18+
import java.util.Base64;
19+
20+
@Configuration
21+
public class FirebaseMessagingConfig {
22+
private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
23+
24+
@Value("${firebase.enabled:false}")
25+
private boolean firebaseEnabled;
26+
27+
@Value("${firebase.credential-file:}")
28+
private String firebaseCredentialFile;
29+
30+
31+
@Bean
32+
@ConditionalOnProperty(name = "firebase.enabled", havingValue = "true")
33+
public FirebaseMessaging firebaseMessaging() throws IOException {
34+
if (!firebaseEnabled) {
35+
logger.error("⚠️ Firebase disabled by config");
36+
return null;
37+
}
38+
39+
try {
40+
if (firebaseCredentialFile == null || firebaseCredentialFile.isBlank()) {
41+
logger.error("⚠️ No Firebase credentials path provided");
42+
return null; // don't throw, app will still start
43+
}
44+
45+
GoogleCredentials credentials = GoogleCredentials.fromStream(
46+
new ClassPathResource(firebaseCredentialFile).getInputStream()
47+
);
48+
FirebaseOptions options = FirebaseOptions.builder()
49+
.setCredentials(credentials)
50+
.build();
51+
52+
FirebaseApp firebaseApp = FirebaseApp.getApps().isEmpty()
53+
? FirebaseApp.initializeApp(options)
54+
: FirebaseApp.getInstance();
55+
56+
return FirebaseMessaging.getInstance(firebaseApp);
57+
58+
} catch (Exception e) {
59+
logger.error("⚠️ Firebase init failed: " + e.getMessage());
60+
return null; // keep app running
61+
}
62+
63+
}
64+
65+
}

src/main/java/com/iemr/common/config/quartz/ScheduleForGrievanceDataSync.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ public void execute() {
3737
}
3838

3939
}
40+

src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public class BeneficiaryRegistrationController {
103103
private BeneficiaryOccupationService beneficiaryOccupationService;
104104
private GovtIdentityTypeService govtIdentityTypeService;
105105

106+
106107
@Autowired
107108
public void setBenRelationshipTypeService(BenRelationshipTypeService benRelationshipTypeService) {
108109
this.benRelationshipTypeService = benRelationshipTypeService;

0 commit comments

Comments
 (0)