From b4d6c1ea138a7c0c576ed41378c5d9441e15c4e9 Mon Sep 17 00:00:00 2001 From: Lukas Laaser Date: Fri, 23 Jan 2026 14:24:01 +0100 Subject: [PATCH] Totally unsave loggingpage --- .gitignore | 5 +- generateStuds.sh | 2 +- openapi.yaml | 1331 ++++++++++++++++- pom.xml | 4 + .../backend/logger/LogPageController.java | 20 + .../security/SecurityConfiguration.java | 1 + src/main/resources/application.properties | 2 + src/main/resources/templates/logs.html | 62 + 8 files changed, 1344 insertions(+), 83 deletions(-) create mode 100644 src/main/java/SuMoC/backend/logger/LogPageController.java create mode 100644 src/main/resources/templates/logs.html diff --git a/.gitignore b/.gitignore index d136912..2e49a38 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,7 @@ build/ ### Secrets ### src/main/resources/firebase-private-key.json src/main/resources/firebase-private-key_disable.json -/secrets/ \ No newline at end of file +/secrets/ +/data/keys/jwt-public.pem +/data/keys/jwt-private.pem +/logs/app.log diff --git a/generateStuds.sh b/generateStuds.sh index 01f650d..0c8b255 100644 --- a/generateStuds.sh +++ b/generateStuds.sh @@ -19,7 +19,7 @@ curl http://localhost:8080/v3/api-docs.yaml -o openapi.yaml # 3. Swift-Client generieren echo "Generiere Swift-Client..." -openapi-generator-cli generate -i openapi.yaml -g swift5 -o app/ios-api +openapi-generator-cli generate -i openapi.yaml -g swift5 -o app/ios-api --additional-properties=useClasses=true # 4. Kotlin-Client generieren echo "Generiere Kotlin-Client..." diff --git a/openapi.yaml b/openapi.yaml index ddcf1c3..9381955 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -36,6 +36,14 @@ paths: description: Ungültige Eingabedaten content: application/json: {} + "403": + description: Ungültige Eingabedaten + content: + application/json: {} + "409": + description: Ungültige Eingabedaten + content: + application/json: {} /user/setPrivateName/{id}: put: tags: @@ -57,7 +65,21 @@ paths: type: string responses: "200": - description: OK + description: Passwort erfolgreich geändert + content: + application/json: {} + "400": + description: Ungültige Eingabedaten + content: + application/json: {} + "403": + description: Nur autorisierte Personen dürfen das Passwort ändern + content: + application/json: {} + "404": + description: Der Nutzer existiert nicht + content: + application/json: {} /user/setPassword/{id}: put: tags: @@ -82,11 +104,21 @@ paths: "200": description: Passwort erfolgreich geändert content: - application/json: {} + application/json: + schema: + $ref: "#/components/schemas/LoginResponseDTO" "400": description: Ungültige Eingabedaten content: application/json: {} + "403": + description: Nur autorisierte Personen dürfen das Passwort ändern + content: + application/json: {} + "404": + description: Der Nutzer existiert nicht + content: + application/json: {} /user/setEmail/{id}: put: tags: @@ -111,11 +143,146 @@ paths: "200": description: E-Mail-Adresse erfolgreich geändert content: - application/json: {} + application/json: + schema: + $ref: "#/components/schemas/LoginResponseDTO" "400": description: Ungültige Eingabedaten content: application/json: {} + "403": + description: Nur autorisierte Personen dürfen die Email ändern + content: + application/json: {} + "404": + description: Der Nutzer existiert nicht + content: + application/json: {} + "409": + description: Die Email wurde bereits vergeben + content: + application/json: {} + /trip/validateTrip/{tripId}: + put: + tags: + - trip-controller + summary: Validate a trip for the authenticated user. + operationId: validateTrip + parameters: + - name: tripId + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: OK + /trip/invalidateTrip/{tripId}: + put: + tags: + - trip-controller + summary: Invalidate a trip for the authenticated user. + operationId: invalidateTrip + parameters: + - name: tripId + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: OK + /routing/preferences/update: + put: + tags: + - routing-preferences-controller + summary: Update the routing preferences of the current user + description: Updates the routing preferences for the authenticated user with + the provided settings. + operationId: updateRoutingPreferences + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RoutingPreferencesDTO" + required: true + responses: + "200": + description: OK + /notifications/register-device-token: + put: + tags: + - notification-controller + summary: Registers a device token for push notifications for the authenticated + user. + operationId: registerDeviceToken + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RegisterDeviceTokenRequest" + required: true + responses: + "200": + description: OK + /badges/modifyBadge: + put: + tags: + - badge-controller + summary: Modify a badge by ID + operationId: modifyBadgeById + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/Badge" + required: true + responses: + "200": + description: Badge modified successfully + content: + '*/*': + schema: + $ref: "#/components/schemas/Badge" + "404": + description: Badge not found + content: + '*/*': + schema: + $ref: "#/components/schemas/Badge" + "400": + description: Invalid input data + content: + '*/*': + schema: + $ref: "#/components/schemas/Badge" + /user/stats/add: + post: + tags: + - user-controller + summary: Add stats to the current user + description: Adds a value to a stat field for the current user. Optionally checks + and awards badges afterwards. + operationId: addStats + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/AddStatRequestDTO" + required: true + responses: + "200": + description: Stats updated successfully + "400": + description: Invalid stat field / invalid input + content: + application/json: {} + "403": + description: Not authorized + content: + application/json: {} /trip/uploadTrip: post: tags: @@ -134,13 +301,13 @@ paths: /routing/alternative/request: post: tags: - - routing-alternative-controller + - routing-controller operationId: requestAlternativeRoutes requestBody: content: application/json: schema: - $ref: "#/components/schemas/RouteAlternativeRequestDTO" + $ref: "#/components/schemas/RoutingAlternativeRequestDTO" required: true responses: "200": @@ -150,7 +317,7 @@ paths: schema: type: array items: - $ref: "#/components/schemas/RouteAlternativeDTO" + $ref: "#/components/schemas/RouteDTO" /friendship/unblock/{friendId}: post: tags: @@ -185,6 +352,23 @@ paths: responses: "200": description: OK + /friendship/request/by-friendcode/{friendCode}: + post: + tags: + - friendship-controller + summary: Request a friendship with another user by friend code. + description: Sends a friendship request to another user identified by their + friend code from the logged in user. + operationId: requestFriendshipByFriendcode + parameters: + - name: friendCode + in: path + required: true + schema: + type: string + responses: + "200": + description: OK /friendship/reject/{friendId}: post: tags: @@ -238,6 +422,54 @@ paths: responses: "200": description: OK + /dev/trigger-trend-calculation: + post: + tags: + - dev-controller + operationId: triggerTrendCalculation + responses: + "200": + description: OK + /badges/createBadge: + post: + tags: + - badge-controller + summary: Create a new badge + operationId: createBadge + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/Badge" + required: true + responses: + "201": + description: Badge created successfully + content: + '*/*': + schema: + $ref: "#/components/schemas/Badge" + "400": + description: Invalid input data + content: + '*/*': + schema: + $ref: "#/components/schemas/Badge" + "409": + description: Badge already exists + content: + '*/*': + schema: + $ref: "#/components/schemas/Badge" + /badges/checkBadgeAndAward: + post: + tags: + - badge-controller + summary: Check badges for current user and award newly unlocked ones + operationId: checkAndAwardBadges + responses: + "200": + description: Check successful /auth/user/registration: post: tags: @@ -257,7 +489,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/LoginResponseDTO" + $ref: "#/components/schemas/RegistrationResponseDTO" "400": description: Ungültige Eingabedaten content: @@ -300,9 +532,9 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/MinimalUserDTO" + $ref: "#/components/schemas/MaximalUserDTO" "404": - description: Nutzerprofil nicht gefunden + description: Der Nutzer existiert nicht content: application/json: {} /user/profile/{id}: @@ -327,6 +559,10 @@ paths: application/json: schema: $ref: "#/components/schemas/MinimalUserDTO" + "403": + description: Nutzerprofil darf nicht aufgerufen werden + content: + application/json: {} "404": description: Nutzerprofil nicht gefunden content: @@ -346,6 +582,114 @@ paths: type: array items: $ref: "#/components/schemas/TripDTO" + /routing/preferences/get: + get: + tags: + - routing-preferences-controller + summary: Get the routing preferences of the current user + description: Retrieves the routing preferences set by the authenticated user. + operationId: getRoutingPreferences + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: "#/components/schemas/RoutingPreferencesDTO" + /leaderboard/getLeaderboard: + get: + tags: + - leaderboard-controller + summary: Get the global score table + operationId: getLeaderboard + parameters: + - name: timeframe + in: query + required: true + schema: + type: string + enum: + - TOTAL + - MONTHLY + - WEEKLY + - name: field + in: query + required: true + schema: + type: string + responses: + "200": + description: Successfully retrieved global score table + content: + '*/*': + schema: + $ref: "#/components/schemas/Leaderboard" + "400": + description: Bad request + content: + '*/*': + schema: + $ref: "#/components/schemas/Leaderboard" + /leaderboard/getFriendLeaderboard: + get: + tags: + - leaderboard-controller + summary: Get the friend score table + operationId: getFriendLeaderboard + parameters: + - name: timeframe + in: query + required: true + schema: + type: string + enum: + - TOTAL + - MONTHLY + - WEEKLY + - name: field + in: query + required: true + schema: + type: string + responses: + "200": + description: Successfully retrieved friend score table + content: + '*/*': + schema: + $ref: "#/components/schemas/Leaderboard" + "400": + description: Bad request + content: + '*/*': + schema: + $ref: "#/components/schemas/Leaderboard" + /geocoding/reverse: + get: + tags: + - geocoding-controller + description: Returns the address at the given lat / lon. + operationId: reverse + parameters: + - name: lat + in: query + required: true + schema: + type: number + format: double + - name: lon + in: query + required: true + schema: + type: number + format: double + responses: + "200": + description: OK + content: + '*/*': + schema: + $ref: "#/components/schemas/AddressDTO" /friendship/blocked: get: tags: @@ -404,6 +748,190 @@ paths: type: array items: $ref: "#/components/schemas/FriendshipDTO" + /dev/test-notification-from-detected-regular-trip: + get: + tags: + - dev-controller + description: Testing endpoint that mocks the detection of regular trips and + then tests the alternative calculation and notification scheduling. + operationId: testNotificationFromDetectedRegularTrip + responses: + "200": + description: OK + content: + '*/*': + schema: + type: string + /dev/test-meteo: + get: + tags: + - dev-controller + operationId: testMeteoClient + responses: + "200": + description: OK + /dev/test-firebase-trend-notification/{fcm_token}: + get: + tags: + - dev-controller + description: Immediately sends a test notification of type TREND to the provided + FCM token. + operationId: SendTestTrendNotificationFirebase + parameters: + - name: fcm_token + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + '*/*': + schema: + type: string + /dev/test-firebase-regular-trip-notification/{fcm_token}: + get: + tags: + - dev-controller + description: Immediately sends a test notification of type REGULAR_TRIP_ALTERNATIVE + to the provided FCM token. + operationId: SendTestRegularTripAlternativeNotificationFirebase + parameters: + - name: fcm_token + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + '*/*': + schema: + type: string + /dev/test-firebase-adhoc-route-notification/{fcm_token}: + get: + tags: + - dev-controller + description: Immediately sends a test notification of type ADHOC_ALTERNATIVE + to the provided FCM token. + operationId: SendTestAdhocRouteNotificationFirebase + parameters: + - name: fcm_token + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + '*/*': + schema: + type: string + /dev/test-clean-old-notifications: + get: + tags: + - dev-controller + description: Tests the method cleaning old notifications from the database. + operationId: testCleanOldNotifications + responses: + "200": + description: OK + /dev/queue-test-notification: + get: + tags: + - dev-controller + description: Immediately queues a notification to the fcm key specified in application-dev.properties + to be processed by the notification queue. + operationId: queueTestNotification + responses: + "200": + description: OK + content: + '*/*': + schema: + type: string + /badges/getBadges/{userId}: + get: + tags: + - badge-controller + summary: Get Badges by user + operationId: getBadgesByUser + parameters: + - name: userId + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: Badges retrieved successfully + content: + '*/*': + schema: + type: array + items: + $ref: "#/components/schemas/UserBadgeDTO" + "404": + description: No badges found for user + content: + '*/*': + schema: + type: array + items: + $ref: "#/components/schemas/UserBadgeDTO" + /badges/getBadge/{badgeId}: + get: + tags: + - badge-controller + summary: Get a badge by ID + operationId: getBadgeById + parameters: + - name: badgeId + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: Badge retrieved successfully + content: + '*/*': + schema: + $ref: "#/components/schemas/Badge" + "404": + description: Badge not found + content: + '*/*': + schema: + $ref: "#/components/schemas/Badge" + /badges/getAllBadges: + get: + tags: + - badge-controller + summary: Get all badges + operationId: getAllBadges + responses: + "200": + description: Badges retrieved successfully + content: + '*/*': + schema: + type: array + items: + $ref: "#/components/schemas/Badge" + "404": + description: No badges found + content: + '*/*': + schema: + type: array + items: + $ref: "#/components/schemas/Badge" /user/delete/{id}: delete: tags: @@ -423,11 +951,21 @@ paths: "200": description: Nutzerprofil erfolgreich gelöscht content: - application/json: {} - "404": - description: Nutzerprofil nicht gefunden + '*/*': + schema: + type: object + "403": + description: "Keine Berechtigung, fremdes Profil zu löschen" content: - application/json: {} + '*/*': + schema: + type: object + "404": + description: Der Nutzer existiert nicht + content: + '*/*': + schema: + type: object /friendship/unfriend/{friendId}: delete: tags: @@ -446,74 +984,26 @@ paths: responses: "200": description: OK + /badges/deleteBadge/{badgeId}: + delete: + tags: + - badge-controller + summary: Delete a badge by ID + operationId: deleteBadgeById + parameters: + - name: badgeId + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + description: Badge deleted successfully + "404": + description: Badge not found components: schemas: - NewTripDTO: - type: object - description: DTO for creating a new Trip - properties: - startPlace: - type: string - endPlace: - type: string - startTime: - type: string - format: date-time - endTime: - type: string - format: date-time - mobilityScore: - type: number - format: float - tripSegments: - type: array - items: - $ref: "#/components/schemas/NewTripSegmentDTO" - maxItems: 2147483647 - minItems: 1 - uniqueItems: true - required: - - tripSegments - NewTripSegmentDTO: - type: object - properties: - modality: - type: string - enum: - - IDLE - - WALKING - - BIKE - - ESCOOTER - - BUS - - TRAM - - TRAIN - - CAR - startTime: - type: string - format: date-time - distanceMeters: - type: number - format: float - RouteAlternativeRequestDTO: - type: object - RouteAlternativeDTO: - type: object - UserRegistrationDTO: - type: object - properties: - privateName: - type: string - publicName: - type: string - email: - type: string - password: - type: string - required: - - email - - password - - privateName - - publicName LoginResponseDTO: type: object properties: @@ -542,6 +1032,322 @@ components: id: type: integer format: int64 + RoutingPreferencesDTO: + type: object + description: This DTO represents the user preferences for routing / alternative + route suggestions. + properties: + preferPhysicalActivity: + type: boolean + considerWeatherConditions: + type: boolean + modalitiesToConsider: + type: array + items: + type: string + enum: + - IDLE + - WALKING + - BICYCLE + - ESCOOTER + - BUS + - TRAM + - TRAIN + - CAR + - MOTORCYCLE + - TAXI + RegisterDeviceTokenRequest: + type: object + properties: + token: + type: string + provider: + type: string + enum: + - FIREBASE + Badge: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + description: + type: string + criteria: + type: object + additionalProperties: + type: integer + format: int32 + AddStatRequestDTO: + type: object + properties: + stat: + type: string + value: + type: integer + format: int64 + minimum: 0 + scope: + type: string + enum: + - TOTAL + - MONTHLY + - WEEKLY + - ALL + awardBadges: + type: boolean + required: + - stat + - value + NewTripDTO: + type: object + description: DTO for creating a new Trip + properties: + startPlace: + type: string + description: High level description of the trip's starting location + startLatitude: + type: number + format: double + startLongitude: + type: number + format: double + endPlace: + type: string + description: High level description of the trip's ending location + endLatitude: + type: number + format: double + endLongitude: + type: number + format: double + startTime: + type: string + format: date-time + endTime: + type: string + format: date-time + mobilityScore: + type: number + format: double + co2Emissions: + type: number + format: double + tripSegments: + type: array + items: + $ref: "#/components/schemas/NewTripSegmentDTO" + maxItems: 2147483647 + minItems: 1 + uniqueItems: true + required: + - tripSegments + NewTripSegmentDTO: + type: object + properties: + modality: + type: string + enum: + - IDLE + - WALKING + - BICYCLE + - ESCOOTER + - BUS + - TRAM + - TRAIN + - CAR + - MOTORCYCLE + - TAXI + startTime: + type: string + format: date-time + distanceMeters: + type: number + format: float + RoutingAlternativeRequestDTO: + type: object + description: This DTO represents a request for alternative routes between an + origin and a destination. + properties: + originLat: + type: number + format: double + originLon: + type: number + format: double + destinationLat: + type: number + format: double + destinationLon: + type: number + format: double + arrivalTime: + type: string + format: date-time + departureTime: + type: string + format: date-time + routingPreferencesDTO: + $ref: "#/components/schemas/RoutingPreferencesDTO" + required: + - arrivalTime + - departureTime + - destinationLat + - destinationLon + - originLat + - originLon + AddressDTO: + type: object + properties: + houseNumber: + type: string + road: + type: string + suburb: + type: string + cityDistrict: + type: string + city: + type: string + state: + type: string + iso3166_2_lvl4: + type: string + postcode: + type: string + country: + type: string + countryCode: + type: string + RouteDTO: + type: object + description: This DTO represents a suggested route as a response to a requested + alternative route. + properties: + startAddress: + $ref: "#/components/schemas/AddressDTO" + description: The actual address of the start location. + firstStopName: + type: string + description: The name of the first stop if the route uses public transport. + E.g. "Essen West" if the route starts with a footpath to the first train + leaving there. + startLat: + type: number + format: double + description: The latitude of the start address. + startLon: + type: number + format: double + description: The longitude of the start address. + endAddress: + $ref: "#/components/schemas/AddressDTO" + description: The actual address of the end location. + lastStopName: + type: string + description: The name of the last stop if the route uses public transport. + E.g. "Essen Hbf" if the route ends with a train arriving there (might + still contain a footpath afterwards). + endLat: + type: number + format: double + description: The latitude of the end address. + endLon: + type: number + format: double + description: The longitude of the end address. + startDateTime: + type: string + format: date-time + description: The start date and time of the route. + endDateTime: + type: string + format: date-time + description: The end date and time of the route. + steps: + type: array + description: The steps the route consists of. + items: + $ref: "#/components/schemas/StepDTO" + co2Savings: + type: number + format: double + description: Amount of CO2e savings in gramm compared to a car trip for + the same route. + co2Emissions: + type: number + format: double + description: CO2e emission of this route. + timeDifferenceSeconds: + type: number + format: double + description: The temporal difference in minutes compared to the original + route the user requested alternatives for. + durationSeconds: + type: integer + format: int64 + physicalActivity: + type: boolean + cyclingRoute: + type: boolean + walkingRoute: + type: boolean + StepDTO: + type: object + description: A single step within a suggested alternative route. + properties: + modality: + type: string + enum: + - IDLE + - WALKING + - BICYCLE + - ESCOOTER + - BUS + - TRAM + - TRAIN + - CAR + - MOTORCYCLE + - TAXI + lineNumber: + type: string + distanceMeters: + type: number + format: double + UserRegistrationDTO: + type: object + properties: + privateName: + type: string + publicName: + type: string + email: + type: string + password: + type: string + required: + - email + - password + - privateName + - publicName + RegistrationResponseDTO: + type: object + properties: + userDTO: + $ref: "#/components/schemas/UserDTO" + jwt: + type: string + status: + type: string + enum: + - SUCCESS + - EMAIL_EXISTS + - EMAIL_INVALID + - PUBLIC_NAME_EXISTS + - PUBLIC_NAME_FORBIDDEN + - UNKNOWN_ERROR UserAuthenticationPairDTO: type: object properties: @@ -552,6 +1358,298 @@ components: required: - email - password + Friendship: + type: object + properties: + id: + type: integer + format: int64 + user: + $ref: "#/components/schemas/User" + friend: + $ref: "#/components/schemas/User" + status: + type: string + enum: + - REQUESTED + - PENDING + - ACCEPTED + - REJECTED + - BLOCKED + createdAt: + type: string + format: date-time + MaximalUserDTO: + type: object + properties: + id: + type: integer + format: int64 + publicName: + type: string + privateName: + type: string + email: + type: string + visibilityPrivacy: + type: string + enum: + - NONE + - FRIENDS_ONLY + - PUBLIC + trips: + type: array + items: + $ref: "#/components/schemas/Trip" + uniqueItems: true + friendships: + type: array + items: + $ref: "#/components/schemas/Friendship" + uniqueItems: true + NotificationToken: + type: object + properties: + userId: + type: integer + format: int64 + provider: + type: string + enum: + - FIREBASE + token: + type: string + RoutingPreferences: + type: object + properties: + id: + type: integer + format: int64 + user: + $ref: "#/components/schemas/User" + preferPhysicalActivity: + type: boolean + considerWeatherConditions: + type: boolean + modalitiesToConsider: + type: array + items: + type: string + enum: + - IDLE + - WALKING + - BICYCLE + - ESCOOTER + - BUS + - TRAM + - TRAIN + - CAR + - MOTORCYCLE + - TAXI + Stats: + type: object + properties: + statsList: + $ref: "#/components/schemas/StatsList" + description: The StatsList to which these stats belong. + xp: + type: integer + format: int64 + co2_SAVED: + type: integer + format: int64 + km_CYCLED: + type: integer + format: int64 + km_WALKED: + type: integer + format: int64 + km_PUBLIC_TRANSPORT: + type: integer + format: int64 + km_DRIVEN: + type: integer + format: int64 + mobility_SCORE: + type: integer + format: int64 + required: + - statsList + StatsList: + type: object + properties: + id: + type: integer + format: int64 + description: Unique identifier of the StatsList. + example: 1 + user: + $ref: "#/components/schemas/User" + description: The User to whom this StatsList belongs. + totalStats: + $ref: "#/components/schemas/Stats" + description: Total stats of the user. + monthlyStats: + $ref: "#/components/schemas/Stats" + description: Monthly stats of the user. + weeklyStats: + $ref: "#/components/schemas/Stats" + description: Weekly stats of the user. + Trip: + type: object + properties: + id: + type: integer + format: int64 + user: + $ref: "#/components/schemas/User" + startPlace: + type: string + startLatitude: + type: number + format: double + startLongitude: + type: number + format: double + startH3Cell: + type: string + endPlace: + type: string + endLatitude: + type: number + format: double + endLongitude: + type: number + format: double + endH3Cell: + type: string + startTime: + type: string + format: date-time + endTime: + type: string + format: date-time + mobilityScore: + type: number + format: double + co2Emissions: + type: number + format: double + cost: + type: number + format: float + invalidated: + type: boolean + mainModality: + type: string + description: Main modality by distance. + enum: + - IDLE + - WALKING + - BICYCLE + - ESCOOTER + - BUS + - TRAM + - TRAIN + - CAR + - MOTORCYCLE + - TAXI + tripSegments: + type: array + items: + $ref: "#/components/schemas/TripSegment" + uniqueItems: true + TripSegment: + type: object + properties: + id: + type: integer + format: int64 + trip: + $ref: "#/components/schemas/Trip" + modality: + type: string + enum: + - IDLE + - WALKING + - BICYCLE + - ESCOOTER + - BUS + - TRAM + - TRAIN + - CAR + - MOTORCYCLE + - TAXI + startTime: + type: string + format: date-time + distanceMeters: + type: integer + format: int64 + User: + type: object + properties: + id: + type: integer + format: int64 + publicName: + type: string + privateName: + type: string + email: + type: string + password: + type: string + visibilityPrivacy: + type: string + enum: + - NONE + - FRIENDS_ONLY + - PUBLIC + friendCode: + type: string + trips: + type: array + items: + $ref: "#/components/schemas/Trip" + uniqueItems: true + friendships: + type: array + items: + $ref: "#/components/schemas/Friendship" + uniqueItems: true + roles: + type: array + items: + type: string + enum: + - USER + - ADMIN + uniqueItems: true + notificationToken: + $ref: "#/components/schemas/NotificationToken" + badges: + type: array + items: + $ref: "#/components/schemas/UserBadge" + uniqueItems: true + routingPreferences: + $ref: "#/components/schemas/RoutingPreferences" + stats: + $ref: "#/components/schemas/StatsList" + UserBadge: + type: object + properties: + id: + type: integer + format: int64 + user: + $ref: "#/components/schemas/User" + badge: + $ref: "#/components/schemas/Badge" + awardedAt: + type: string + format: date-time MinimalUserDTO: type: object properties: @@ -562,6 +1660,8 @@ components: type: string TripDTO: type: object + description: Represents a trip uploaded to the backend by a user that is already + stored in the DB. properties: tripId: type: integer @@ -571,8 +1671,20 @@ components: format: int32 startPlace: type: string + startLatitude: + type: number + format: double + startLongitude: + type: number + format: double endPlace: type: string + endLatitude: + type: number + format: double + endLongitude: + type: number + format: double startTime: type: string format: date-time @@ -581,11 +1693,16 @@ components: format: date-time mobilityScore: type: number - format: float + format: double + co2Emissions: + type: number + format: double tripSegments: type: array items: $ref: "#/components/schemas/TripSegmentDTO" + invalidated: + type: boolean TripSegmentDTO: type: object properties: @@ -600,18 +1717,52 @@ components: enum: - IDLE - WALKING - - BIKE + - BICYCLE - ESCOOTER - BUS - TRAM - TRAIN - CAR + - MOTORCYCLE + - TAXI startTime: type: string format: date-time distanceMeters: type: number format: float + Leaderboard: + type: object + properties: + timeframe: + type: string + enum: + - TOTAL + - MONTHLY + - WEEKLY + entries: + type: array + items: + $ref: "#/components/schemas/LeaderboardEntry" + scoreType: + type: string + enum: + - XP + - CO2 + - KM + LeaderboardEntry: + type: object + properties: + userId: + type: integer + format: int64 + username: + type: string + isFriend: + type: boolean + score: + type: integer + format: int64 FriendshipDTO: type: object properties: @@ -634,6 +1785,24 @@ components: createdAt: type: string format: date-time + UserBadgeDTO: + type: object + properties: + badgeId: + type: integer + format: int64 + name: + type: string + description: + type: string + criteria: + type: object + additionalProperties: + type: integer + format: int32 + awardedAt: + type: string + format: date-time securitySchemes: bearerAuth: type: http diff --git a/pom.xml b/pom.xml index 97d5e66..ca765aa 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,10 @@ org.springframework.boot spring-boot-starter-validation + + org.springframework.boot + spring-boot-starter-thymeleaf + com.h2database h2 diff --git a/src/main/java/SuMoC/backend/logger/LogPageController.java b/src/main/java/SuMoC/backend/logger/LogPageController.java new file mode 100644 index 0000000..5e5555c --- /dev/null +++ b/src/main/java/SuMoC/backend/logger/LogPageController.java @@ -0,0 +1,20 @@ +package SuMoC.backend.logger; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +@Controller +public class LogPageController { + + @GetMapping("/logs") + public String logs(Model model) throws IOException { + String content = Files.readString(Path.of("logs/app.log")); + model.addAttribute("logs", content); + return "logs"; + } +} \ No newline at end of file diff --git a/src/main/java/SuMoC/backend/security/SecurityConfiguration.java b/src/main/java/SuMoC/backend/security/SecurityConfiguration.java index efd98ae..717d643 100644 --- a/src/main/java/SuMoC/backend/security/SecurityConfiguration.java +++ b/src/main/java/SuMoC/backend/security/SecurityConfiguration.java @@ -91,6 +91,7 @@ public class SecurityConfiguration { auth.requestMatchers(AUTH_WHITELIST).permitAll(); auth.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll(); auth.requestMatchers("/dev/**").permitAll(); + auth.requestMatchers("/logs").permitAll(); auth.requestMatchers("/routing/alternative/**").permitAll(); auth.requestMatchers("/auth/user/**").permitAll(); auth.requestMatchers("/admin/**").hasRole("ADMIN"); //looks for "ROLE_ADMIN" //alternative: hasAuthoritiy("ADMIN") diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ede5695..bf0c224 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -35,3 +35,5 @@ sumoc.dev.fcm-key=dmydW4a_RjKCDjcBLZ9Kl8:APA91bFjBIjw8NcjeMIsNkfPuW9jhMlK3n_LHoG # RSA key paths (file paths, not directories) security.rsa.private-key-path=${RSA_PRIVATE_KEY_PATH:${user.home}/.sumoc/keys/jwt-private.pem} security.rsa.public-key-path=${RSA_PUBLIC_KEY_PATH:${user.home}/.sumoc/keys/jwt-public.pem} + +logging.file.name=logs/app.log diff --git a/src/main/resources/templates/logs.html b/src/main/resources/templates/logs.html new file mode 100644 index 0000000..0ea9ae5 --- /dev/null +++ b/src/main/resources/templates/logs.html @@ -0,0 +1,62 @@ + + + + + Server Logs + + + +
📝 Server Logs
+
+

+
+ +