From 3712f59cd8679dbbc4112aa216fec28d3d2d8fec Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 18:09:14 +0300 Subject: [PATCH 01/11] mongo local --- src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c837b43..8d55ca1 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -21,9 +21,9 @@ server.port=8888 # DATA PROPERTIES #mongodb spring.data.mongodb.repositories.enabled=true -#spring.data.mongodb.uri=mongodb://localhost:27017/pocketdb -#spring.data.mongodb.uri=mongodb://pocket:pocket@89.208.196.184:27017/pocketdb -spring.data.mongodb.uri=mongodb+srv://pocket:pocket@cluster0-vsjrv.mongodb.net/pocketdb?retryWrites=true&w=majority +spring.data.mongodb.uri=mongodb://pocket:pocket@localhost:27017/pocketdb +#spring.data.mongodb.uri=mongodb://pocket:pocket@192.168.1.37:27017/pocketdb +#spring.data.mongodb.uri=mongodb+srv://pocket:pocket@cluster0-vsjrv.mongodb.net/pocketdb?retryWrites=true&w=majority # # OTHER spring.jackson.serialization.indent_output=true From 153b58d2a1668b69cdcbf031be3529451823c557 Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 18:10:16 +0300 Subject: [PATCH 02/11] properties comment encoding fix --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8d55ca1..c8a485b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -11,7 +11,7 @@ server.port=8888 #server.tomcat.remote_ip_header=x-forwarded-for #server.tomcat.protocol_header=x-forwarded-proto # -# Íàñòðîéêà ñåðâåðà íà çàïóñê ñ SSL/TLS è èñïîëüçîâàíèÿ HTTPS +# Configure the server to run with SSL/TLS and use HTTPS #security.require-ssl=true #server.ssl.key-alias=tomcat #server.ssl.key-store=classpath:keystore.jks From ec9bbdc0ac28c11540df59695f6a424c5aa541b0 Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 18:11:58 +0300 Subject: [PATCH 03/11] gson update --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0d619ea..a8d0b6f 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ com.google.code.gson gson - 2.8.6 + 2.13.2 From 33d7ec5edf14692c97a47e8d3f1bc7e870fd62e7 Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 18:11:29 +0300 Subject: [PATCH 04/11] swagger update --- pom.xml | 10 ++-------- .../pocket/backend/config/SecurityConfig.java | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index a8d0b6f..c5f4477 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,6 @@ 1.8 1.8 ru.geekbrains.pocket.backend.PocketBackendApplication - 2.9.2 @@ -116,13 +115,8 @@ io.springfox - springfox-swagger2 - ${swagger.version} - - - io.springfox - springfox-swagger-ui - ${swagger.version} + springfox-boot-starter + 3.0.0 diff --git a/src/main/java/ru/geekbrains/pocket/backend/config/SecurityConfig.java b/src/main/java/ru/geekbrains/pocket/backend/config/SecurityConfig.java index 5a633ee..61107f0 100644 --- a/src/main/java/ru/geekbrains/pocket/backend/config/SecurityConfig.java +++ b/src/main/java/ru/geekbrains/pocket/backend/config/SecurityConfig.java @@ -57,7 +57,7 @@ public void configure(WebSecurity web) throws Exception { web.httpFirewall(allowHttpMethodsFirewall()); web.ignoring().antMatchers("/webjars/**", "/v2/api-docs/**", "/configuration/ui/**", "/configuration/security/**", - "/swagger-resources/**", "/swagger-ui.html/**", "/swagger-ui.html#/**"); + "/swagger-resources/**", "/swagger-ui/**"); } @Override From d5863b5319d5b7dde3bcf245a22fe290180edb40 Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 18:27:42 +0300 Subject: [PATCH 05/11] swagger update result: guava change to caffeine cache --- pom.xml | 6 ++++ .../backend/security/LoginAttemptService.java | 36 +++++++------------ 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index c5f4477..89d5591 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,12 @@ jjwt 0.9.1 + + + com.github.ben-manes.caffeine + caffeine + 2.9.3 + diff --git a/src/main/java/ru/geekbrains/pocket/backend/security/LoginAttemptService.java b/src/main/java/ru/geekbrains/pocket/backend/security/LoginAttemptService.java index 49fedf5..3746016 100644 --- a/src/main/java/ru/geekbrains/pocket/backend/security/LoginAttemptService.java +++ b/src/main/java/ru/geekbrains/pocket/backend/security/LoginAttemptService.java @@ -1,11 +1,10 @@ package ru.geekbrains.pocket.backend.security; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; +import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.LoadingCache; import org.springframework.stereotype.Service; -import java.util.concurrent.ExecutionException; +import java.util.Optional; import java.util.concurrent.TimeUnit; //https://www.baeldung.com/spring-security-block-brute-force-authentication-attempts @@ -16,40 +15,29 @@ public class LoginAttemptService { private final int MAX_ATTEMPT = 10; - private LoadingCache attemptsCache; + private final LoadingCache attemptsCache; public LoginAttemptService() { - super(); - attemptsCache = CacheBuilder.newBuilder() + attemptsCache = Caffeine.newBuilder() .expireAfterWrite(1, TimeUnit.DAYS) - .build(new CacheLoader() { - @Override - public Integer load(final String key) { - return 0; - } - }); + .build(key -> 0); // Дефолтное значение } public void loginSucceeded(final String key) { attemptsCache.invalidate(key); } + private int getAttempts(String key) { + return Optional.ofNullable(attemptsCache.get(key)).orElse(0); + } + public void loginFailed(final String key) { - int attempts = 0; - try { - attempts = attemptsCache.get(key); - } catch (final ExecutionException e) { - attempts = 0; - } + int attempts = getAttempts(key); attempts++; attemptsCache.put(key, attempts); } public boolean isBlocked(final String key) { - try { - return attemptsCache.get(key) >= MAX_ATTEMPT; - } catch (final ExecutionException e) { - return false; - } + return getAttempts(key) >= MAX_ATTEMPT; } } From 678b8ad778cc3a1e711ee1d683d38d9000600a52 Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 18:52:12 +0300 Subject: [PATCH 06/11] removing an extra role (was commented) --- .../pocket/backend/domain/db/Role.java | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/main/java/ru/geekbrains/pocket/backend/domain/db/Role.java diff --git a/src/main/java/ru/geekbrains/pocket/backend/domain/db/Role.java b/src/main/java/ru/geekbrains/pocket/backend/domain/db/Role.java deleted file mode 100644 index 446cd4a..0000000 --- a/src/main/java/ru/geekbrains/pocket/backend/domain/db/Role.java +++ /dev/null @@ -1,54 +0,0 @@ -//package ru.geekbrains.pocket.backend.domain.db; -// -//import com.fasterxml.jackson.annotation.JsonIgnore; -//import lombok.Getter; -//import lombok.NoArgsConstructor; -//import lombok.Setter; -//import org.bson.types.ObjectId; -//import org.springframework.data.annotation.Id; -//import org.springframework.data.annotation.TypeAlias; -//import org.springframework.data.mongodb.core.index.Indexed; -//import org.springframework.data.mongodb.core.mapping.DBRef; -//import org.springframework.data.mongodb.core.mapping.Document; -//import org.springframework.data.mongodb.core.mapping.Field; -// -//import javax.validation.Valid; -//import javax.validation.constraints.NotEmpty; -//import javax.validation.constraints.NotNull; -//import java.util.List; -// -////this class for Spring Security -// -//@Getter -//@Setter -//@NoArgsConstructor -//@Document(collection = "roles") -//@TypeAlias("roles") -//public class Role { -// @Id -// private ObjectId id; -// -// @NotNull -// @NotEmpty -// @Indexed(unique = true) -// private String name; -// -// @DBRef -// @NotNull -// @Valid -// @JsonIgnore -// @Field(value = "privileges") -// private List privileges; -// -// public Role(String name) { -// this.name = name; -// } -// -// @Override -// public String toString() { -// return "Role{" + -// "id=" + id + -// ", name=" + name + -// '}'; -// } -//} From 3c89b971398b3479a6e08f3842beacc0cccd93b4 Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 18:55:46 +0300 Subject: [PATCH 07/11] calculations simplification in JwtTokenUtil --- .../pocket/backend/security/token/JwtTokenUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/geekbrains/pocket/backend/security/token/JwtTokenUtil.java b/src/main/java/ru/geekbrains/pocket/backend/security/token/JwtTokenUtil.java index fd1de29..371b933 100644 --- a/src/main/java/ru/geekbrains/pocket/backend/security/token/JwtTokenUtil.java +++ b/src/main/java/ru/geekbrains/pocket/backend/security/token/JwtTokenUtil.java @@ -13,7 +13,7 @@ @Component public class JwtTokenUtil implements Serializable { - private static final long ACCESS_TOKEN_VALIDITY_SECONDS = 30*24*60*60;//30 дней + private static final long ACCESS_TOKEN_VALIDITY_MILLISECONDS = 30*24*60*60*1000L;//30 дней private static final String SIGNING_KEY = "pocket"; public String getUsernameFromToken(String token) { @@ -54,7 +54,7 @@ private String doGenerateToken(User user) { .setClaims(claims) .setIssuer("http://geekbrains.ru") .setIssuedAt(new Date(System.currentTimeMillis())) - .setExpiration(new Date(System.currentTimeMillis() + ACCESS_TOKEN_VALIDITY_SECONDS*1000)) + .setExpiration(new Date(System.currentTimeMillis() + ACCESS_TOKEN_VALIDITY_MILLISECONDS)) .signWith(SignatureAlgorithm.HS256, SIGNING_KEY) .compact(); From af266ac16860c580b9101e08ca82135485caa9bc Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 18:59:49 +0300 Subject: [PATCH 08/11] lombok update --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89d5591..ccd77b5 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ org.projectlombok lombok - 1.18.12 + 1.18.42 provided From 990f5e3b9653a741fb0dcc62adaede712c102dd0 Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 19:00:22 +0300 Subject: [PATCH 09/11] keystore.jks update & https on --- src/main/resources/application.properties | 10 +++++----- src/main/resources/keystore.jks | Bin 2252 -> 2744 bytes 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c8a485b..e67b0ed 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -12,11 +12,11 @@ server.port=8888 #server.tomcat.protocol_header=x-forwarded-proto # # Configure the server to run with SSL/TLS and use HTTPS -#security.require-ssl=true -#server.ssl.key-alias=tomcat -#server.ssl.key-store=classpath:keystore.jks -#server.ssl.key-store-password=pocket -#server.ssl.key-password=pocket +security.require-ssl=true +server.ssl.key-alias=tomcat +server.ssl.key-store=classpath:keystore.jks +server.ssl.key-store-password=pocket +server.ssl.key-password=pocket # # DATA PROPERTIES #mongodb diff --git a/src/main/resources/keystore.jks b/src/main/resources/keystore.jks index cf209c3f5bd369c1f90060b00e4eec932d263b38..7b74c759a655c32d6f86c2ef194826d1a9df805b 100644 GIT binary patch literal 2744 zcma);S5y-U5{8qIP(v?@fYPOtKq4h70hC?@1d`Bu?*R)45-CP3sFct_xDt?Fq=SeQ zkuJR(+NDYfNRxX#yL-H6pLQSS%$e_>naBV9Fal#02uK4XFxt{GNX6*H{9p#s0ka8= z#$W=Y{x7TzBS1?2OM+y936Qj3IQdt-re*ri6_gPO$|gY2zu;Av>+cH)GYkt;{%3^3 zq`_QVUKgUxTXvV&2+LRG-zFyX9JsH7K$qD-KtULkmj2%#K@1Q8On{cbK1K)VLIVa$ zf!Vwn3|jYdTfVh_+czSFgvo;m;DJuNT|X=Hvj~6j8Jk-Pgino6o1S_4Oj(Q>#&e)m zM9vcT>589Mw>~P$tZW^s=E*u|eS9Elm>(*{e2ubuy@h?k7hrPNUSap!tWXkQvxj;Y zf4^y_yPL7B!RX|Lg`pGeP`~F^qy1wvT>nj)nhu@GI+Z4tpEV`TScFB8Lx+!%(nwnS z^HfHIzI>yknLS$*1gax4(IM3>DX46*bj6d~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Ky`Gw&WB+*)UoHkBNOIuq@Pv7IG)x&B3*Zx0Fq5^w<4Q6LG zAXGqjXHEblm`fIMD?juSN3InX~rK(05Sa&|R!k}cJmXIoXNp0c7F z%OnUNW|>g7L~^{bno1}iEzkN?uYNy9<7H$h6(7Z_e>HPuI?U>@_(SoY5oc; zn)Y$n1aJtpO2e8x=hG?SVEg0ywZk9nyCvfgY?n3;{x59zbysoM`N8b3`+6=;h3pTC zBw*ii9))jL4ziX5c;N{rdfWUCR4HCz{S{S{DJ!&`KmQC z{sl@@;ni)3L^0OL~dn82Y{wjFkkh^&$ z=e*MIBn`V%d-X0YA^-~Gf{%4OYB_B=BWdy`w}`u$U%sWkKlY^S{U=vBPIAITMGde= zP*f59277k3WuIFT(E11M8fV^;R$eXw^)&O}lWk&)bPj&t5rG Date: Sat, 7 Feb 2026 21:11:41 +0300 Subject: [PATCH 10/11] add paths to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index db7fe4c..0aac5d2 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,5 @@ OAuth2Configuration \ https://java-api.pocketmsg.ru http://localhost:8888 +https://localhost:8888 +https://localhost:8888/swagger-ui/ From 7fce843a874b81e761b3d61974e656a4d86e8395 Mon Sep 17 00:00:00 2001 From: PaLoMaster Date: Sat, 7 Feb 2026 21:13:55 +0300 Subject: [PATCH 11/11] removing duplicate spring-security-messaging --- pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pom.xml b/pom.xml index ccd77b5..246cc6f 100644 --- a/pom.xml +++ b/pom.xml @@ -56,10 +56,6 @@ org.springframework.boot spring-boot-starter-data-mongodb - - org.springframework.security - spring-security-messaging -