You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Made required changes in UserResource.java to create a new endpoint for salesforce login and also created a method to get user information in salesforce.
Changes Made
Created different methods for a new endpoint for salesforce login and for getting user info for salesforce.
How to Test
Try to login inside an app to test the new endpoint for salesforce login.
Now username is getting stored and displayed on salesforce SSO login.
Made required changes in UserResource.java to create a new endpoint for salesforce login and also created a method to get user information in salesforce.
Changes Made
Created different methods for a new endpoint for salesforce login and for getting user info for salesforce.
How to Test
Try to login inside an app to test the new endpoint for salesforce login.
Now username is getting stored and displayed on salesforce SSO login.
PR Type
Enhancement
Description
Add Salesforce userinfo endpoint
Support DB-driven Salesforce OAuth login
Populate Salesforce access token profile
Query credentials from SECURITY_DB
Diagram Walkthrough
flowchart LR
A["/login2/salesforce endpoint"] -- "read uuid" --> B["Query SALESFORCE_CREDENTIALS"]
B -- "clientId, secret, redirectUri" --> C["Exchange code for token"]
C -- "SalesforceTokenFiller" --> D["Add access token to session"]
E["/userinfo/salesforce endpoint"] -- "use session token" --> F["GET /userinfo from Salesforce"]
F -- "extract name" --> G["Return JSON { name }"]
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 Security concerns
Sensitive information handling: Ensure that database-stored CLIENTSECRET is handled securely. Although parameterized queries are used, verify that logging does not include secrets (current debug logs print the access token value; avoid logging tokens). Also validate and sanitize the 'uuid' and 'redirect' parameters to prevent open redirect or misuse of credentials selection.
In userinfoSalesforce, the catch block returns an error message instructing to log into a Microsoft account, which is inconsistent with the Salesforce context and likely confusing to users.
} catch (Exceptione) {
ret.put(Constants.ERROR_MESSAGE, "Log into your Microsoft account");
returnWebUtility.getResponse(ret, 200);
}
The uuid parameter from the request is used directly in DB lookups without explicit validation; ensure it is present, non-empty, and conforms to expected format before querying, and handle missing/invalid cases with clear responses.
After retrieving AccessToken for Salesforce in userinfoSalesforce, code assumes non-null; add null checks to avoid NPE if token retrieval fails or is absent.
The error message references Microsoft in the Salesforce userinfo handler, confusing users and masking true failures. Return a Salesforce-specific message and appropriate HTTP status. Also log the exception for diagnostics while not exposing details to the client.
} catch (Exception e) {
- ret.put(Constants.ERROR_MESSAGE, "Log into your Microsoft account");- return WebUtility.getResponse(ret, 200);+ classLogger.error("Failed to fetch Salesforce user info", e);+ ret.put(Constants.ERROR_MESSAGE, "Log into your Salesforce account");+ return WebUtility.getResponse(ret, 401);
}
Suggestion importance[1-10]: 8
__
Why: The catch block in the Salesforce userinfo method incorrectly tells users to log into Microsoft and always returns 200; updating the message to Salesforce and using 401 improves correctness and UX. The improved_code also adds proper logging, aligning with the method’s context.
Medium
Validate required UUID parameter
Validate uuid before using it in DB queries to prevent null or empty values causing errors or unintended behavior. Reject invalid input early with a clear response and avoid querying with a bad identifier.
Why: Validating uuid before DB use prevents null/empty inputs and avoids unclear errors; the change is accurate and localized. Impact is moderate as prepared statements mitigate injection, but early validation improves robustness and response clarity.
Medium
Security
Encode redirect URL parameters
URL-encode clientId and redirectUri to avoid malformed redirects or injection via special characters. Build the URL using encoded parameter values consistently.
Why: Encoding clientId and redirectUri in the authorization URL prevents malformed redirects due to special characters and improves security; the fix is precise and matches the existing code location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Made required changes in UserResource.java to create a new endpoint for salesforce login and also created a method to get user information in salesforce.
Changes Made
Created different methods for a new endpoint for salesforce login and for getting user info for salesforce.
How to Test