Skip to content

Commit 0413a74

Browse files
committed
fixes for user #889 and #332
1 parent 70bbcf1 commit 0413a74

File tree

9 files changed

+28
-21
lines changed

9 files changed

+28
-21
lines changed

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /et
3333
curl \
3434
openjdk17-jre \
3535
su-exec \
36+
shadow \
3637
# Doc conversion
3738
libreoffice@testing \
3839
# OCR MY PDF (unpaper for descew and other advanced featues)
@@ -52,8 +53,8 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /et
5253
chmod +x /scripts/init.sh && \
5354
# User permissions
5455
addgroup -S stirlingpdfgroup && adduser -S stirlingpdfuser -G stirlingpdfgroup && \
55-
chown -R stirlingpdfuser:stirlingpdfgroup $HOME /scripts /usr/share/fonts/opentype/noto /configs /customFiles /pipeline && \
56-
chown stirlingpdfuser:stirlingpdfgroup /app.jar
56+
chown -R stirlingpdfuser:stirlingpdfgroup $HOME /scripts /usr/share/fonts/opentype/noto /configs /customFiles /pipeline && \
57+
chown stirlingpdfuser:stirlingpdfgroup /app.jar
5758

5859
EXPOSE 8080
5960

Dockerfile-lite

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /et
3131
curl \
3232
openjdk17-jre \
3333
su-exec \
34+
shadow \
3435
# Doc conversion
3536
libreoffice@testing \
3637
# python and pip

Dockerfile-ultra-lite

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ RUN mkdir /configs /logs /customFiles && \
3030
bash \
3131
curl \
3232
su-exec \
33+
shadow \
3334
openjdk17-jre && \
3435
echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories && \
3536
echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories && \

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
import com.github.jk1.license.render.*
1313

1414
group = 'stirling.software'
15-
version = '0.22.0'
15+
version = '0.22.1'
1616
sourceCompatibility = '17'
1717

