Skip to content

idek - #297

Merged
driedpampas merged 2 commits into
mainfrom
oauth-bettermap-betterui-newicons-mergelisting
Jun 4, 2026
Merged

idek#297
driedpampas merged 2 commits into
mainfrom
oauth-bettermap-betterui-newicons-mergelisting

Conversation

@Edd1e1

@Edd1e1 Edd1e1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Google OAuth login authentication option for users
  • Improvements

    • Routing API now accepts optional store location parameters for flexible requests
    • Enhanced character encoding support for international requests
    • Better error handling for oversized request payloads

@Edd1e1
Edd1e1 requested a review from a team as a code owner June 4, 2026 15:27
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces Google OAuth login with passwordless user creation, makes macro routing endpoints flexible to accept store coordinates directly, adds OSRM as a fallback routing backend, and hardens request body caching to handle oversized payloads and invalid charsets safely.

Changes

Authentication, Routing, and Infrastructure Enhancements

Layer / File(s) Summary
Google OAuth Data Model
src/main/java/com/p2ps/auth/model/Users.java, src/main/java/com/p2ps/auth/repository/UserRepository.java
Users entity adds unique googleId column and makes password nullable to support Google sign-in without stored passwords; UserRepository gains findByGoogleId query method.
Google OAuth Service and Endpoint
src/main/java/com/p2ps/auth/service/UserService.java, src/main/java/com/p2ps/auth/controller/AuthController.java
UserService adds findOrCreateGoogleUser to create or merge Google accounts and defensively handles null passwords; AuthController adds RestTemplate dependency and implements POST /api/auth/google endpoint that validates Google credentials, fetches user profile, creates/loads user, and issues JWT tokens.
Flexible Store Routing API
src/main/java/com/p2ps/controller/RoutingController.java, src/main/java/com/p2ps/service/MacroRoutingService.java, src/test/java/com/p2ps/controller/RoutingControllerTest.java
/api/routing/macro now accepts optional store coordinates (storeLat, storeLng) to override stored location; MacroRoutingService adds overload that uses provided coordinates or fetches via storeId; test cases updated to pass new optional parameters.
Multi-Backend Routing Implementation
src/main/java/com/p2ps/client/OsrmClient.java
OsrmClient conditionally routes to OpenRouteService (with API key) or open-source OSRM (fallback); refactors ORS handling into getEstimateOrs with auth headers and defensive route checking; adds getEstimateOsrm for OSRM profile mapping, polyline geometry parsing, and response validation.
Request Body Caching and Charset Handling
src/main/java/com/p2ps/telemetry/config/TelemetryRequestBodyCachingFilter.java, src/test/java/com/p2ps/telemetry/config/TelemetryRequestBodyCachingFilterTest.java
TelemetryRequestBodyCachingFilter explicitly catches PayloadTooLargeException, enforces buffered read limits during body accumulation, and safely falls back to UTF-8 when request charset is invalid; new test verifies charset fallback behavior.

Sequence Diagram

sequenceDiagram
  participant Client
  participant AuthController
  participant RestTemplate
  participant GoogleAPI as Google Userinfo API
  participant UserService
  participant Database
  Client->>AuthController: POST /api/auth/google (credential)
  AuthController->>RestTemplate: GET userinfo endpoint
  RestTemplate->>GoogleAPI: Fetch user profile
  GoogleAPI-->>RestTemplate: {email, id, names}
  RestTemplate-->>AuthController: User profile data
  AuthController->>UserService: findOrCreateGoogleUser(googleId, email, firstName, lastName)
  UserService->>Database: Query by googleId or email
  Database-->>UserService: Existing user or empty
  UserService->>Database: Save user (create or update)
  Database-->>UserService: Persisted user
  UserService-->>AuthController: User object
  AuthController->>AuthController: Generate JWT cookie
  AuthController-->>Client: Set-Cookie (JWT), optionally return token
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • P2P-Shopping/server#204: Updates to request-body caching and oversized-payload handling in TelemetryRequestBodyCachingFilter align with prior refactoring work in the same class.

Suggested reviewers

  • driedpampas
  • bmbianca
  • iuliaaa20
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'idek' is vague and non-descriptive, providing no meaningful information about the changeset's content or purpose. Replace with a clear, specific title that summarizes the main change, such as 'Add Google OAuth login and optional store coordinates for routing' or similar.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch oauth-bettermap-betterui-newicons-mergelisting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
27.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

coderabbitai[bot]

This comment was marked as spam.

@driedpampas
driedpampas merged commit 9a20bab into main Jun 4, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants