Compare commits

..

180 Commits

Author SHA1 Message Date
Marcus Da Coregio
37d1f68766 Release 3.0.1 2023-03-21 10:33:18 -03:00
Marcus Da Coregio
d2fe7d0e74 Update org.mongodb to 4.8.2
Closes gh-2271
2023-03-21 10:32:44 -03:00
Marcus Da Coregio
380dae16d2 Update to spring-security-bom:6.0.2
Closes gh-2270
2023-03-21 10:32:37 -03:00
Marcus Da Coregio
6aa71d45f9 Update to spring-data-bom:2022.0.3
Closes gh-2269
2023-03-21 10:32:28 -03:00
Marcus Da Coregio
635a6d4dd6 Update to spring-framework-bom:6.0.6
Closes gh-2268
2023-03-21 10:32:16 -03:00
Marcus Da Coregio
a69d53c17f Update to junit-bom:5.9.2
Closes gh-2267
2023-03-21 10:32:10 -03:00
Marcus Da Coregio
0afc216d21 Update to jackson-bom:2.14.2
Closes gh-2266
2023-03-21 10:32:02 -03:00
Marcus Da Coregio
801a0057fd Update reactor-bom to 2022.0.5
Closes gh-2265
2023-03-21 10:29:14 -03:00
Marcus Da Coregio
7d1b01daf6 Update Antora Plugin to 1.0.0
Issue gh-2234
2023-03-06 14:43:21 -03:00
Marcus Da Coregio
d7d36846a1 Merge branch '2.7.x' 2023-03-06 14:23:39 -03:00
Marcus Da Coregio
d48aa09b9c Update to mariadb-java-client 2.7.8
Closes gh-2255
2023-03-06 13:58:02 -03:00
Marcus Da Coregio
02a6dbc08a Revert "Update to mariadb-java-client 3.0.10"
This reverts commit acb59258
2023-03-06 13:55:08 -03:00
Marcus Da Coregio
e4a023fa64 Revert "Update Antora Plugin to 1.0.0"
This reverts commit 280f311677.
2023-03-06 13:52:52 -03:00
Rob Winch
1e10dfe1a3 Merge remote-tracking branch 'origin/2.7.x' 2023-02-21 17:23:51 -06:00
Rob Winch
e8837c83e9 Next Development Version 2023-02-21 17:21:56 -06:00
Rob Winch
b4b9ea8112 Release 2.7.1 2023-02-21 17:21:18 -06:00
Rob Winch
c571f7479c Update to org.postgresql:postgresql:42.3.8
Closes gh-2250
2023-02-21 17:13:06 -06:00
Rob Winch
63d7580a69 Update to MongoDB 4.6.1
Closes gh-2249
2023-02-21 17:12:19 -06:00
Rob Winch
c466aa5dd3 Update to Mockito 4.5.1
Closes gh-2248
2023-02-21 17:11:33 -06:00
Rob Winch
acb59258c3 Update to mariadb-java-client 3.0.10
Closes gh-2247
2023-02-21 17:10:44 -06:00
Rob Winch
e5022757a9 Update to mysql-connector-java 8.0.32
Closes gh-2246
2023-02-21 17:09:49 -06:00
Rob Winch
ddad8010eb Update to lettuce 6.1.10.RELEASE
Closes gh-2245
2023-02-21 17:09:01 -06:00
Rob Winch
fc3e2e1c64 Update to HikariCP:4.0.3
Closes gh-2244
2023-02-21 17:08:18 -06:00
Rob Winch
eb169f8186 Update to com.ibm.db2:jcc:11.5.8.0
Closes gh-2243
2023-02-21 17:07:23 -06:00
Rob Winch
5fd7c9ddcf Update to testcontainers 1.17.6
Closes gh-2242
2023-02-21 17:06:13 -06:00
Rob Winch
8898ceb4a7 Update to Spring Security 5.7.6
Closes gh-2241
2023-02-21 17:05:25 -06:00
Rob Winch
c4e9a93d02 Update to Spring Data 20201.2.7
Closes gh-2240
2023-02-21 17:04:17 -06:00
Rob Winch
d8ab39eba7 Update to Spring Framework 5.3.25
Closes gh-2239
2023-02-21 17:03:19 -06:00
Rob Winch
6a5f101656 Update to Jackson 2.13.4.20221013
Closes gh-2238
2023-02-21 17:02:26 -06:00
Rob Winch
88d34035a6 Update to Reactor 2020.0.27
Closes gh-2237
2023-02-21 17:01:26 -06:00
Rob Winch
81ef425b1b Spring to Boot 2.7.8
Closes gh-2236
2023-02-21 16:59:46 -06:00
Marcus Da Coregio
280f311677 Update Antora Plugin to 1.0.0
Issue gh-2234
2023-02-16 09:41:50 -03:00
Marcel Wollschläger
8da5068cac Update Redis example documentation
With the release of Spring-Boot 3.x, the application properties for Redis
changed from `spring.redis` to `spring.data.redis`.
This change will update the documentation to be consistent with the latest
changes in Spring-Boot.
2023-01-24 09:44:47 -03:00
Marcus Da Coregio
9276e1ddc6 Merge branch '2.7.x' 2023-01-23 13:59:11 -03:00
Kaoru Muta
fab1f7b38e docs: fix broken links in hazelcast documents 2023-01-23 13:57:39 -03:00
Marcus Da Coregio
a09146a2ed Merge branch '2.7.x' 2023-01-23 13:50:44 -03:00
Eddú Meléndez
0dfc97289f Polish related to testcontainers
* Use getHost instead of getContainerIpAddress
* Rely on OracleContainer and it's improvements which involve the log
wait strategy
2023-01-23 13:47:59 -03:00
Marcus Da Coregio
13c7ee54a8 Merge branch '2.7.x' 2023-01-23 12:59:31 -03:00
Marcus Da Coregio
7c927c7f38 Setup forward merge
Closes gh-2228
2023-01-23 11:52:06 -03:00
Marcus Da Coregio
c98a7be0e2 Remove System.out.println
Closes gh-2215
2022-12-01 10:17:20 -03:00
Marcus Da Coregio
8f9c69ea02 Add jakarta.servlet.jsp.jstl-api to non Spring Boot samples
Closes gh-2216
2022-12-01 09:07:19 -03:00
Rob Winch
df3f9a386e Next Development Version 2022-11-22 09:09:55 -06:00
Rob Winch
77e062b2cd Release 3.0.0 2022-11-22 09:08:17 -06:00
Rob Winch
2a3b76fee5 Update to Spring Security 6.0.0
Closes gh-2211
2022-11-22 09:06:02 -06:00
Rob Winch
d5b75228fc Update to Spring Data 2022.0.0
Closes gh-2210
2022-11-22 09:03:59 -06:00
Rob Winch
3d7c668e57 Update to Spring Framework 6.0.0
Closes gh-2209
2022-11-22 09:02:56 -06:00
Rob Winch
e83cf082c4 Merge branch '2.7.x' 2022-11-15 14:20:11 -06:00
Rob Winch
cbd1c66c13 Merge branch '2.6.x' into 2.7.x 2022-11-15 14:20:00 -06:00
Rob Winch
9f7a969a6e Fix Snapshot Deploy
This commit merges a workaround to an issue in JFrog's Gradle plugin
which causes SNAPSHOTs to be out of sync and thus prevents downloading.

Closes gh-2177
2022-11-15 14:17:26 -06:00
Rob Winch
f51310ee64 Merge branch '2.7.x' 2022-11-15 13:45:25 -06:00
Rob Winch
5f2523e211 Merge branch '2.6.x' into 2.7.x 2022-11-15 13:44:56 -06:00
Bakul Kakadiya
26986a6b7d Corrected documentation Reference Link 2022-11-15 11:49:05 -06:00
Craig Andrews
6cdb77378d Update reference site link
https://docs.spring.io/spring-session/docs/current/reference/html5/ goes to a 404 page

Use https://docs.spring.io/spring-session/reference/ instead which is the current documentation site.
2022-11-15 11:48:28 -06:00
Vedran Pavic
238416ec23 Polish HttpSessionAdapter 2022-11-15 11:47:01 -06:00
Vedran Pavic
4b99428267 Polish SessionRepositoryFilterTests 2022-11-15 11:47:01 -06:00
Dan Allen
058e4e46a5 label jpg as binary file in .gitattributes 2022-11-15 11:34:19 -06:00
Rob Winch
fd3609c6f0 Next Development Version 2022-11-09 13:09:53 -06:00
Rob Winch
a0d03adbe1 Release 3.0.0-RC2 2022-11-09 12:44:49 -06:00
Rob Winch
b229103d8c Remove spring-session-sample-javaconfig-rest
Works around a compatability issue for now.

Issue gh-2201
2022-11-09 12:44:31 -06:00
Rob Winch
94b441c676 Define websocket depenendencies
Issue gh-2204
2022-11-09 12:43:22 -06:00
Rob Winch
b2f10c6752 Next Development Version 2022-11-09 10:24:54 -06:00
Rob Winch
b3d228eb2e Release 3.0.0-RC2 2022-11-09 10:24:22 -06:00
Rob Winch
19dd3d8be1 Revert "Update for docs-build branch"
This reverts commit cd628fe5af.
2022-11-09 10:22:52 -06:00
Rob Winch
1aaffb28fc Update to Spring Security 6.0.0-RC2
Closes gh-2206
2022-11-09 09:56:24 -06:00
Rob Winch
75af61ca6c Update to Spring Data 2022.0.0-RC2
Closes gh-2205
2022-11-09 09:55:30 -06:00
Rob Winch
2fff593423 Update to Spring Framework 6.0.0-RC4
Closes gh-2204
2022-11-09 09:54:10 -06:00
Rob Winch
6a381d3226 Update to reactor-bom:2022.0.0
Closes gh-2203
2022-11-09 09:53:09 -06:00
Rob Winch
cd628fe5af Update for docs-build branch 2022-11-08 12:59:06 -06:00
Andy Wilkinson
ee4df64bb1 Align wth Servlet 6.0 API 2022-11-07 10:27:13 -06:00
Andy Wilkinson
d850762bce Avoid changing line endings of png and mmdb files 2022-11-07 10:05:58 -06:00
Vedran Pavic
f71d1d6ca4 Add Spring Session BOM module
With Spring Session Data Geode module being removed from the BOM, all of Spring Session's modules are now managed by this repository.

This means that the BOM itself can be moved to this repository, in order to simplify the overall project maintenance.

See gh-2195
2022-10-25 14:33:58 -05:00
Vedran Pavic
e5eeacec5f Update security config in samples
This commit updates security configuration in samples to:

- use AuthorizationFilter instead of FilterSecurityInterceptor
- update session creation policy in REST sample
2022-10-25 14:27:39 -05:00
Rob Winch
62ec64310b Next Development Version 2022-10-18 20:46:04 -05:00
Rob Winch
58813e9d5a Next Development Version 2022-05-18 11:06:59 -05:00
Rob Winch
c66ee750f9 Release 2.7.0 2022-05-18 11:02:54 -05:00
Rob Winch
9062db3f55 Update to spring-security-bom:5.7.0
Closes gh-2084
2022-05-18 09:29:51 -05:00
Rob Winch
4bf15cda3b Update to spring-data-bom:2021.2.0
Closes gh-2085
2022-05-18 09:29:51 -05:00
Rob Winch
7f8c0387a7 Update to spring-framework-bom:5.3.20
Closes gh-2086
2022-05-18 09:29:51 -05:00
Rob Winch
3bc15c4259 Update to reactor-bom:2020.0.19
Closes gh-2087
2022-05-18 09:29:50 -05:00
Rob Winch
c9add24c77 Add .sdkmanrc
Closes gh-2088
2022-05-18 09:29:44 -05:00
Eleftheria Stein
aaed973d27 Add Caffeine community extension
Closes gh-2039
2022-04-27 09:50:11 +02:00
Eleftheria Stein
55c4fcfd3f Fix link to Infinispan cache 2022-04-27 09:49:41 +02:00
Eleftheria Stein
2a5d6b4d2e Next development version 2022-04-19 18:39:03 +02:00
Eleftheria Stein
42aa10bfe8 Release 2.7.0-RC1 2022-04-19 18:20:16 +02:00
Eleftheria Stein
2ce570cbdc Next development version 2022-04-19 18:06:26 +02:00
Eleftheria Stein
221b48094a Upgrade test dependencies 2022-04-19 17:59:17 +02:00
Eleftheria Stein
d43b48bbb0 Revert "Upgrade test dependencies"
This reverts commit 2369b2cfb3.
2022-04-19 17:57:52 +02:00
Eleftheria Stein
840907993b Release 2.6.3 2022-04-19 17:37:41 +02:00
Eleftheria Stein
e1dea5e0a8 Revise Redis test mocks based on new Data implementation
Issue gh-2070
2022-04-19 15:53:23 +02:00
Eleftheria Stein
4db41c1caf Upgrade Spring Data to 2021.1.4
Closes gh-2058
2022-04-19 15:41:20 +02:00
Eleftheria Stein
23a32acd56 Upgrade Spring Data to 2021.2.0-RC1
Closes gh-2059
2022-04-19 15:18:55 +02:00
Eleftheria Stein
dc8cca5351 Upgrade Spring Security to 5.7.0-RC1
Closes gh-2070
2022-04-19 13:19:15 +02:00
Eleftheria Stein
2369b2cfb3 Upgrade test dependencies 2022-04-19 13:19:10 +02:00
Eleftheria Stein
e6ce56ec8b Upgrade Reactor to 2020.0.18
Closes gh-2071
2022-04-19 13:17:57 +02:00
Eleftheria Stein
36939c1b02 Upgrade Jackson to 2.13.2.20220328
Closes gh-2068
2022-04-19 13:17:25 +02:00
Eleftheria Stein
0a84f9d544 Upgrade Spring Framework to 5.3.19
Closes gh-2069
2022-04-19 13:15:32 +02:00
Eleftheria Stein
f4840e98a2 Upgrade test dependencies 2022-04-19 12:27:09 +02:00
Eleftheria Stein
8c99c9f904 Upgrade Spring Security to 5.6.3
Closes gh-2064
2022-04-19 12:26:40 +02:00
Eleftheria Stein
f70f1f20f9 Upgrade Reactor to 2020.0.18
Closes gh-2065
2022-04-19 12:25:20 +02:00
Eleftheria Stein
ac1a77e5fe Upgrade Jackson to 2.13.2.20220328
Closes gh-2066
2022-04-19 12:21:58 +02:00
Eleftheria Stein
214a556dd4 Upgrade Spring Framework to 5.3.19
Closes gh-2063
2022-04-19 12:21:22 +02:00
Eleftheria Stein
cace484fbe Upgrade samples to Spring Boot 2.6.6
Closes gh-2067
2022-04-19 12:20:16 +02:00
Eleftheria Stein
a5ec1ccf1f Fix formatting 2022-04-19 11:13:49 +02:00
Greg L. Turnquist
7fc0ae47d5 Switch back to unicode for the DOT substitute character.
MongoDB doesn't support "." in field names, so a Private Use Area character was used. This was originally stored in unicode format, but delomboking the code caused it to get transformed into another encoding. This causes issues on certain systems when building the software, so we are converting it back to its unicode representation. The character has been the same throughout, ensuring binary compatilibity.

See: https://www.compart.com/en/unicode/U+F607

Related: d601e270fc (diff-57190a47726099e31fdf86b12b80206e2ae24feb28aacaf494b99557583df150L47)
Closes #2053.
2022-04-18 09:49:57 -05:00
Jerome Prinet
ce2e644e04 Update Gradle Enterprise plugin to 3.9 2022-04-14 11:10:54 +02:00
Felix Scheinost
24c198fe98 Fix bug in JDBC SaveMode.ON_GET_ATTRIBUTE 2022-04-08 17:50:51 +02:00
Felix Scheinost
8800fb9816 Fix bug in JDBC SaveMode.ON_GET_ATTRIBUTE 2022-04-08 17:19:54 +02:00
Eleftheria Stein
b8e94948ae Upgrade MongoDB to 4.5.1
Closes gh-2047
2022-03-30 15:24:02 +02:00
Eleftheria Stein
8d2276341f Upgrade samples to Spring Boot 2.7.0-M3
This also makes the necessary changes for the Thymeleaf Layout Dialect 3.0 update.

Closes gh-2046
2022-03-30 15:23:49 +02:00
Eleftheria Stein
2c1b79375d Upgrade samples to Spring Boot 2.6.5
This also makes the necessary changes for the Thymeleaf Layout Dialect 3.0 update.

Closes gh-1980
2022-03-29 15:33:08 +02:00
Eleftheria Stein
63f1c7bf6f Fix reference documentation redirects
Closes gh-2044
2022-03-23 10:03:32 +01:00
Eleftheria Stein
e8e4ee2850 Make RedisSessionRepository.DEFAULT_KEY_NAMESPACE public
Closes gh-2043
2022-03-15 18:23:17 +01:00
Eleftheria Stein
9a643c8866 Update to Antora 3.0.1
Closes gh-2038
2022-03-11 15:46:19 +01:00
Eleftheria Stein
282f774e07 Document release process for 2.7.x
Issue gh-2036
2022-02-24 12:46:05 +01:00
Eleftheria Stein
fba9313c6b Document release process for 2.6.x
Issue gh-2036
2022-02-23 14:22:25 +01:00
Eleftheria Stein
e6ec5765b8 Fix 2.6.2 reference docs
Closes gh-2035
2022-02-22 15:43:37 +01:00
Eleftheria Stein
c2288615bf Update antora to 2.6.3 2022-02-22 14:38:24 +01:00
Eleftheria Stein
ad52fc0297 Next development version 2022-02-22 14:13:29 +01:00
Eleftheria Stein
2516a495af Release 2.6.2 2022-02-22 10:31:00 +01:00
Eleftheria Stein
9be7ac7fa6 Upgrade test dependencies 2022-02-22 10:30:29 +01:00
Eleftheria Stein
c335a49924 Upgrade Hazelcast 4 to 4.2.4
Closes gh-2029
2022-02-22 10:29:20 +01:00
Eleftheria Stein
092e6c6607 Upgrade MongoDB to 4.4.2
Closes gh-2034
2022-02-22 10:28:02 +01:00
Eleftheria Stein
0924c9558a Upgrade Reactor to 2020.0.16
Closes gh-2031
2022-02-22 10:27:20 +01:00
Eleftheria Stein
0484781541 Upgrade Jackson to 2.13.1
Closes gh-2033
2022-02-22 10:26:38 +01:00
Eleftheria Stein
3995f8bf65 Upgrade Spring Framework to 5.3.16
Closes gh-2028
2022-02-22 10:25:32 +01:00
Eleftheria Stein
ad16f17398 Upgrade Spring Data to 2021.1.2
Closes gh-2032
2022-02-22 10:24:56 +01:00
Eleftheria Stein
11aa50e83c Upgrade Spring Security to 5.6.2
Closes gh-2030
2022-02-22 10:24:32 +01:00
Eleftheria Stein
ab5c727846 Update Websocket sample to be compatible with H2 2.0
Closes gh-2013
2022-01-27 14:11:26 +01:00
Eleftheria Stein
a0246a61b6 Update to jakarta.servlet-api dependency
Closes gh-1960
2022-01-25 13:26:47 +01:00
Eleftheria Stein
8f20fa328a Update to jakarta.annotation-api dependency
Closes gh-1956
2022-01-25 12:50:29 +01:00
Eleftheria Stein
44ff959c59 Include 2.6.x branch in Antora docs
Issue gh-2014
2022-01-21 10:13:52 +01:00
Eleftheria Stein
ad67a3775b Add manual trigger to antora generate workflow
Issue gh-2014
2022-01-20 13:52:11 +01:00
Eleftheria Stein
75c60b27bd Exclude 3.0.0-M1 and 2.7.0-M1 tags from antora
Closes gh-2014
2022-01-20 13:22:31 +01:00
Ruslan Molchanov
12ce8de84e Fix memory leak with null principal in Redis
Closes gh-1987
2022-01-20 10:05:05 +01:00
Ruslan Molchanov
81bd6bd261 Fix memory leak with null principal in Redis
Closes gh-1987
2022-01-19 17:31:35 +01:00
Eleftheria Stein
2e8c4292fd Next development version 2022-01-18 13:01:30 +01:00
Eleftheria Stein
315b9c9929 Release 2.7.0-M1 2022-01-18 12:51:40 +01:00
Eleftheria Stein
a70abd90bd Upgrade test dependencies 2022-01-18 11:29:58 +01:00
Eleftheria Stein
f13df5aa2f Revert "Upgrade test dependencies"
This reverts commit bda72c074f.
2022-01-18 11:14:02 +01:00
Eleftheria Stein
6fd68e093f Upgrade Spring Data to 2021.2.0-M2
Closes gh-1996
2022-01-18 10:47:16 +01:00
Eleftheria Stein
653d820290 Update antora tags to include 3.0 2022-01-18 10:35:06 +01:00
Jerome Prinet
950ac50234 Bump up Gradle plugin dependencies 2022-01-17 17:05:36 +01:00
Eleftheria Stein
bda72c074f Upgrade test dependencies 2022-01-17 14:51:48 +01:00
Eleftheria Stein
fb1362aa2c Upgrade Hazelcast 4 to 4.2.4
Closes gh-2001
2022-01-17 14:51:48 +01:00
Eleftheria Stein
d5dac6629d Upgrade Spring Security to 5.7.0-M1
Closes gh-1997
2022-01-17 14:51:45 +01:00
Eleftheria Stein
04b4b9ba17 Upgrade Spring Framework to 5.3.15
Closes gh-1998
2022-01-17 14:51:18 +01:00
Eleftheria Stein
97308bdbf4 Upgrade Jackson to 2.13.1
Closes gh-2002
2022-01-17 14:50:38 +01:00
Eleftheria Stein
4ba62c71dd Upgrade MongoDB to 4.4.1
Closes gh-2000
2022-01-17 14:50:38 +01:00
Eleftheria Stein
265099c586 Upgrade Reactor to 2020.0.15
Closes gh-1999
2022-01-17 09:41:09 +01:00
Eleftheria Stein
2f4a0110ab Update to jakarta.servlet-api dependency
Closes gh-1960
2022-01-14 16:21:35 +01:00
Eleftheria Stein
7a1cb66dae Update to jakarta.annotation-api dependency
Closes gh-1956
2022-01-14 16:19:22 +01:00
Jerome Prinet
9bad2afa14 Bump up Gradle enterprise plugin to 3.7.2 2022-01-05 14:34:51 +01:00
Eleftheria Stein
dba22292a3 Run CI on all branches 2022-01-05 14:29:57 +02:00
Eleftheria Stein
c79173879f Run CI on all branches 2022-01-05 14:29:28 +02:00
Eleftheria Stein
2c065c0241 Next minor development version 2022-01-05 14:28:19 +02:00
Eleftheria Stein
a08c721118 Next development version 2021-12-21 16:31:16 +02:00
Eleftheria Stein
70e0c6d22d Update antora version 2021-12-21 15:44:58 +02:00
Eleftheria Stein
61bf2eca49 Release 2.6.1 2021-12-21 15:12:26 +02:00
Eleftheria Stein
59923121f0 Make gretty samples compatible with logback 1.2.9
Explicitly reference the logback.xml file to prevent gretty from configuring the defaults using groovy.
2021-12-21 11:10:33 +02:00
Eleftheria Stein
b5f8e29585 Upgrade test dependencies 2021-12-21 11:10:22 +02:00
Eleftheria Stein
307a1f0dde Upgrade Hazelcast 4 to 4.2.3
Closes gh-1979
2021-12-21 10:09:06 +02:00
Eleftheria Stein
ced2d8421c Upgrade Spring Security to 5.6.1
Closes gh-1978
2021-12-21 10:08:25 +02:00
Eleftheria Stein
d98ff97e1a Upgrade Spring Framework to 5.3.14
Closes gh-1977
2021-12-21 10:03:02 +02:00
Eleftheria Stein
757175516f Upgrade Reactor to 2020.0.14
Closes gh-1976
2021-12-21 10:02:30 +02:00
Eleftheria Stein
8ae55b7ee4 GitHub Actions uses spring-builds+github user
This is more clear than spring-builds user
2021-12-07 15:43:42 +01:00
Eleftheria Stein
1eb53ead9d Update README to include MongoDB
Issue gh-1901
2021-11-26 17:37:12 +01:00
Guillaume Husta
72159794f4 Doc : typo on Username _user-
user should be in italic
2021-11-19 14:56:56 +01:00
Eleftheria Stein
aaf122f3a6 Include 2.6.0 and 3.0 snapshots in reference docs 2021-11-17 11:28:54 +01:00
Eleftheria Stein
6f823805f2 Include 2.6.8 release in docs 2021-11-17 11:04:55 +01:00
Eleftheria Stein
7807aa9f3c Next development version 2021-11-16 18:56:49 +01:00
Eleftheria Stein
76924bc923 Release 2.6.0 2021-11-16 14:21:51 +01:00
Eleftheria Stein
134f89dd41 Upgrade test dependencies 2021-11-16 13:57:45 +01:00
Eleftheria Stein
33812f7197 Upgrade MongoDB to 4.4.0
Closes gh-1967
2021-11-16 13:56:44 +01:00
Eleftheria Stein
bcf17ba3b7 Upgrade samples to Spring Boot 2.5.6
Closes gh-1966
2021-11-16 13:37:41 +01:00
Eleftheria Stein
98f656ad46 Upgrade Jackson to 2.13.0
Closes gh-1965
2021-11-16 13:11:51 +01:00
Eleftheria Stein
7832942752 Upgrade Spring Security to 5.6.0
Closes gh-1964
2021-11-16 13:07:43 +01:00
Eleftheria Stein
722069a5f8 Upgrade Spring Data to 2021.1.0
Closes gh-1963
2021-11-16 13:06:41 +01:00
Eleftheria Stein
addbdbc1a2 Upgrade Spring Framework to 5.3.13
Closes gh-1962
2021-11-16 13:05:51 +01:00
Eleftheria Stein
004466ed07 Upgrade Reactor to 2020.0.13
Closes gh-1961
2021-11-16 13:04:32 +01:00
Eleftheria Stein
aeb5bc545c Update to Gradle 7.3
Closes gh-1959
2021-11-15 09:59:22 +01:00
69 changed files with 799 additions and 1181 deletions