1818
repositories {

exampleYmlFiles/docker-compose-latest-security.yml

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ services:
2121
environment:
2222
DOCKER_ENABLE_SECURITY: "true"
2323
SECURITY_ENABLELOGIN: "true"
24+
PUID: 1002
25+
GGID: 1002
26+
UMASK: "022"
2427
SYSTEM_DEFAULTLOCALE: en-US
2528
UI_APPNAME: Stirling-PDF
2629
UI_HOMEDESCRIPTION: Demo site for Stirling-PDF Latest with Security

scripts/init.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@ if [ -d /usr/share/tesseract-ocr/5/tessdata ]; then
1313
cp -r /usr/share/tesseract-ocr/5/tessdata/* /usr/share/tessdata || true;
1414
fi
1515

16-
1716
# Update the user and group IDs as per environment variables
1817
if [ ! -z "$PUID" ] && [ "$PUID" != "$(id -u stirlingpdfuser)" ]; then
1918
usermod -o -u "$PUID" stirlingpdfuser
2019
fi
2120

22-
if [ ! -z "$PGID" ] && [ "$PGID" != "$(id -g stirlingpdfgroup)" ]; then
21+
if [ ! -z "$PGID" ] && [ "$PGID" != "$(getent group stirlingpdfgroup | cut -d: -f3)" ]; then
2322
groupmod -o -g "$PGID" stirlingpdfgroup
2423
fi
2524
umask "$UMASK"
2625

2726
echo "Setting permissions and ownership for necessary directories..."
28-
chown -R stirlingpdfuser:stirlingpdfgroup /logs /scripts /usr/share/fonts/opentype/noto /usr/share/tessdata /configs /customFiles
29-
chmod -R 755 /logs /scripts /usr/share/fonts/opentype/noto /usr/share/tessdata /configs /customFiles
27+
chown -R stirlingpdfuser:stirlingpdfgroup $HOME /logs /scripts /usr/share/fonts/opentype/noto /usr/share/tessdata /configs /customFiles /pipeline /app.jar
28+
chmod -R 755 /logs /scripts /usr/share/fonts/opentype/noto /usr/share/tessdata /configs /customFiles /pipeline /app.jar
3029

3130

3231

src/main/java/stirling/software/SPDF/config/security/SecurityConfiguration.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
6666
sessionManagement ->
6767
sessionManagement
6868
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
69-
.maximumSessions(3)
69+
.maximumSessions(1)
7070
.maxSessionsPreventsLogin(true)
7171
.sessionRegistry(sessionRegistry())
7272
.expiredUrl("/login?logout=true"));
73+
7374
http.formLogin(
7475
formLogin ->
7576
formLogin
@@ -92,8 +93,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
9293
.addLogoutHandler(
9394
(request, response, authentication) -> {
9495
HttpSession session =
95-
request.getSession(
96-
false);
96+
request.getSession(false);
9797
if (session != null) {
9898
String sessionId = session.getId();
9999
sessionRegistry()

src/main/java/stirling/software/SPDF/controller/api/UserController.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public String register(@ModelAttribute UsernameAndPass requestModel, Model model
5656
@PostMapping("/change-username")
5757
public RedirectView changeUsername(
5858
Principal principal,
59-
@RequestParam String currentPassword,
60-
@RequestParam String newUsername,
59+
@RequestParam(name = "currentPassword") String currentPassword,
60+
@RequestParam(name = "newUsername") String newUsername,
6161
HttpServletRequest request,
6262
HttpServletResponse response,
6363
RedirectAttributes redirectAttributes) {
@@ -95,8 +95,8 @@ public RedirectView changeUsername(
9595
@PostMapping("/change-password-on-login")
9696
public RedirectView changePasswordOnLogin(
9797
Principal principal,
98-
@RequestParam String currentPassword,
99-
@RequestParam String newPassword,
98+
@RequestParam(name = "currentPassword") String currentPassword,
99+
@RequestParam(name = "newPassword") String newPassword,
100100
HttpServletRequest request,
101101
HttpServletResponse response,
102102
RedirectAttributes redirectAttributes) {
@@ -128,8 +128,8 @@ public RedirectView changePasswordOnLogin(
128128
@PostMapping("/change-password")
129129
public RedirectView changePassword(
130130
Principal principal,
131-
@RequestParam String currentPassword,
132-
@RequestParam String newPassword,
131+
@RequestParam(name = "currentPassword") String currentPassword,
132+
@RequestParam(name = "newPassword") String newPassword,
133133
HttpServletRequest request,
134134
HttpServletResponse response,
135135
RedirectAttributes redirectAttributes) {
@@ -180,9 +180,9 @@ public String updateUserSettings(HttpServletRequest request, Principal principal
180180
@PreAuthorize("hasRole('ROLE_ADMIN')")
181181
@PostMapping("/admin/saveUser")
182182
public RedirectView saveUser(
183-
@RequestParam String username,
184-
@RequestParam String password,
185-
@RequestParam String role,
183+
@RequestParam(name = "username") String username,
184+
@RequestParam(name = "password") String password,
185+
@RequestParam(name = "role") String role,
186186
@RequestParam(name = "forceChange", required = false, defaultValue = "false")
187187
boolean forceChange) {
188188

@@ -207,7 +207,8 @@ public RedirectView saveUser(
207207

208208
@PreAuthorize("hasRole('ROLE_ADMIN')")
209209
@PostMapping("/admin/deleteUser/{username}")
210-
public RedirectView deleteUser(@PathVariable String username, Authentication authentication) {
210+
public RedirectView deleteUser(
211+
@PathVariable(name = "username") String username, Authentication authentication) {
211212

212213
if (!userService.usernameExists(username)) {
213214
return new RedirectView("/addUsers?messageType=deleteUsernameExists");

test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ check_health() {
1818
fi
1919
done
2020
echo -e "\n$service_name is healthy!"
21-
21+
echo "Printing logs for $service_name:"
22+
docker logs "$service_name"
2223
return 0
2324
}
2425

0 commit comments

Comments
 (0)