Skip to content

Commit 8916932

Browse files
feat: modernize webstore security, checkout, and responsive UI
1 parent cc67b29 commit 8916932

114 files changed

Lines changed: 3563 additions & 2971 deletions

File tree

Some content is hidden

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

.DS_Store

-8 KB
Binary file not shown.

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.git
2+
.github
3+
.gradle
4+
build
5+
data
6+
uploads
7+
.DS_Store
8+
**/.DS_Store
9+
*.log
10+
.env

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copy to .env and replace every placeholder before running Docker Compose.
2+
MYSQL_PASSWORD=replace-with-a-long-random-database-password
3+
MYSQL_ROOT_PASSWORD=replace-with-a-different-long-random-root-password
4+
5+
# Optional host port; defaults to 8080 when omitted.
6+
WEBSTORE_PORT=8080
7+
8+
# Optional one-time administrator bootstrap.
9+
APP_ADMIN_BOOTSTRAP_ENABLED=true
10+
APP_ADMIN_EMAIL=portfolio-admin@example.com
11+
APP_ADMIN_PASSWORD=replace-with-a-strong-unique-admin-password

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test-and-build:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 20
16+
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Java 17
22+
uses: actions/setup-java@v4
23+
with:
24+
distribution: temurin
25+
java-version: '17'
26+
cache: gradle
27+
28+
- name: Run tests
29+
run: ./gradlew --no-daemon test
30+
31+
- name: Build container image
32+
run: docker build --tag webstore:ci .

.gitignore

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,24 @@ out/
3838

3939
### OS / Editor Junk ###
4040
.DS_Store
41-
<<<<<<< HEAD
42-
src/.DS_Store
43-
src/main/.DS_Store
44-
src/main/resources/.DS_Store
45-
.DS_Store
46-
.DS_Store
47-
=======
4841
Thumbs.db
4942
Desktop.ini
5043

5144
### Local App Data / Runtime Artifacts ###
5245
*.log
5346
*.tmp
5447
*.swp
48+
/data/
49+
/uploads/
5550

5651
### Local Environment / Secrets ###
5752
.env
5853
.env.*
54+
!.env.example
5955
application-local.properties
60-
application-dev.properties
6156
src/main/resources/application-local.properties
62-
src/main/resources/application-dev.properties
6357

6458
### Local Databases ###
6559
*.db
6660
*.sqlite
6761
*.sqlite3
68-
>>>>>>> bd6444a68f11d9a3db5c157692385fabb6dfccc0
69-
.DS_Store

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Changelog
2+
3+
## 2026-07-14
4+
5+
### Changed
6+
7+
- Replaced shared global cart state with one server-side cart per HTTP session.
8+
- Rebuilt checkout around authoritative persisted product/tax data, transactional stock locking, `BigDecimal` money, immutable order lines, and persisted receipts.
9+
- Consolidated customer, order, catalog, image, and administrator route/service boundaries.
10+
- Replaced entity-bound forms with validated request DTOs and canonical role handling.
11+
- Reworked the storefront, cart drawer, checkout, authentication, and product administration UI for responsive layouts, keyboard operation, visible async states, semantic markup, and accessible labels.
12+
- Replaced usernames with normalized email addresses across registration, customer login, administrator login, persistence, bootstrap configuration, and authentication.
13+
- Matched authentication action widths, widened the storefront cart control, and redesigned administrator login/product creation as centered responsive cards with deliberate upload-area padding.
14+
- Split development and production configuration; development uses local H2 while production uses environment-provided MySQL credentials.
15+
- Added Flyway schema migrations, health endpoints, a private durable MySQL Compose service, and a reproducible non-root container image.
16+
- Upgraded Spring Boot from 3.4.1 to 3.5.16 and removed the unused Lombok dependency/configuration.
17+
- Normalized Java packages, separated request DTOs from persistence models, and added GitHub Actions test/container CI.
18+
- Replaced placeholder documentation with architecture, setup, security, routes, screenshots, environment template, and MIT licensing.
19+
20+
### Fixed
21+
22+
- Removed public registration privilege injection, default administrator credentials, role rewrites, CSRF bypasses, duplicate email races, and overly broad admin authorization.
23+
- Removed browser-authoritative pricing/tax/shipping, duplicate checkout creation, cross-session cart leakage, destructive schema recreation, debug logging, and committed credentials.
24+
- Removed payment-card collection from the simulated checkout flow.
25+
- Added safe decoded-image validation, generated filenames, upload size/dimension limits, and path containment.
26+
- Removed duplicate routes, dead controllers/templates/scripts, generated repository junk, and committed merge markers.
27+
28+
### Verification
29+
30+
- Added integration coverage for registration privilege boundaries, case-insensitive duplicate emails, email-only authentication, session cart isolation, authoritative checkout totals, stock mutation, receipt persistence, and repeated empty checkout rejection.
31+
- Exercised local H2 and containerized MySQL startup, email-based customer and administrator authentication, customer checkout, administrator image/product management, responsive layouts, health checks, and persistence across an application-container restart.

Dockerfile

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
# Use an OpenJDK image
2-
FROM openjdk:17
1+
FROM eclipse-temurin:17-jdk-jammy@sha256:723151f3fc88ca2060153ee08ab8dbbea7983d6ed6f2622fe440acf178737c94 AS build
2+
WORKDIR /workspace
33

4-
# Set the working directory inside the container
5-
WORKDIR /app
4+
COPY gradlew settings.gradle build.gradle ./
5+
COPY gradle gradle
6+
RUN chmod +x gradlew
7+
8+
COPY src src
9+
RUN ./gradlew --no-daemon bootJar -x test
610

7-
# Copy only the specific JAR file
8-
COPY build/libs/webstore-0.0.1-SNAPSHOT.jar app.jar
11+
FROM eclipse-temurin:17-jre-jammy@sha256:475d8e96b4b2bfe08999e5e854755c773af1581acdf959a4545d88f0696a2339
12+
RUN groupadd --system webstore \
13+
&& useradd --system --gid webstore --home-dir /app --shell /usr/sbin/nologin webstore
914

10-
COPY src/main/resources/static/images /app/src/main/resources/static/images
15+
WORKDIR /app
16+
COPY --from=build --chown=webstore:webstore /workspace/build/libs/webstore-0.0.1-SNAPSHOT.jar app.jar
17+
RUN mkdir -p /app/uploads && chown webstore:webstore /app/uploads
1118

12-
# Expose the application port
19+
USER webstore
1320
EXPOSE 8080
1421

15-
# Run the application
16-
ENTRYPOINT ["java", "-jar", "app.jar"]
22+
HEALTHCHECK --interval=10s --timeout=3s --start-period=30s --retries=6 \
23+
CMD curl --fail --silent --show-error http://127.0.0.1:8080/actuator/health > /dev/null || exit 1
24+
25+
ENTRYPOINT ["java", "-jar", "/app/app.jar"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Thomas Roy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)