5
.gitattributes vendored
View File

@@ -1,5 +1,6 @@
* text eol=lf
*.bat text eol=crlf
*.jar binary
*.jpg binary
*.png binary
*.mmdb binary

View File

@@ -1,20 +0,0 @@
{
"index_name": "session-docs",
"start_urls": [
"https://docs.spring.io/spring-session/reference/"
],
"selectors": {
"lvl0": {
"selector": "//nav[@class='crumbs']//li[@class='crumb'][last()-1]",
"type": "xpath",
"global": true,
"default_value": "Home"
},
"lvl1": ".doc h1",
"lvl2": ".doc h2",
"lvl3": ".doc h3",
"lvl4": ".doc h4",
"text": ".doc p, .doc td.content, .doc th.tableblock"
}
}

View File

@@ -1,20 +0,0 @@
#!/bin/bash
HOST="$1"
HOST_PATH="$2"
SSH_PRIVATE_KEY="$3"
SSH_KNOWN_HOST="$4"
if [ "$#" -ne 4 ]; then
echo -e "not enough arguments USAGE:\n\n$0 \$HOST \$HOST_PATH \$SSH_PRIVATE_KEY \$SSH_KNOWN_HOSTS \n\n" >&2
exit 1
fi
# Use a non-default path to avoid overriding when testing locally
SSH_PRIVATE_KEY_PATH=~/.ssh/github-actions-docs
install -m 600 -D /dev/null "$SSH_PRIVATE_KEY_PATH"
echo "$SSH_PRIVATE_KEY" > "$SSH_PRIVATE_KEY_PATH"
echo "$SSH_KNOWN_HOST" > ~/.ssh/known_hosts
rsync --delete -avze "ssh -i $SSH_PRIVATE_KEY_PATH" spring-session-docs/build/site/ "$HOST:$HOST_PATH"
rm -f "$SSH_PRIVATE_KEY_PATH"

View File

@@ -1,21 +0,0 @@
#!/bin/bash
###
# Docs
# config.json https://docsearch.algolia.com/docs/config-file
# Run the crawler https://docsearch.algolia.com/docs/run-your-own/#run-the-crawl-from-the-docker-image
### USAGE
if [ "$#" -ne 3 ]; then
echo -e "not enough arguments USAGE:\n\n$0 \$ALGOLIA_APPLICATION_ID \$ALGOLIA_API_KEY \$CONFIG_FILE\n\n" >&2
exit 1
fi
# Script Parameters
APPLICATION_ID=$1
API_KEY=$2
CONFIG_FILE=$3
#### Script
script_dir=$(dirname $0)
docker run -e "APPLICATION_ID=$APPLICATION_ID" -e "API_KEY=$API_KEY" -e "CONFIG=$(cat $CONFIG_FILE | jq -r tostring)" algolia/docsearch-scraper

View File

@@ -1,5 +0,0 @@
REPOSITORY_REF="$1"
TOKEN="$2"
curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${TOKEN}" --request POST --data '{"event_type": "request-build-reference"}' https://api.github.com/repos/${REPOSITORY_REF}/dispatches
echo "Requested Build for $REPOSITORY_REF"

View File

@@ -1,16 +0,0 @@
name: Update Algolia Index
on:
schedule:
- cron: '0 10 * * *' # Once per day at 10am UTC
workflow_dispatch: # Manual trigger
jobs:
update:
name: Update Algolia Index
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v2
- name: Update Index
run: ${GITHUB_WORKSPACE}/.github/actions/algolia-docsearch-scraper.sh "${{ secrets.ALGOLIA_APPLICATION_ID }}" "${{ secrets.ALGOLIA_WRITE_API_KEY }}" "${GITHUB_WORKSPACE}/.github/actions/algolia-config.json"

View File

@@ -1,36 +0,0 @@
name: Generate Antora Files and Request Build
on:
push:
branches-ignore:
- 'gh-pages'
env:
GH_ACTIONS_REPO_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Generate antora.yml
run: ./gradlew :spring-session-docs:generateAntora
- name: Extract Branch Name
id: extract_branch_name
run: echo "##[set-output name=generated_branch_name;]$(echo ${GITHUB_REPOSITORY}/${GITHUB_REF##*/})"
- name: Push generated antora files to the spring-generated-docs
uses: JamesIves/github-pages-deploy-action@4.1.4
with:
branch: ${{ steps.extract_branch_name.outputs.generated_branch_name }} # The branch the action should deploy to.
folder: "spring-session-docs/build/generateAntora" # The folder the action should deploy.
repository-name: "spring-io/spring-generated-docs"
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
- name: Dispatch Build Request
run: ${GITHUB_WORKSPACE}/.github/actions/dispatch.sh 'spring-projects/spring-session' "$GH_ACTIONS_REPO_TOKEN"

30
.github/workflows/deploy-docs.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Deploy Docs
on:
push:
branches-ignore: [ gh-pages ]
tags: '**'
repository_dispatch:
types: request-build-reference # legacy
workflow_dispatch:
permissions: read-all
jobs:
build:
runs-on: ubuntu-latest
if: github.repository_owner == 'spring-projects'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: docs-build
fetch-depth: 1
- name: Dispatch (partial build)
if: github.ref_type == 'branch'
env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }}
- name: Dispatch (full build)
if: github.ref_type == 'tag'
env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD)

View File

@@ -1,33 +0,0 @@
name: Build & Deploy Reference
on:
repository_dispatch:
types: request-build-reference
schedule:
- cron: '0 10 * * *' # Once per day at 10am UTC
workflow_dispatch: # Manual trigger
jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Build with Gradle
run: ./gradlew :spring-session-docs:antora --stacktrace
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Deploy
run: ${GITHUB_WORKSPACE}/.github/actions/algolia-deploy.sh "${{ secrets.DOCS_USERNAME }}@${{ secrets.DOCS_HOST }}" "/opt/www/domains/spring.io/docs/htdocs/spring-session/reference/" "${{ secrets.DOCS_SSH_KEY }}" "${{ secrets.DOCS_SSH_HOST_KEY }}"

View File

@@ -0,0 +1,20 @@
name: Rebuild Search Index
on:
schedule:
- cron: '0 10 * * *' # Once per day at 10am UTC
workflow_dispatch:
permissions: read-all
jobs:
build:
if: github.repository_owner == 'spring-projects'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: docs-build
fetch-depth: 1
- name: Dispatch
env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
run: gh workflow run rebuild-search-index.yml -r $(git rev-parse --abbrev-ref HEAD)

View File

@@ -25,6 +25,13 @@ If you are reporting a bug, please help to speed up problem diagnosis by providi
information as possible. Ideally, that would include a small sample project that
reproduces the problem.
== Create your branch from the oldest maintenance branch
Create your topic branch to be submitted as a pull request from the oldest impacted and supported maintenance branch.
You can find the supported versions by looking at the https://github.com/spring-projects/spring-session/milestones[milestones page].
Switch to a branch named `<major>.<minor>.x` from the smallest milestone in the format of `<major>.<minor>.<patch>(-<prerelease>)`.
The spring team will ensure the code gets merged forward into additional branches.
== Sign the Contributor License Agreement
If you have not previously done so, please fill out and

View File

@@ -63,7 +63,7 @@ Compile and test; build all jars, distribution zips, and docs
You can find the documentation, samples, and guides for using Spring Session on the https://projects.spring.io/spring-session/[Spring Session project site].
For more in depth information, visit the https://docs.spring.io/spring-session/docs/current/reference/html5/[Spring Session Reference].
For more in depth information, visit the https://docs.spring.io/spring-session/reference/[Spring Session Reference].
== Code of Conduct

View File

@@ -26,6 +26,10 @@ sourceSets {
gradlePlugin {
plugins {
checkAntoraVersion {
id = "org.springframework.antora.check-version"
implementationClass = "org.springframework.gradle.antora.AntoraVersionPlugin"
}
managementConfiguration {
id = "io.spring.convention.management-configuration"
implementationClass = "io.spring.gradle.convention.ManagementConfigurationPlugin"
@@ -54,6 +58,7 @@ configurations {
dependencies {
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'net.sourceforge.saxon:saxon:9.1.0.8'
implementation 'org.yaml:snakeyaml:1.30'
implementation localGroovy()
implementation 'io.github.gradle-nexus:publish-plugin:1.1.0'
@@ -66,7 +71,7 @@ dependencies {
implementation 'io.spring.nohttp:nohttp-gradle:0.0.9'
implementation 'net.sourceforge.htmlunit:htmlunit:2.37.0'
implementation 'org.hidetake:gradle-ssh-plugin:2.10.1'
implementation 'org.jfrog.buildinfo:build-info-extractor-gradle:4.24.20'
implementation 'org.jfrog.buildinfo:build-info-extractor-gradle:4.29.0'
implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1'
testImplementation platform('org.junit:junit-bom:5.8.1')

View File

@@ -18,6 +18,7 @@ package io.spring.gradle.convention
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
class ArtifactoryPlugin implements Plugin<Project> {
@@ -37,8 +38,14 @@ class ArtifactoryPlugin implements Plugin<Project> {
password = artifactoryPassword
}
}
defaults {
publications('mavenJava')
}
}
project.plugins.withType(MavenPublishPlugin) {
project.artifactory {
publish {
defaults {
publications('mavenJava')
}
}
}
}

View File

@@ -32,6 +32,7 @@ class RootProjectPlugin implements Plugin<Project> {
pluginManager.apply(SchemaPlugin)
pluginManager.apply(NoHttpPlugin)
pluginManager.apply(SpringNexusPublishPlugin)
pluginManager.apply(ArtifactoryPlugin)
pluginManager.apply("org.sonarqube")
project.repositories.mavenCentral()

View File

@@ -0,0 +1,71 @@
package org.springframework.gradle.antora;
import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.language.base.plugins.LifecycleBasePlugin;
public class AntoraVersionPlugin implements Plugin<Project> {
public static final String ANTORA_CHECK_VERSION_TASK_NAME = "antoraCheckVersion";
@Override
public void apply(Project project) {
TaskProvider<CheckAntoraVersionTask> antoraCheckVersion = project.getTasks().register(ANTORA_CHECK_VERSION_TASK_NAME, CheckAntoraVersionTask.class, new Action<CheckAntoraVersionTask>() {
@Override
public void execute(CheckAntoraVersionTask antoraCheckVersion) {
antoraCheckVersion.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
antoraCheckVersion.setDescription("Checks the antora.yml version properties match the Gradle version");
antoraCheckVersion.getAntoraVersion().convention(project.provider(() -> getDefaultAntoraVersion(project)));
antoraCheckVersion.getAntoraPrerelease().convention(project.provider(() -> getDefaultAntoraPrerelease(project)));
antoraCheckVersion.getAntoraDisplayVersion().convention(project.provider(() -> getDefaultAntoraDisplayVersion(project)));
antoraCheckVersion.getAntoraYmlFile().fileProvider(project.provider(() -> project.file("antora.yml")));
}
});
project.getPlugins().withType(LifecycleBasePlugin.class, new Action<LifecycleBasePlugin>() {
@Override
public void execute(LifecycleBasePlugin lifecycleBasePlugin) {
project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(new Action<Task>() {
@Override
public void execute(Task check) {
check.dependsOn(antoraCheckVersion);
}
});
}
});
project.getTasks().register("antoraUpdateVersion", UpdateAntoraVersionTask.class, new Action<UpdateAntoraVersionTask>() {
@Override
public void execute(UpdateAntoraVersionTask antoraUpdateVersion) {
antoraUpdateVersion.setGroup("Release");
antoraUpdateVersion.setDescription("Updates the antora.yml version properties to match the Gradle version");
antoraUpdateVersion.getAntoraYmlFile().fileProvider(project.provider(() -> project.file("antora.yml")));
}
});
}
private static String getDefaultAntoraVersion(Project project) {
String projectVersion = getProjectVersion(project);
return AntoraVersionUtils.getDefaultAntoraVersion(projectVersion);
}
private static String getDefaultAntoraPrerelease(Project project) {
String projectVersion = getProjectVersion(project);
return AntoraVersionUtils.getDefaultAntoraPrerelease(projectVersion);
}
private static String getDefaultAntoraDisplayVersion(Project project) {
String projectVersion = getProjectVersion(project);
return AntoraVersionUtils.getDefaultAntoraDisplayVersion(projectVersion);
}
private static String getProjectVersion(Project project) {
Object projectVersion = project.getVersion();
if (projectVersion == null) {
throw new GradleException("Please define antoraVersion and antoraPrerelease on " + ANTORA_CHECK_VERSION_TASK_NAME + " or provide a Project version so they can be defaulted");
}
return String.valueOf(projectVersion);
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.gradle.antora;
public class AntoraVersionUtils {
public static String getDefaultAntoraVersion(String projectVersion) {
int preReleaseIndex = getSnapshotIndex(projectVersion);
return isSnapshot(projectVersion) ? projectVersion.substring(0, preReleaseIndex) : projectVersion;
}
public static String getDefaultAntoraPrerelease(String projectVersion) {
if (isSnapshot(projectVersion)) {
int preReleaseIndex = getSnapshotIndex(projectVersion);
return projectVersion.substring(preReleaseIndex);
}
if (isPreRelease(projectVersion)) {
return Boolean.TRUE.toString();
}
return null;
}
public static String getDefaultAntoraDisplayVersion(String projectVersion) {
if (!isSnapshot(projectVersion) && isPreRelease(projectVersion)) {
return getDefaultAntoraVersion(projectVersion);
}
return null;
}
private static boolean isSnapshot(String projectVersion) {
return getSnapshotIndex(projectVersion) >= 0;
}
private static int getSnapshotIndex(String projectVersion) {
return projectVersion.lastIndexOf("-SNAPSHOT");
}
private static boolean isPreRelease(String projectVersion) {
return projectVersion.lastIndexOf("-") >= 0;
}
}

View File

@@ -0,0 +1,96 @@
package org.springframework.gradle.antora;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.representer.Representer;
public abstract class CheckAntoraVersionTask extends DefaultTask {
@TaskAction
public void check() throws FileNotFoundException {
File antoraYmlFile = getAntoraYmlFile().getAsFile().get();
String expectedAntoraVersion = getAntoraVersion().get();
String expectedAntoraPrerelease = getAntoraPrerelease().getOrElse(null);
String expectedAntoraDisplayVersion = getAntoraDisplayVersion().getOrElse(null);
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml(new Constructor(AntoraYml.class), representer);
AntoraYml antoraYml = yaml.load(new FileInputStream(antoraYmlFile));
String actualAntoraPrerelease = antoraYml.getPrerelease();
boolean preReleaseMatches = antoraYml.getPrerelease() == null && expectedAntoraPrerelease == null ||
(actualAntoraPrerelease != null && actualAntoraPrerelease.equals(expectedAntoraPrerelease));
String actualAntoraDisplayVersion = antoraYml.getDisplay_version();
boolean displayVersionMatches = antoraYml.getDisplay_version() == null && expectedAntoraDisplayVersion == null ||
(actualAntoraDisplayVersion != null && actualAntoraDisplayVersion.equals(expectedAntoraDisplayVersion));
String actualAntoraVersion = antoraYml.getVersion();
if (!preReleaseMatches ||
!displayVersionMatches ||
!expectedAntoraVersion.equals(actualAntoraVersion)) {
throw new GradleException("The Gradle version of '" + getProject().getVersion() + "' should have version: '"
+ expectedAntoraVersion + "' prerelease: '" + expectedAntoraPrerelease + "' display_version: '"
+ expectedAntoraDisplayVersion + "' defined in " + antoraYmlFile + " but got version: '"
+ actualAntoraVersion + "' prerelease: '" + actualAntoraPrerelease + "' display_version: '" + actualAntoraDisplayVersion + "'");
}
}
@InputFile
public abstract RegularFileProperty getAntoraYmlFile();
@Input
public abstract Property<String> getAntoraVersion();
@Input
@Optional
public abstract Property<String> getAntoraPrerelease();
@Input
@Optional
public abstract Property<String> getAntoraDisplayVersion();
public static class AntoraYml {
private String version;
private String prerelease;
private String display_version;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getPrerelease() {
return prerelease;
}
public void setPrerelease(String prerelease) {
this.prerelease = prerelease;
}
public String getDisplay_version() {
return display_version;
}
public void setDisplay_version(String display_version) {
this.display_version = display_version;
}
}
}

View File

@@ -0,0 +1,130 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.gradle.antora;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import org.gradle.api.DefaultTask;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.TaskAction;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.nodes.NodeTuple;
import org.yaml.snakeyaml.nodes.Tag;
import org.yaml.snakeyaml.representer.Representer;
public abstract class UpdateAntoraVersionTask extends DefaultTask {
@TaskAction
public void update() throws IOException {
String projectVersion = getProject().getVersion().toString();
File antoraYmlFile = getAntoraYmlFile().getAsFile().get();
String updatedAntoraVersion = AntoraVersionUtils.getDefaultAntoraVersion(projectVersion);
String updatedAntoraPrerelease = AntoraVersionUtils.getDefaultAntoraPrerelease(projectVersion);
String updatedAntoraDisplayVersion = AntoraVersionUtils.getDefaultAntoraDisplayVersion(projectVersion);
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml(new Constructor(AntoraYml.class), representer);
AntoraYml antoraYml = yaml.load(new FileInputStream(antoraYmlFile));
System.out.println("Updating the version parameters in " + antoraYmlFile.getName() + " to version: "
+ updatedAntoraVersion + ", prerelease: " + updatedAntoraPrerelease + ", display_version: "
+ updatedAntoraDisplayVersion);
antoraYml.setVersion(updatedAntoraVersion);
antoraYml.setPrerelease(updatedAntoraPrerelease);
antoraYml.setDisplay_version(updatedAntoraDisplayVersion);
FileWriter outputWriter = new FileWriter(antoraYmlFile);
getYaml().dump(antoraYml, outputWriter);
}
@InputFile
public abstract RegularFileProperty getAntoraYmlFile();
public static class AntoraYml {
private String name;
private String version;
private String prerelease;
private String display_version;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getPrerelease() {
return prerelease;
}
public void setPrerelease(String prerelease) {
this.prerelease = prerelease;
}
public String getDisplay_version() {
return display_version;
}
public void setDisplay_version(String display_version) {
this.display_version = display_version;
}
}
private Yaml getYaml() {
Representer representer = new Representer() {
@Override
protected NodeTuple representJavaBeanProperty(Object javaBean,
org.yaml.snakeyaml.introspector.Property property, Object propertyValue, Tag customTag) {
// Don't write out null values
if (propertyValue == null) {
return null;
}
else {
return super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
}
}
};
representer.addClassTag(AntoraYml.class, Tag.MAP);
DumperOptions ymlOptions = new DumperOptions();
ymlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
ymlOptions.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
return new Yaml(representer, ymlOptions);
}
}

135
git/hooks/forward-merge Executable file
View File

@@ -0,0 +1,135 @@
#!/usr/bin/ruby
require 'json'
require 'net/http'
require 'yaml'
require 'logger'
$log = Logger.new(STDOUT)
$log.level = Logger::WARN
class ForwardMerge
attr_reader :issue, :milestone, :message, :line
def initialize(issue, milestone, message, line)
@issue = issue
@milestone = milestone
@message = message
@line = line
end
end
def find_forward_merges(message_file)
$log.debug "Searching for forward merge"
rev=`git rev-parse -q --verify MERGE_HEAD`.strip
$log.debug "Found #{rev} from git rev-parse"
return nil unless rev
message = File.read(message_file)
forward_merges = []
message.each_line do |line|
$log.debug "Checking #{line} for message"
match = /^(?:Fixes|Closes) gh-(\d+) in (\d\.\d\.[\dx](?:[\.\-](?:M|RC)\d)?)$/.match(line)
if match then
issue = match[1]
milestone = match[2]
$log.debug "Matched reference to issue #{issue} in milestone #{milestone}"
forward_merges << ForwardMerge.new(issue, milestone, message, line)
end
end
$log.debug "No match in merge message" unless forward_merges
return forward_merges
end
def get_issue(username, password, repository, number)
$log.debug "Getting issue #{number} from GitHub repository #{repository}"
uri = URI("https://api.github.com/repos/#{repository}/issues/#{number}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl=true
request = Net::HTTP::Get.new(uri.path)
request.basic_auth(username, password)
response = http.request(request)
$log.debug "Get HTTP response #{response.code}"
return JSON.parse(response.body) unless response.code != '200'
puts "Failed to retrieve issue #{number}: #{response.message}"
exit 1
end
def find_milestone(username, password, repository, title)
$log.debug "Finding milestone #{title} from GitHub repository #{repository}"
uri = URI("https://api.github.com/repos/#{repository}/milestones")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl=true
request = Net::HTTP::Get.new(uri.path)
request.basic_auth(username, password)
response = http.request(request)
milestones = JSON.parse(response.body)
if title.end_with?(".x")
prefix = title.delete_suffix('.x')
$log.debug "Finding nearest milestone from candidates starting with #{prefix}"
titles = milestones.map { |milestone| milestone['title'] }
titles = titles.select{ |title| title.start_with?(prefix) unless title.end_with?('.x')}
titles = titles.sort_by { |v| Gem::Version.new(v) }
$log.debug "Considering candidates #{titles}"
if(titles.empty?)
puts "Cannot find nearest milestone for prefix #{title}"
exit 1
end
title = titles.first
$log.debug "Found nearest milestone #{title}"
end
milestones.each do |milestone|
$log.debug "Considering #{milestone['title']}"
return milestone['number'] if milestone['title'] == title
end
puts "Milestone #{title} not found in #{repository}"
exit 1
end
def create_issue(username, password, repository, original, title, labels, milestone, milestone_name, dry_run)
$log.debug "Finding forward-merge issue in GitHub repository #{repository} for '#{title}'"
uri = URI("https://api.github.com/repos/#{repository}/issues")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl=true
request = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
request.basic_auth(username, password)
request.body = {
title: title,
labels: labels,
milestone: milestone.to_i,
body: "Forward port of issue ##{original} to #{milestone_name}."
}.to_json
if dry_run then
puts "Dry run"
puts "POSTing to #{uri} with body #{request.body}"
return "dry-run"
end
response = JSON.parse(http.request(request).body)
$log.debug "Created new issue #{response['number']}"
return response['number']
end
$log.debug "Running forward-merge hook script"
message_file=ARGV[0]
forward_merges = find_forward_merges(message_file)
exit 0 unless forward_merges
$log.debug "Loading config from ~/.spring-boot/forward_merge.yml"
config = YAML.load_file(File.join(Dir.home, '.spring-boot', 'forward-merge.yml'))
username = config['github']['credentials']['username']
password = config['github']['credentials']['password']
dry_run = config['dry_run']
repository = 'spring-projects/spring-session'
forward_merges.each do |forward_merge|
existing_issue = get_issue(username, password, repository, forward_merge.issue)
title = existing_issue['title']
labels = existing_issue['labels'].map { |label| label['name'] }
labels << "status: forward-port"
$log.debug "Processing issue '#{title}'"
milestone = find_milestone(username, password, repository, forward_merge.milestone)
new_issue_number = create_issue(username, password, repository, forward_merge.issue, title, labels, milestone, forward_merge.milestone, dry_run)
puts "Created gh-#{new_issue_number} for forward port of gh-#{forward_merge.issue} into #{forward_merge.milestone}"
rewritten_message = forward_merge.message.sub(forward_merge.line, "Closes gh-#{new_issue_number}\n")
File.write(message_file, rewritten_message)
end

71
git/hooks/prepare-forward-merge Executable file
View File

@@ -0,0 +1,71 @@
#!/usr/bin/ruby
require 'json'
require 'net/http'
require 'yaml'
require 'logger'
$main_branch = "3.0.x"
$log = Logger.new(STDOUT)
$log.level = Logger::WARN
def get_fixed_issues()
$log.debug "Searching for for forward merge"
rev=`git rev-parse -q --verify MERGE_HEAD`.strip
$log.debug "Found #{rev} from git rev-parse"
return nil unless rev
fixed = []
message = `git log -1 --pretty=%B #{rev}`
message.each_line do |line|
$log.debug "Checking #{line} for message"
fixed << line.strip if /^(?:Fixes|Closes) gh-(\d+)/.match(line)
end
$log.debug "Found fixed issues #{fixed}"
return fixed;
end
def rewrite_message(message_file, fixed)
current_branch = `git rev-parse --abbrev-ref HEAD`.strip
if current_branch == "main"
current_branch = $main_branch
end
rewritten_message = ""
message = File.read(message_file)
message.each_line do |line|
match = /^Merge.*branch\ '(.*)'(?:\ into\ (.*))?$/.match(line)
if match
from_branch = match[1]
if from_branch.include? "/"
from_branch = from_branch.partition("/").last
end
to_brach = match[2]
$log.debug "Rewriting merge message"
line = "Merge branch '#{from_branch}'" + (to_brach ? " into #{to_brach}\n" : "\n")
end
if fixed and line.start_with?("#")
$log.debug "Adding fixed"
rewritten_message << "\n"
fixed.each do |fixes|
rewritten_message << "#{fixes} in #{current_branch}\n"
end
fixed = nil
end
rewritten_message << line
end
return rewritten_message
end
$log.debug "Running prepare-forward-merge hook script"
message_file=ARGV[0]
message_type=ARGV[1]
if message_type != "merge"
$log.debug "Not a merge commit"
exit 0;
end
$log.debug "Searching for for forward merge"
fixed = get_fixed_issues()
rewritten_message = rewrite_message(message_file, fixed)
File.write(message_file, rewritten_message)

View File

@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
version=3.0.0-RC1
version=3.0.1

View File

@@ -1,12 +1,12 @@
dependencyManagement {
imports {
mavenBom 'io.projectreactor:reactor-bom:2022.0.0-RC1'
mavenBom 'com.fasterxml.jackson:jackson-bom:2.13.4.20221013'
mavenBom 'org.junit:junit-bom:5.9.1'
mavenBom 'io.projectreactor:reactor-bom:2022.0.5'
mavenBom 'com.fasterxml.jackson:jackson-bom:2.14.2'
mavenBom 'org.junit:junit-bom:5.9.2'
mavenBom 'org.mockito:mockito-bom:4.8.1'
mavenBom 'org.springframework:spring-framework-bom:6.0.0-RC1'
mavenBom 'org.springframework.data:spring-data-bom:2022.0.0-RC1'
mavenBom 'org.springframework.security:spring-security-bom:6.0.0-RC1'
mavenBom 'org.springframework:spring-framework-bom:6.0.6'
mavenBom 'org.springframework.data:spring-data-bom:2022.0.3'
mavenBom 'org.springframework.security:spring-security-bom:6.0.2'
mavenBom 'org.testcontainers:testcontainers-bom:1.17.3'
}
@@ -22,7 +22,9 @@ dependencyManagement {
dependency 'com.zaxxer:HikariCP:5.0.1'
dependency 'edu.umd.cs.mtc:multithreadedtc:1.01'
dependency 'io.lettuce:lettuce-core:6.2.1.RELEASE'
dependency 'jakarta.servlet:jakarta.servlet-api:5.0.0'
dependency 'jakarta.servlet:jakarta.servlet-api:6.0.0'
dependency 'jakarta.websocket:jakarta.websocket-api:2.1.0'
dependency 'jakarta.websocket:jakarta.websocket-client-api:2.1.0'
dependency 'mysql:mysql-connector-java:8.0.30'
dependencySet(group: 'org.apache.derby', version: '10.16.1.1') {
entry 'derby'
@@ -32,7 +34,7 @@ dependencyManagement {
dependency 'org.hamcrest:hamcrest:2.2'
dependency 'org.hsqldb:hsqldb:2.7.0'
dependency 'org.mariadb.jdbc:mariadb-java-client:3.0.7'
dependencySet(group: 'org.mongodb', version: '4.8.0-beta0') {
dependencySet(group: 'org.mongodb', version: '4.8.2') {
entry 'mongodb-driver-core'
entry 'mongodb-driver-sync'
entry 'mongodb-driver-reactivestreams'

View File

@@ -12,6 +12,7 @@ plugins {
rootProject.name = 'spring-session-build'
include 'spring-session-bom'
include 'spring-session-core'
include 'spring-session-data-mongodb'
include 'spring-session-data-redis'

View File

@@ -0,0 +1,15 @@
import io.spring.gradle.convention.SpringModulePlugin
plugins {
id("io.spring.convention.bom")
}
dependencies {
constraints {
project.rootProject.allprojects { project ->
project.plugins.withType(SpringModulePlugin) {
api(project)
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,14 +19,11 @@ package org.springframework.session.web.http;
import java.time.Duration;
import java.util.Collections;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Set;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionBindingEvent;
import jakarta.servlet.http.HttpSessionBindingListener;
import jakarta.servlet.http.HttpSessionContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,12 +38,11 @@ import org.springframework.session.Session;
* @author Vedran Pavic
* @since 1.1
*/
@SuppressWarnings("deprecation")
class HttpSessionAdapter<S extends Session> implements HttpSession {
private static final Log logger = LogFactory.getLog(HttpSessionAdapter.class);
private S session;
private final S session;
private final ServletContext servletContext;
@@ -101,35 +97,18 @@ class HttpSessionAdapter<S extends Session> implements HttpSession {
return (int) this.session.getMaxInactiveInterval().getSeconds();
}
@Override
public HttpSessionContext getSessionContext() {
return NOOP_SESSION_CONTEXT;
}
@Override
public Object getAttribute(String name) {
checkState();
return this.session.getAttribute(name);
}
@Override
public Object getValue(String name) {
return getAttribute(name);
}
@Override
public Enumeration<String> getAttributeNames() {
checkState();
return Collections.enumeration(this.session.getAttributeNames());
}
@Override
public String[] getValueNames() {
checkState();
Set<String> attrs = this.session.getAttributeNames();
return attrs.toArray(new String[0]);
}
@Override
public void setAttribute(String name, Object value) {
checkState();
@@ -156,11 +135,6 @@ class HttpSessionAdapter<S extends Session> implements HttpSession {
}
}
@Override
public void putValue(String name, Object value) {
setAttribute(name, value);
}
@Override
public void removeAttribute(String name) {
checkState();
@@ -176,11 +150,6 @@ class HttpSessionAdapter<S extends Session> implements HttpSession {
}
}
@Override
public void removeValue(String name) {
removeAttribute(name);
}
@Override
public void invalidate() {
checkState();
@@ -203,32 +172,4 @@ class HttpSessionAdapter<S extends Session> implements HttpSession {
}
}
private static final HttpSessionContext NOOP_SESSION_CONTEXT = new HttpSessionContext() {
@Override
public HttpSession getSession(String sessionId) {
return null;
}
@Override
public Enumeration<String> getIds() {
return EMPTY_ENUMERATION;
}
};
private static final Enumeration<String> EMPTY_ENUMERATION = new Enumeration<String>() {
@Override
public boolean hasMoreElements() {
return false;
}
@Override
public String nextElement() {
throw new NoSuchElementException("a");
}
};
}

View File

@@ -24,7 +24,6 @@ import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -40,7 +39,6 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionBindingEvent;
import jakarta.servlet.http.HttpSessionBindingListener;
import jakarta.servlet.http.HttpSessionContext;
import org.assertj.core.data.Offset;
import org.junit.jupiter.api.BeforeEach;
@@ -80,7 +78,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* Tests for {@link SessionRepositoryFilter}.
*/
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
class SessionRepositoryFilterTests {
@Mock
@@ -316,52 +313,6 @@ class SessionRepositoryFilterTests {
});
}
@Test
void doFilterValue() throws Exception {
final String ATTR = "ATTR";
final String VALUE = "VALUE";
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
wrappedRequest.getSession().putValue(ATTR, VALUE);
assertThat(wrappedRequest.getSession().getValue(ATTR)).isEqualTo(VALUE);
assertThat(Arrays.asList(wrappedRequest.getSession().getValueNames())).containsOnly(ATTR);
}
});
nextRequest();
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
assertThat(wrappedRequest.getSession().getValue(ATTR)).isEqualTo(VALUE);
assertThat(Arrays.asList(wrappedRequest.getSession().getValueNames())).containsOnly(ATTR);
}
});
nextRequest();
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
assertThat(wrappedRequest.getSession().getValue(ATTR)).isEqualTo(VALUE);
wrappedRequest.getSession().removeValue(ATTR);
assertThat(wrappedRequest.getSession().getValue(ATTR)).isNull();
}
});
nextRequest();
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
assertThat(wrappedRequest.getSession().getValue(ATTR)).isNull();
}
});
}
@Test
void doFilterIsNewTrue() throws Exception {
doFilter(new DoInFilter() {
@@ -637,27 +588,6 @@ class SessionRepositoryFilterTests {
assertThat(session.getSecure()).describedAs("Session Cookie should be marked as Secure").isTrue();
}
@Test
void doFilterSessionContext() throws Exception {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
HttpSessionContext sessionContext = wrappedRequest.getSession().getSessionContext();
assertThat(sessionContext).isNotNull();
assertThat(sessionContext.getSession("a")).isNull();
assertThat(sessionContext.getIds()).isNotNull();
assertThat(sessionContext.getIds().hasMoreElements()).isFalse();
try {
sessionContext.getIds().nextElement();
fail("Expected Exception");
}
catch (NoSuchElementException ignored) {
}
}
});
}
// --- saving
@Test
@@ -741,23 +671,6 @@ class SessionRepositoryFilterTests {
});
}
@Test
void doFilterInvalidateValueIllegalState() throws Exception {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
HttpSession session = wrappedRequest.getSession();
session.invalidate();
try {
session.getValue("attr");
fail("Expected Exception");
}
catch (IllegalStateException ignored) {
}
}
});
}
@Test
void doFilterInvalidateAttributeNamesIllegalState() throws Exception {
doFilter(new DoInFilter() {
@@ -775,23 +688,6 @@ class SessionRepositoryFilterTests {
});
}
@Test
void doFilterInvalidateValueNamesIllegalState() throws Exception {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
HttpSession session = wrappedRequest.getSession();
session.invalidate();
try {
session.getValueNames();
fail("Expected Exception");
}
catch (IllegalStateException ignored) {
}
}
});
}
@Test
void doFilterInvalidateSetAttributeIllegalState() throws Exception {
doFilter(new DoInFilter() {
@@ -809,23 +705,6 @@ class SessionRepositoryFilterTests {
});
}
@Test
void doFilterInvalidatePutValueIllegalState() throws Exception {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
HttpSession session = wrappedRequest.getSession();
session.invalidate();
try {
session.putValue("a", "b");
fail("Expected Exception");
}
catch (IllegalStateException ignored) {
}
}
});
}
@Test
void doFilterInvalidateRemoveAttributeIllegalState() throws Exception {
doFilter(new DoInFilter() {
@@ -843,23 +722,6 @@ class SessionRepositoryFilterTests {
});
}
@Test
void doFilterInvalidateRemoveValueIllegalState() throws Exception {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
HttpSession session = wrappedRequest.getSession();
session.invalidate();
try {
session.removeValue("name");
fail("Expected Exception");
}
catch (IllegalStateException ignored) {
}
}
});
}
@Test
void doFilterInvalidateNewIllegalState() throws Exception {
doFilter(new DoInFilter() {
@@ -921,20 +783,6 @@ class SessionRepositoryFilterTests {
});
}
@Test
void doFilterInvalidateSessionContext() throws Exception {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest) {
HttpSession session = wrappedRequest.getSession();
session.invalidate();
// no exception
session.getSessionContext();
}
});
}
@Test
void doFilterInvalidateMaxInteractiveInterval() throws Exception {
doFilter(new DoInFilter() {
@@ -1339,8 +1187,9 @@ class SessionRepositoryFilterTests {
@Test
void order() {
assertThat(AnnotationAwareOrderComparator.INSTANCE.compare(this.filter,
new SessionRepositoryFilterDefaultOrder()));
assertThat(
AnnotationAwareOrderComparator.INSTANCE.compare(this.filter, new SessionRepositoryFilterDefaultOrder()))
.isZero();
}
// We want the filter to work without any dependencies on Spring
@@ -1552,7 +1401,7 @@ class SessionRepositoryFilterTests {
}
private abstract class DoInFilter {
private abstract static class DoInFilter {
void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws ServletException, IOException {

View File

@@ -18,6 +18,8 @@ dependencies {
optional "org.mongodb:mongodb-driver-core"
testImplementation "org.mongodb:mongodb-driver-sync"
testImplementation "org.mongodb:mongodb-driver-reactivestreams"
testImplementation 'jakarta.websocket:jakarta.websocket-api'
testImplementation 'jakarta.websocket:jakarta.websocket-client-api'
integrationTestCompile "org.testcontainers:mongodb"
// Everything else

View File

@@ -1,27 +0,0 @@
site:
title: Spring Session
url: https://docs.spring.io/spring-session/reference/
asciidoc:
attributes:
page-pagination: true
content:
sources:
- url: https://github.com/spring-io/spring-generated-docs
branches: [spring-projects/spring-session/*]
- url: https://github.com/spring-projects/spring-session
branches: [main,2.7.x,2.6.x]
tags: [ '3.0.*', '2.7.*', '2.6.*','!2.6.0-M*','!2.6.0-RC*','!2.7.0-M1','!3.0.0-M1']
start_path: spring-session-docs
urls:
latest_version_segment_strategy: redirect:to
latest_version_segment: ''
redirect_facility: httpd
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/latest/ui-bundle.zip
snapshot: true
antora:
extensions:
- require: ./antora/extensions/version-fix.js
- require: ./antora/extensions/major-minor-segment.js

View File

@@ -1,4 +1,12 @@
name: ROOT
version: '3.0.0-RC1'
prerelease: 'true'
display_version: '3.0.0-RC1'
version: true
title: Documentation
nav:
- modules/ROOT/nav.adoc
ext:
collector:
run:
command: gradlew -q -PbuildSrc.skipTests=true "-Dorg.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError" :spring-session-docs:generateAntoraYml
local: true
scan:
dir: ./build/generated-antora-resources

View File

@@ -0,0 +1,35 @@
# PACKAGES antora@3.2.0-alpha.2 @antora/atlas-extension:1.0.0-alpha.1 @antora/collector-extension@1.0.0-alpha.3 @springio/antora-extensions@1.0.0 @asciidoctor/tabs@1.0.0-beta.3 @opendevise/antora-release-line-extension@1.0.0
#
# The purpose of this Antora playbook is to build the docs in the current branch.
antora:
extensions:
- '@antora/collector-extension'
- id: '@antora/atlas-extension'
require: '@antora/atlas-extension'
enabled: false
- '@opendevise/antora-release-line-extension'
- require: '@springio/antora-extensions/tabs-migration-extension'
unwrap_example_block: always
site:
title: Spring Session Reference
content:
sources:
- url: ./..
branches: HEAD
start_path: spring-session-docs
worktrees: true
asciidoc:
attributes:
hide-uri-scheme: '@'
page-pagination: ''
primary-site-url: https://docs.spring.io/spring-session/reference
tabs-sync-option: '@'
extensions:
- '@asciidoctor/tabs'
sourcemap: true
urls:
latest_version_segment: ''
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/latest/ui-bundle.zip
snapshot: true

View File

@@ -1,26 +0,0 @@
site:
title: Spring
url: https://docs.spring.io/spring-session/reference/
asciidoc:
attributes:
page-pagination: true
content:
sources:
- url: ../../spring-io/spring-generated-docs
branches: [spring-projects/spring-session/*]
- url: ../../spring-projects/spring-session
branches: [main]
start_path: spring-session-docs
urls:
latest_version_segment_strategy: redirect:to
latest_version_segment: ''
redirect_facility: httpd
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/latest/ui-bundle.zip
snapshot: true
antora:
extensions:
- require: ./antora/extensions/version-fix.js
- require: ./antora/extensions/major-minor-segment.js

View File

@@ -51,7 +51,7 @@ public class RememberMeSecurityConfiguration {
return http
.formLogin(Customizer.withDefaults())
.authorizeRequests((authorize) -> authorize
.authorizeHttpRequests((authorize) -> authorize
.anyRequest().authenticated()
).build();
}

View File

@@ -15,7 +15,6 @@
*** xref:guides/boot-webflux-custom-cookie.adoc[Custom Cookie]
** Java Configuration
** XML Configuration
* xref:modules.adoc[Modules]
* xref:http-session.adoc[HttpSession Integration]
* xref:web-socket.adoc[WebSocket Integration]
* xref:web-session.adoc[WebSession Integration]

View File

@@ -75,9 +75,9 @@ For example, you can include the following in your application.properties:
====
.src/main/resources/application.properties
----
spring.redis.host=localhost # Redis server host.
spring.redis.password= # Login password of the redis server.
spring.redis.port=6379 # Redis server port.
spring.data.redis.host=localhost # Redis server host.
spring.data.redis.password= # Login password of the redis server.
spring.data.redis.port=6379 # Redis server port.
----
====

View File

@@ -100,7 +100,7 @@ Spring Session provides `PrincipalNameExtractor` for this purpose.
is not set, Hazelcast will serialize sessions using native Java serialization.
<4> We create a `HazelcastInstance` that connects Spring Session to Hazelcast.
By default, the application starts and connects to an embedded instance of Hazelcast.
For more information on configuring Hazelcast, see the https://docs.hazelcast.org/docs/{hazelcast-version}/manual/html-single/index.html#hazelcast-configuration[reference documentation].
For more information on configuring Hazelcast, see the https://docs.hazelcast.com/hazelcast/latest/[reference documentation].
====
NOTE: If `HazelcastSessionSerializer` is preferred, it needs to be configured for all Hazelcast cluster members before they start.
@@ -161,7 +161,7 @@ $ ./gradlew :spring-session-sample-javaconfig-hazelcast:tomcatRun
====
NOTE: By default, Hazelcast runs in embedded mode with your application.
However, if you want to connect to a standalone instance instead, you can configure it by following the instructions in the https://docs.hazelcast.org/docs/{hazelcast-version}/manual/html-single/index.html#hazelcast-configuration[reference documentation].
However, if you want to connect to a standalone instance instead, you can configure it by following the instructions in the https://docs.hazelcast.com/hazelcast/latest/getting-started/get-started-cli[reference documentation].
You should now be able to access the application at http://localhost:8080/
@@ -188,9 +188,9 @@ You can view the cookies (with https://developers.google.com/web/tools/chrome-de
=== Interacting with the Data Store
You can remove the session by using https://docs.hazelcast.org/docs/{hazelcast-version}/manual/html-single/index.html#hazelcast-java-client[a Java client],
https://docs.hazelcast.org/docs/{hazelcast-version}/manual/html-single/index.html#other-client-implementations[one of the other clients], or the
https://docs.hazelcast.org/docs/{hazelcast-version}/manual/html-single/index.html#management-center[management center].
You can remove the session by using https://docs.hazelcast.com/hazelcast/latest/clients/java[a Java client],
https://hazelcast.com/clients/[one of the other clients], or the
https://docs.hazelcast.com/management-center/latest/getting-started/overview[management center].
==== Using the Console
@@ -203,7 +203,7 @@ For example, to remove the session by using the management center console after
----
====
TIP: The Hazelcast documentation has instructions for https://docs.hazelcast.org/docs/{hazelcast-version}/manual/html-single/index.html#executing-console-commands[the console].
TIP: The Hazelcast documentation has instructions for https://docs.hazelcast.com/hazelcast/latest/clients/clc[the console].
Alternatively, you can also delete the explicit key. Enter the following into the console, being sure to replace `7e8383a4-082c-4ffe-a4bc-c40fd3363c5e` with the value of your `SESSION` cookie:
@@ -218,7 +218,7 @@ Now visit the application at http://localhost:8080/ and observe that we are no l
==== Using the REST API
As described in the section of the documentation that cover other clients, there is a
https://docs.hazelcast.org/docs/{hazelcast-version}/manual/html-single/index.html#rest-client[REST API]
https://docs.hazelcast.com/hazelcast/latest/clients/rest[REST API]
provided by the Hazelcast node(s).
For example, you could delete an individual key as follows (being sure to replace `7e8383a4-082c-4ffe-a4bc-c40fd3363c5e` with the value of your SESSION cookie):

View File

@@ -1,22 +0,0 @@
[[modules]]
= Spring Session Modules
In Spring Session 1.x, all of the Spring Session's `SessionRepository` implementations were available within the `spring-session` artifact.
While convenient, this approach was not sustainable long-term as more features and `SessionRepository` implementations were added to the project.
With Spring Session 2.0, several modules were split off to be separate modules as well as managed repositories.
Spring Session for MongoDB was retired, but was later reactivated as a separate module.
As of Spring Session 2.6, Spring Session for MongoDB was merged back into Spring Session.
Now the situation with the various repositories and modules is as follows:
* https://github.com/spring-projects/spring-session[`spring-session` repository]
** Hosts the Spring Session Core, Spring Session for MongoDB, Spring Session for Redis, Spring Session JDBC, and Spring Session Hazelcast modules.
* https://github.com/spring-projects/spring-session-data-geode[`spring-session-data-geode` repository]
** Hosts the Spring Session Data Geode modules. Spring Session Data Geode has its own user guide, which you can find at the [https://spring.io/projects/spring-session-data-geode#learn site].
Finally, Spring Session also provides a Maven BOM ("`bill of materials`") module in order to help users with version management concerns:
* https://github.com/spring-projects/spring-session-bom[`spring-session-bom` repository]
** Hosts the Spring Session BOM module

View File

@@ -1,4 +1 @@
= What's New
Check also the Spring Session BOM https://github.com/spring-projects/spring-session-bom/wiki#release-notes[release notes]
for a list of new and noteworthy features, as well as upgrade instructions for each release.

View File

@@ -1,5 +1,6 @@
plugins {
id "io.github.rwinch.antora" version "0.0.2"
id 'org.antora' version '1.0.0'
id 'io.spring.antora.generate-antora-yml' version '0.0.1'
}
apply plugin: 'io.spring.convention.docs'
@@ -29,16 +30,54 @@ dependencies {
}
antora {
antoraVersion = "3.1.0"
arguments = ["--fetch"]
playbook = 'cached-antora-playbook.yml'
playbookProvider {
repository = 'spring-projects/spring-session'
branch = 'docs-build'
path = 'lib/antora/templates/per-branch-antora-playbook.yml'
checkLocalBranch = true
}
options = [clean: true, fetch: !project.gradle.startParameter.offline, stacktrace: true]
}
tasks.antora {
environment = [
"ALGOLIA_API_KEY" : "82c7ead946afbac3cf98c32446154691",
"ALGOLIA_APP_ID" : "244V8V9FGG",
"ALGOLIA_INDEX_NAME" : "session-docs"
]
tasks.named("generateAntoraYml") {
asciidocAttributes = project.provider( { generateAttributes() } )
}
def generateAttributes() {
def dollar = '$'
def ghTag = snapshotBuild ? 'main' : project.version
def ghUrl = "https://github.com/spring-projects/spring-session/tree/${ghTag.toString()}"
def snapshotBuild = project.version.contains("SNAPSHOT")
def milestoneBuild = project.version.contains("-M")
def releaseBuild = (!snapshotBuild && !milestoneBuild)
def springBootVersion = "2.7.0"
def downloadUrl = "https://github.com/spring-projects/spring-session/archive/${ghTag}.zip"
def ghSamplesUrl = "$ghUrl/spring-session-samples/"
def samplesDir = "example${dollar}spring-session-samples/"
def sessionJdbcMainResourcesDir = "example${dollar.toString()}session-jdbc-main-resources-dir/"
def springSessionDataMongoDbDir = "example${dollar.toString()}spring-session-data-mongodb-dir/"
def docsTestDir = "example${dollar.toString()}java/"
def websocketdocTestDir = "example${dollar.toString()}java/docs/websocket/"
def docsTestResourcesDir = "example${dollar.toString()}resources/"
def indexdocTests = "example${dollar.toString()}java/docs/IndexDocTests.java"
return [
'download-url': downloadUrl.toString(),
'gh-samples-url': ghSamplesUrl.toString(),
'samples-dir': samplesDir.toString(),
'session-jdbc-main-resources-dir': sessionJdbcMainResourcesDir.toString(),
'spring-session-data-mongodb-dir': springSessionDataMongoDbDir.toString(),
'docs-test-dir': docsTestDir.toString(),
'websocketdoc-test-dir': websocketdocTestDir.toString(),
'docs-test-resources-dir': docsTestResourcesDir.toString(),
'indexdoc-tests': indexdocTests.toString(),
'spring-session-version': project.version,
'version-milestone': milestoneBuild,
'version-release': releaseBuild,
'version-snapshot': snapshotBuild,
'spring-boot-version': springBootVersion
] + resolvedVersions(project.configurations.testRuntimeClasspath)
}
sourceSets {
@@ -52,58 +91,16 @@ sourceSets {
}
}
tasks.register("generateAntora") {
group = "Documentation"
description = "Generates the antora.yml for dynamic properties"
doLast {
def dollar = '$'
def ghTag = snapshotBuild ? 'main' : project.version
def ghUrl = "https://github.com/spring-projects/spring-session/tree/$ghTag"
def versions = resolvedVersions(project.configurations.testRuntimeClasspath)
def ymlVersions = ""
versions.call().each { name, version ->
ymlVersions += """
${name}: ${version}"""
}
def outputFile = new File("$buildDir/generateAntora/antora.yml")
outputFile.getParentFile().mkdirs()
outputFile.createNewFile()
def antoraYmlText = file("antora.yml").getText()
outputFile.setText("""$antoraYmlText
title: Spring Session
start_page: ROOT:index.adoc
nav:
- modules/ROOT/nav.adoc
asciidoc:
attributes:
download-url: "https://github.com/spring-projects/spring-session/archive/${ghTag}.zip"
gh-samples-url: "$ghUrl/spring-session-samples/"
samples-dir: "example${dollar}spring-session-samples/"
session-jdbc-main-resources-dir: "example${dollar}session-jdbc-main-resources-dir/"
spring-session-data-mongodb-dir: "example${dollar}spring-session-data-mongodb-dir/"
docs-test-dir: "example${dollar}java/"
websocketdoc-test-dir: 'example${dollar}java/docs/websocket/'
docs-test-resources-dir: "example${dollar}resources/"
indexdoc-tests: "example${dollar}java/docs/IndexDocTests.java"
spring-session-version: ${project.version}
version-milestone: $milestoneBuild
version-release: $releaseBuild
version-snapshot: $snapshotBuild
spring-boot-version: ${springBootVersion}
${ymlVersions}
""")
}
}
repositories {
maven { url "https://repo.spring.io/release" }
mavenCentral()
maven { url 'https://repo.spring.io/release' }
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
def resolvedVersions(Configuration configuration) {
return {
configuration.resolvedConfiguration
return configuration.resolvedConfiguration
.resolvedArtifacts
.collectEntries { [(it.name + "-version"): it.moduleVersion.id.version] }
}
}

View File

@@ -36,7 +36,7 @@ public class SecurityConfig {
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeRequests((authorize) -> authorize
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.anyRequest().authenticated()
)

View File

@@ -35,7 +35,7 @@ public class SecurityConfig {
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeRequests((authorize) -> authorize
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.anyRequest().authenticated()
)

View File

@@ -45,7 +45,7 @@ public class SecurityConfig {
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeRequests((authorize) -> authorize
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.anyRequest().authenticated()
)

View File

@@ -35,7 +35,7 @@ public class SecurityConfig {
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeRequests((authorize) -> authorize
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.anyRequest().authenticated()
)

View File

@@ -36,7 +36,7 @@ public class SecurityConfig {
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeRequests((authorize) -> authorize
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.anyRequest().authenticated()
)

View File

@@ -54,7 +54,7 @@ public class WebSecurityConfig {
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeRequests((authorize) -> authorize
.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.anyRequest().authenticated()
)

View File

@@ -13,8 +13,9 @@ dependencies {
implementation "ch.qos.logback:logback-classic"
implementation "org.testcontainers:testcontainers"
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter-api"

View File

@@ -16,6 +16,7 @@ dependencies {
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter-api"

View File

@@ -14,6 +14,7 @@ dependencies {
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter-api"

View File

@@ -15,6 +15,7 @@ dependencies {
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter-api"

View File

@@ -1,31 +0,0 @@
plugins {
id "org.gretty" version "4.0.0"
id "io.spring.convention.spring-sample-war"
}
dependencies {
implementation project(':spring-session-data-redis')
implementation "io.lettuce:lettuce-core"
implementation "org.springframework:spring-webmvc"
implementation "org.springframework.security:spring-security-config"
implementation "org.springframework.security:spring-security-web"
implementation "com.fasterxml.jackson.core:jackson-databind"
implementation "org.slf4j:slf4j-api"
implementation "org.slf4j:jcl-over-slf4j"
implementation "org.slf4j:log4j-over-slf4j"
implementation "ch.qos.logback:logback-classic"
implementation "org.testcontainers:testcontainers"
providedCompile "jakarta.servlet:jakarta.servlet-api"
testImplementation "org.springframework.security:spring-security-test"
testImplementation "org.assertj:assertj-core"
testImplementation "org.springframework:spring-test"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
}
gretty {
jvmArgs = ['-Dspring.profiles.active=embedded-redis']
servletContainer = 'tomcat10'
}

View File

@@ -1,112 +0,0 @@
/*
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.GenericContainer;
import sample.SecurityConfig;
import sample.mvc.MvcConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.session.Session;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.HeaderHttpSessionIdResolver;
import org.springframework.session.web.http.HttpSessionIdResolver;
import org.springframework.session.web.http.SessionRepositoryFilter;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = { RestMockMvcTests.Config.class, SecurityConfig.class, MvcConfig.class })
@WebAppConfiguration
class RestMockMvcTests {
private static final String DOCKER_IMAGE = "redis:7.0.4-alpine";
@Autowired
private SessionRepositoryFilter<? extends Session> sessionRepositoryFilter;
@Autowired
private WebApplicationContext context;
private MockMvc mvc;
@BeforeEach
void setup() {
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).alwaysDo(print())
.addFilters(this.sessionRepositoryFilter).apply(springSecurity()).build();
}
@Test
void noSessionOnNoCredentials() throws Exception {
this.mvc.perform(get("/")).andExpect(header().doesNotExist("X-Auth-Token"))
.andExpect(status().isUnauthorized());
}
@WithMockUser
@Test
void autheticatedAnnotation() throws Exception {
this.mvc.perform(get("/")).andExpect(content().string("{\"username\":\"user\"}"));
}
@Test
void autheticatedRequestPostProcessor() throws Exception {
this.mvc.perform(get("/").with(user("user"))).andExpect(content().string("{\"username\":\"user\"}"));
}
@Configuration
@EnableRedisHttpSession
static class Config {
@Bean
GenericContainer redisContainer() {
GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE).withExposedPorts(6379);
redisContainer.start();
return redisContainer;
}
@Bean
LettuceConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory(redisContainer().getHost(), redisContainer().getFirstMappedPort());
}
@Bean
HttpSessionIdResolver httpSessionIdResolver() {
return HeaderHttpSessionIdResolver.xAuthToken();
}
}
}

View File

@@ -1,125 +0,0 @@
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import java.util.Base64;
import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Pool Dolorier
*/
class RestTests {
private static final String AUTHORIZATION = "Authorization";
private static final String BASIC = "Basic ";
private static final String X_AUTH_TOKEN = "X-Auth-Token";
private RestTemplate restTemplate;
private String baseUrl;
@BeforeEach
void setUp() {
this.baseUrl = "http://localhost:" + System.getProperty("app.port");
this.restTemplate = new RestTemplate();
}
@Test
void unauthenticatedUserSentToLogInPage() {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
assertThatExceptionOfType(HttpClientErrorException.class)
.isThrownBy(() -> getForUser(this.baseUrl + "/", headers, String.class))
.satisfies((e) -> assertThat(e.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED));
}
@Test
void authenticateWithBasicWorks() {
String auth = getAuth("user", "password");
HttpHeaders headers = getHttpHeaders();
headers.set(AUTHORIZATION, BASIC + auth);
ResponseEntity<User> entity = getForUser(this.baseUrl + "/", headers, User.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getHeaders().containsKey(X_AUTH_TOKEN)).isTrue();
assertThat(entity.getBody().getUsername()).isEqualTo("user");
}
@Test
void authenticateWithXAuthTokenWorks() {
String auth = getAuth("user", "password");
HttpHeaders headers = getHttpHeaders();
headers.set(AUTHORIZATION, BASIC + auth);
ResponseEntity<User> entity = getForUser(this.baseUrl + "/", headers, User.class);
String token = entity.getHeaders().getFirst(X_AUTH_TOKEN);
HttpHeaders authTokenHeader = new HttpHeaders();
authTokenHeader.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
authTokenHeader.set(X_AUTH_TOKEN, token);
ResponseEntity<User> authTokenResponse = getForUser(this.baseUrl + "/", authTokenHeader, User.class);
assertThat(authTokenResponse.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(authTokenResponse.getBody().getUsername()).isEqualTo("user");
}
@Test
void logout() {
String auth = getAuth("user", "password");
HttpHeaders headers = getHttpHeaders();
headers.set(AUTHORIZATION, BASIC + auth);
ResponseEntity<User> entity = getForUser(this.baseUrl + "/", headers, User.class);
String token = entity.getHeaders().getFirst(X_AUTH_TOKEN);
HttpHeaders logoutHeader = getHttpHeaders();
logoutHeader.set(X_AUTH_TOKEN, token);
ResponseEntity<User> logoutResponse = getForUser(this.baseUrl + "/logout", logoutHeader, User.class);
assertThat(logoutResponse.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}
private <T> ResponseEntity<T> getForUser(String resourceUrl, HttpHeaders headers, Class<T> type) {
return this.restTemplate.exchange(resourceUrl, HttpMethod.GET, new HttpEntity<T>(headers), type);
}
private HttpHeaders getHttpHeaders() {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
return headers;
}
private String getAuth(String user, String password) {
String auth = user + ":" + password;
return Base64.getEncoder().encodeToString(auth.getBytes());
}
}

View File

@@ -1,34 +0,0 @@
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
/**
* @author Pool Dolorier
*/
public class User {
private String username;
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import org.testcontainers.containers.GenericContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
@Configuration
@Profile("embedded-redis")
public class EmbeddedRedisConfig {
private static final String DOCKER_IMAGE = "redis:7.0.4-alpine";
@Bean
public GenericContainer redisContainer() {
GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE).withExposedPorts(6379);
redisContainer.start();
return redisContainer;
}
@Bean
@Primary
public LettuceConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory(redisContainer().getHost(), redisContainer().getFirstMappedPort());
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.HeaderHttpSessionIdResolver;
import org.springframework.session.web.http.HttpSessionIdResolver;
@Import(EmbeddedRedisConfig.class)
// tag::class[]
@Configuration
@EnableRedisHttpSession // <1>
public class HttpSessionConfig {
@Bean
public LettuceConnectionFactory connectionFactory() {
return new LettuceConnectionFactory(); // <2>
}
@Bean
public HttpSessionIdResolver httpSessionIdResolver() {
return HeaderHttpSessionIdResolver.xAuthToken(); // <3>
}
}
// end::class[]

View File

@@ -1,25 +0,0 @@
/*
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import org.springframework.session.web.context.AbstractHttpSessionApplicationInitializer;
// tag::class[]
public class Initializer extends AbstractHttpSessionApplicationInitializer {
}
// end::class[]

View File

@@ -1,55 +0,0 @@
/*
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.savedrequest.NullRequestCache;
@Configuration(proxyBeanMethods = false)
@EnableWebSecurity
public class SecurityConfig {
// @formatter:off
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.requestCache((requestCache) -> requestCache
.requestCache(new NullRequestCache())
)
.httpBasic(Customizer.withDefaults())
.build();
}
// @formatter:on
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser(User.withUsername("user").password("{noop}password").roles("USER").build());
}
}

View File

@@ -1,26 +0,0 @@
/*
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
/**
* @author Rob Winch
*/
public class SecurityInitializer extends AbstractSecurityWebApplicationInitializer {
}

View File

@@ -1,31 +0,0 @@
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.mvc;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* @author Rob Winch
*/
@Configuration
@EnableWebMvc
@ComponentScan
public class MvcConfig {
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.mvc;
import sample.HttpSessionConfig;
import sample.SecurityConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
/**
* @author Rob Winch
*/
public class MvcInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
// tag::config[]
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { SecurityConfig.class, HttpSessionConfig.class };
}
// end::config[]
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { MvcConfig.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.mvc;
import java.security.Principal;
import java.util.HashMap;
import java.util.Map;
import jakarta.servlet.http.HttpSession;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
/**
* @author Rob Winch
*/
@RestController
public class RestDemoController {
@RequestMapping(value = "/", produces = "application/json")
public Map<String, String> helloUser(Principal principal) {
HashMap<String, String> result = new HashMap<>();
result.put("username", principal.getName());
return result;
}
@RequestMapping("/logout")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void logout(HttpSession session) {
session.invalidate();
}
}

View File

@@ -1,14 +0,0 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- <logger name="org.springframework.security" level="DEBUG"/> -->
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@@ -17,6 +17,7 @@ dependencies {
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.springframework:spring-test"

View File

@@ -13,6 +13,7 @@ dependencies {
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter-api"

View File

@@ -13,7 +13,8 @@ dependencies {
implementation "ch.qos.logback:logback-classic"
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter-api"

View File

@@ -15,6 +15,7 @@ dependencies {
providedCompile "jakarta.servlet:jakarta.servlet-api"
providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl"
providedCompile "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter-api"