Skip to content

Recent update on struts6-upg#101

Closed
kateyang1998 wants to merge 49 commits intomaintenancefrom
struts6-upg
Closed

Recent update on struts6-upg#101
kateyang1998 wants to merge 49 commits intomaintenancefrom
struts6-upg

Conversation

@kateyang1998
Copy link
Copy Markdown

@kateyang1998 kateyang1998 commented Feb 18, 2025

What included in this PR for reviewing:

  • Removed PHR module and fixed relevant codes.
  • Cleaned up pom.xml (transitive / duplicated dependencies).
  • Updated jdocs in src/main/java/com/onelogin/saml2/customize/servlet/ServletUtils.java, src/main/java/oscar/BillingDataServlet.java, src/main/java/oscar/oscarSecurity/LoginFilter.java, src/main/webapp/casemgmt/uploadimage.jsp
  • Upgraded axis2 from version 1.8.0 to 2.0.0-SNAPSHOT.
  • Removed myoscar_client_utils library, fixed some compilation errors caused by removal.
  • Replaced org.apache.cxf.rs.security.oauth to scribejava, refactored the relevant classes to make them compatible with scribejava oauth1.0a

Summary by Sourcery

This pull request updates dependencies, removes unused modules, and refactors OAuth implementation to improve compatibility and maintainability.

Enhancements:

  • Upgrade axis2 from version 1.8.0 to 2.0.0-SNAPSHOT to be compatible with Jakarta EE.
  • Refactor OAuth-related classes to use scribejava instead of org.apache.cxf.rs.security.oauth for OAuth1.0a support.
  • Update ant dependency to version 1.10.15.
  • Update cxf dependencies to version 4.1.0.
  • Update jaxws-ri dependencies to version 4.0.3.
  • Update struts2-core, struts2-spring-plugin, and struts2-convention-plugin dependencies to version 6.7.0.

Build:

  • Clean up pom.xml by removing transitive and duplicated dependencies.

Chores:

  • Remove the PHR module and update the relevant code.
  • Remove the myoscar_client_utils library and address any compilation errors resulting from its removal.

kateyang1998 and others added 30 commits January 14, 2025 14:52
…in some dependencies, added needed jakarta libraries
- adjusted the code to use slf4j imports
… logic, and use the new CsrfGuard methods

- verifyPageToken()
- verifySessionToken()
- rotateTokens()
…uts2.ActionSupport since it's deprecated in struts 6.7.0
 - upgrade hibernate version from 5.6.15 to 6.4.10
 - update DAOs' methods using new methods in Hibernate 6
 - fix setAllowMTOM() doesn't exist error by adding config to JaxWsProxyFactoryBean
- Changed the oauth library to ScribeJava, refactored the OscarRequestTokenService and OscarRequestTokenHandler classes
- Added Auth.java and ServletUtils.java to the customize directory
- Changed javax to jakarta
- direct dependencies calls on the same transitive dependencies which causes duplicates and conflicts in versions
- removed/excluded those dependencies
Struts 6 and Jakarta Migration
 - replace jakarta.servlet.ServletContext with javax.servlet.ServletContext
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 18, 2025

Reviewer's Guide by Sourcery

This pull request includes several updates: the removal of the PHR module, dependency cleanup in pom.xml, axis2 upgrade, removal of myoscar_client_utils, replacement of org.apache.cxf.rs.security.oauth with scribejava, replacement of joda-time with java.time, replacement of javax.servlet with jakarta.servlet, and replacement of com.onelogin:java-saml with com.onelogin:java-saml:customize. The changes primarily involve dependency management, library upgrades, and code refactoring to adapt to the new libraries.

Updated class diagram for OscarOAuthDataProvider

classDiagram
  class OscarOAuthDataProvider {
    -Logger logger
    -ServiceRequestTokenDao serviceRequestTokenDao
    -ServiceAccessTokenDao serviceAccessTokenDao
    -ServiceClientDao serviceClientDao
    -OAuth1Client oauthClient
    +initializeOAuthClient(String apiKey, String apiSecret, String callbackUrl) void
    +getClient(String clientId) ServiceClient
    +createRequestToken(String clientId, String callbackUrl, List~String~ scopes) OAuth1RequestToken
    +getRequestToken(String tokenId) OAuth1RequestToken
    +finalizeAuthorization(String tokenId) String
    +createAccessToken(String tokenId, String verifier) OAuth1AccessToken
    +getAccessToken(String tokenId) OAuth1AccessToken
    +removeToken(String tokenId) void
    +sendSignedRequest(OAuth1AccessToken accessToken, String url) String
  }

  class OAuth1Client {
    +OAuth1Client(String apiKey, String apiSecret, String callbackUrl)
    +getAuthorizationUrl(OAuth1RequestToken requestToken) String
    +getAccessToken(OAuth1RequestToken requestToken, String verifier) OAuth1AccessToken
    +sendSignedRequest(OAuth1AccessToken accessToken, String url) String
  }

  OscarOAuthDataProvider -- OAuth1Client : uses

  note for OscarOAuthDataProvider "Replaced CXF OAuth with ScribeJava OAuth1.0a"
Loading

Updated class diagram for AbstractServiceImpl

classDiagram
  class AbstractServiceImpl {
    -OAuth10aService oauthService
    +setOAuthService(OAuth10aService oauthService) void
    +getHttpServletRequest() HttpServletRequest
    +getOAuthAccessToken() OAuth1AccessToken
    +getCurrentProvider() Provider
    +getLoggedInInfo() LoggedInInfo
  }

  note for AbstractServiceImpl "Replaced CXF OAuth with ScribeJava OAuth1.0a"
Loading

Updated class diagram for Stay

classDiagram
  class Stay {
    -Instant admissionInstant
    -Instant dischargeInstant
    -Duration stayDuration
    +Stay(Date admission, Date discharge, Date start, Date end)
    +getStayDuration() Duration
    +getAdmissionInstant() Instant
    +getDischargeInstant() Instant
  }

  note for Stay "Replaced Joda-Time with java.time"
Loading

Updated class diagram for AgeCalculator

classDiagram
  class AgeCalculator {
    +calculateAge(Calendar birthDate) Age
  }

  class Age {
    -int days
    -int months
    -int years
  }

  AgeCalculator -- Age : returns

  note for AgeCalculator "Replaced Joda-Time with java.time"
Loading

Updated class diagram for Prevention

classDiagram
  class Prevention {
    +isHistorical(int days) boolean
  }

  note for Prevention "Replaced Joda-Time with java.time"
Loading

Updated class diagram for PersonaService

classDiagram
  class PersonaService {
  }

  PersonaService -- AbstractServiceImpl : extends

  note for PersonaService "Removed MyOscarUtils.isMyOscarEnabled"
Loading

Updated class diagram for LoginFilter

classDiagram
  class LoginFilter {
  }

  note for LoginFilter "Replaced javax.servlet with jakarta.servlet"
Loading

Updated class diagram for Auth

classDiagram
  class Auth {
    -Instant sessionExpiration
  }

  note for Auth "Replaced Joda-Time with java.time"
Loading

Updated class diagram for SamlMessageFactory

classDiagram
  class SamlMessageFactory {
  }

  note for SamlMessageFactory "Added SamlMessageFactory interface"
Loading

File-Level Changes

Change Details Files
Removed the PHR module and its related code.
  • Removed PHR module related classes.
  • Removed PHR module related DAOs.
  • Removed PHR module related models.
  • Removed PHR module related services.
  • Removed PHR module related web actions.
  • Removed PHR module related utils.
  • Removed PHR module related taglibs.
src/main/java/oscar/login/OscarOAuthDataProvider.java
src/main/java/oscar/oscarRx/pageUtil/RxSessionBean.java
src/main/java/oscar/oscarEncounter/oscarMeasurements/pageUtil/EctSendMeasurementToPhr2Action.java
src/main/java/oscar/oscarRx/pageUtil/RxSendToPhr2Action.java
src/main/java/org/oscarehr/phr/RegistrationHelper.java
src/main/java/org/oscarehr/phr/dao/PHRActionDAO.java
src/main/java/org/oscarehr/phr/dao/PHRDocumentDAO.java
src/main/java/org/oscarehr/phr/dao/hibernate/PHRDocumentDAOHibernate.java
src/main/java/org/oscarehr/phr/indivo/IndivoUtil.java
src/main/java/org/oscarehr/phr/indivo/service/accesspolicies/IndivoAPService.java
src/main/java/org/oscarehr/phr/model/PHRAction.java
src/main/java/org/oscarehr/phr/model/PHRDocument.java
src/main/java/org/oscarehr/phr/model/PHRMeasurement.java
src/main/java/org/oscarehr/phr/model/PHRMedication.java
src/main/java/org/oscarehr/phr/model/PHRMessage.java
src/main/java/org/oscarehr/phr/model/notice.txt
src/main/java/org/oscarehr/phr/service/PHRService.java
src/main/java/org/oscarehr/phr/taglib/IfDocumentPreviouslySent.java
src/main/java/org/oscarehr/phr/util/MumpsResultWrapper.java
src/main/java/org/oscarehr/phr/util/MyOscarServerRelationManager.java
src/main/java/org/oscarehr/phr/util/MyOscarUtils.java
src/main/java/org/oscarehr/phr/util/PHRVerificationTag.java
src/main/java/org/oscarehr/phr/util/UsernameHelper.java
src/main/java/org/oscarehr/phr/web/MyOscarMessagesHelper.java
src/main/java/org/oscarehr/phr/web/PHRGenericSendToPhr2Action.java
src/main/java/org/oscarehr/phr/web/PHRLogin2Action.java
src/main/java/org/oscarehr/phr/web/PHRLogout2Action.java
src/main/java/org/oscarehr/phr/web/PHRMessage2Action.java
src/main/java/org/oscarehr/phr/web/PHRMessageAction.java
src/main/java/org/oscarehr/phr/web/PHRUserManagement2Action.java
src/main/java/org/oscarehr/phr/web/PHRViewPatientRecord2Action.java
Cleaned up pom.xml by removing transitive and duplicated dependencies.
  • Removed duplicated dependencies.
  • Removed transitive dependencies that are no longer required.
pom.xml
Upgraded axis2 from version 1.8.0 to 2.0.0-SNAPSHOT.
  • Upgraded axis2-kernel to version 2.0.0-SNAPSHOT.
  • Upgraded axis2-adb to version 2.0.0-SNAPSHOT.
  • Upgraded axis2-transport-http to version 2.0.0-SNAPSHOT.
pom.xml
Removed myoscar_client_utils library and fixed compilation errors.
  • Removed the myoscar_client_utils dependency.
  • Fixed compilation errors caused by the removal of the library.
pom.xml
src/main/java/oscar/oscarEncounter/pageUtil/EctIncomingEncounter2Action.java
src/main/java/org/oscarehr/ws/rest/PersonaService.java
Replaced org.apache.cxf.rs.security.oauth with scribejava and refactored relevant classes.
  • Replaced org.apache.cxf.rs.security.oauth dependency with scribejava-apis and scribejava-core.
  • Refactored classes to be compatible with scribejava oauth1.0a.
  • Updated OAuth-related classes to use scribejava for OAuth 1.0a implementation.
pom.xml
src/main/java/oscar/login/OscarOAuthDataProvider.java
src/main/java/org/oscarehr/ws/oauth/AbstractServiceImpl.java
src/main/java/org/oscarehr/app/OAuth1Utils.java
src/main/java/org/oscarehr/ws/rest/ProviderService.java
src/main/java/org/oscarehr/ws/oauth/util/OAuthInterceptor.java
src/main/java/org/oscarehr/ws/oauth/OAuth1Client.java
src/main/java/org/oscarehr/ws/rest/ConsentService.java
Replaced joda-time with java.time.
  • Replaced joda-time dependency with java.time.
  • Refactored classes to be compatible with java.time.
src/main/java/org/oscarehr/common/model/Stay.java
src/main/java/org/oscarehr/integration/born/BORNWbCsdXmlGenerator.java
src/main/java/org/oscarehr/integration/born/BORNWbXmlGenerator.java
src/main/java/org/oscarehr/util/AgeCalculator.java
src/main/java/org/oscarehr/common/model/Prevention.java
src/main/java/org/oscarehr/common/dao/PopulationReportDaoImpl.java
src/main/java/org/oscarehr/managers/AuditLogManager.java
Replaced javax.servlet with jakarta.servlet.
  • Replaced javax.servlet dependency with jakarta.servlet.
  • Refactored classes to be compatible with jakarta.servlet.
src/main/java/oscar/oscarSecurity/LoginFilter.java
src/main/webapp/casemgmt/uploadimage.jsp
src/main/java/oscar/BillingDataServlet.java
Replaced com.onelogin:java-saml with com.onelogin:java-saml:customize.
  • Replaced com.onelogin:java-saml dependency with com.onelogin:java-saml:customize.
  • Refactored classes to be compatible with com.onelogin:java-saml:customize.
  • Added com.onelogin.saml2.customize.authn.SamlResponse.java.
  • Added com.onelogin.saml2.customize.factory.SamlMessageFactory.java.
src/main/java/com/onelogin/saml2/customize/Auth.java
src/main/java/com/onelogin/saml2/customize/servlet/ServletUtils.java
src/main/java/com/onelogin/saml2/customize/authn/SamlResponse.java
src/main/java/com/onelogin/saml2/customize/factory/SamlMessageFactory.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@socket-security
Copy link
Copy Markdown

socket-security bot commented Feb 18, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kateyang1998 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using managed dependencies in your pom.xml to centralize dependency version management and ensure consistency across modules.
  • It looks like you're using a lot of exclusions; consider if there's a better way to manage dependencies to avoid needing so many.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.



// We need to Remove the saml:EncryptedAssertion Node
NodeList AssertionDataNodes = Util.query(dom, "/samlp:Response/saml:EncryptedAssertion/saml:Assertion");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Potential bug: wrong NodeList variable used for assertion check.

Immediately after fetching AssertionDataNodes, the code checks the length of encryptedDataNodes instead of AssertionDataNodes. This appears to be a mistake and may lead to unexpected behavior if the assertion element is missing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kateyang1998 ? Did you miss following up with sourcery on this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the original code from OneLogin source code, I didn't change anything of that instead of the namespaces from javax to jakarta to make it compatible. We can make it open to be discussed to see if it's better to take sourcery's suggestion?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the conversation, I'll provide a constructive response:

The Sourcery review highlights a potential issue in the code where the wrong NodeList is being used for assertion checking. While the code is originally from the OneLogin source, it's still worth carefully reviewing the suggestion.

Here's a detailed analysis:

  1. The current code checks the length of encryptedDataNodes after fetching AssertionDataNodes, which could indeed lead to unexpected behavior.

  2. A potential fix would be to modify the code to check the length of AssertionDataNodes instead:

NodeList encryptedDataNodes = Util.query(dom, "/samlp:Response/saml:EncryptedAssertion/xenc:EncryptedData");
NodeList AssertionDataNodes = Util.query(dom, "/samlp:Response/saml:EncryptedAssertion/saml:Assertion");

if (AssertionDataNodes.getLength() == 0) {
    throw new ValidationError("No decrypted Assertion found", ValidationError.MISSING_ASSERTION_ELEMENT);
}
  1. This change would ensure that the code checks for the presence of the decrypted Assertion element, which seems to be the intent of the original code.

I recommend discussing this suggestion with the team. Even though the code is from an existing library, it's always good to review and potentially improve error handling and validation logic.

Would you like me to elaborate on the potential implications of this code change or provide more context about the assertion decryption process?

yingbull
yingbull previously approved these changes Feb 28, 2025
Copy link
Copy Markdown

@yingbull yingbull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to let this go forward but be sure that we have followed up to removed those other MyOSCAR items you added (and any others) and make sure an issue ticket tracks this till done. Also, remember to not add commented out code unless there is a clear statement why this must be commented out and under what circumstances it would be uncommented/when.

@yingbull
Copy link
Copy Markdown

This needs to be updated / merge issue. Please review @kateyang1998

@yingbull yingbull dismissed their stale review February 28, 2025 19:42

waiting on conflict resolve

@kateyang1998
Copy link
Copy Markdown
Author

This needs to be updated / merge issue. Please review @kateyang1998

Sure, I will look into it on Monday morning.

@yingbull
Copy link
Copy Markdown

@kateyang1998 This is also out of date, can you update what should be reviewed for merge?

@kateyang1998
Copy link
Copy Markdown
Author

kateyang1998 commented Apr 24, 2025

@yingbull I just updated the PR description, right now is updated to-date. The 20 commits are the latest changes we made to this branch. (struts6-upg)

@yingbull yingbull self-requested a review April 24, 2025 15:49
@Autowired
OAuth1Client oauthClient;

protected SecurityContext getSecurityContext() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand why this is removed, @kateyang1998?

//private ServiceClientDao serviceClientDao = SpringUtils.getBean(ServiceClientDao.class);

@Override
public Client getClient(String clientId) throws OAuthServiceException {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this removal, @kateyang1998 ?

*/
public ServiceClient getClient(String clientId) {
logger.debug("getClient() called");
ServiceClient sc = serviceClientDao.findByKey(clientId);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good case for adding docs to code as we do it as it helps with review... can you justify/explain this change @kateyang1998 ?

StringBuilder sb = new StringBuilder();
List<OAuthPermission> perms = new ArrayList<>();
for (String scope : reg.getScopes()) {
OAuthPermission p = new OAuthPermission(scope, scope);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are permissions being kept in how we are doing OAuth @kateyang1998

long issuedAt = System.currentTimeMillis() / 1000;
AccessToken accessToken = new AccessToken(client, accessTokenString,
tokenSecretString, 3600, issuedAt);
UserSubject subject = new UserSubject(srt.getProviderNo(), new ArrayList<>());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we capturing this level of detail now @kateyang1998 ?

public OAuth1AccessToken getAccessToken(String tokenId) {
ServiceAccessToken sat = serviceAccessTokenDao.findByTokenId(tokenId);
if (sat == null) {
throw new OAuthServiceException("Invalid access token.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comments to above.

ResourceBundle props = ResourceBundle.getBundle("oscarResources", request.getLocale());
try {
MessageTransfer3 messageTransfer = MyOscarMessagesHelper.readMessage(request.getSession(),
MessageTransfer3 messageTransfer = readMessage(request.getSession(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? If we aren't going myoscarmsgs, maybe this whole block goes away?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because of myoscar dependency removal. After we removed the dependency, we had to do this refactor (The refactor of myoscar is not finished yet, we stopped and then switch to the 404/500 error fix in coyote)

String dateStr = "";

if (request.getParameter("remyoscarmsg") != null) {
MessageTransfer3 messageTransferOrig = MyOscarMessagesHelper.readMessage(request.getSession(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same to above


import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.fileupload2.core.FileUploadException;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was this replaced with?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the relpaced import:
import org.apache.commons.fileupload2.jakarta.servlet6.JakartaServletFileUpload;

return null;
}
bean.clearPairPHRMed();
//bean.clearPairPHRMed();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not needed, let's remove, but feels like more code might be involved?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed since it's calling the PHR method, we've already deleted PHR modules; this line of code caused an error.

@kateyang1998
Copy link
Copy Markdown
Author

@yingbull for the comments I haven't replied -
I will need to look into details, when I'm back, but these are some info from DeepSeek:
Q1: Are permissions being kept in how we are doing OAuth?
Yes, but handled differently:
Original:
Used OAuthPermission objects (Apache CXF)
Stored as space-separated strings in DB (e.g., "scope1 scope2")
Explicitly attached to tokens via setScopes()
Refactored:
Still stores scopes in ServiceRequestToken.scopes and ServiceAccessToken.scopes as space-separated strings.
But ScribeJava's OAuth1RequestToken/OAuth1AccessToken does not natively support scopes.
→ Recommendation:
If scopes are critical, add a Map<String, List> in OAuth1Client to track token-scope relationships.
Or extend OAuth1AccessToken to include a scopes field.

Q2: Where are we capturing this level of detail now?
Scopes: Still stored in DB columns (ServiceRequestToken.scopes, ServiceAccessToken.scopes).
Missing in Refactored Code:
The refactored version does not attach scopes to OAuth1AccessToken when returned (unlike the original).
Fix: Modify createAccessToken() to include scopes:
java
public OAuth1AccessToken createAccessToken(...) {
// ... existing code ...
OAuth1AccessToken accessToken = new OAuth1AccessToken(token, secret);
// Add scopes (requires custom subclass or external tracking)
return accessToken;
}

Q3: What is token lifetime in this new setup?
Original:
Explicitly set lifetime=3600 (1 hour) for AccessToken.
Validated during token usage (e.g., getAccessToken() checks expiry).
Refactored:
No explicit lifetime in OAuth1AccessToken (ScribeJava does not enforce this).
Risk: Tokens never expire unless manually revoked.
Recommendation:
Add expiryDate to ServiceAccessToken and validate in getAccessToken():
java
public OAuth1AccessToken getAccessToken(String tokenId) {
ServiceAccessToken sat = serviceAccessTokenDao.findByTokenId(tokenId);
if (sat == null || sat.getExpiryDate().before(new Date())) {
throw new RuntimeException("Invalid/expired token.");
}
return new OAuth1AccessToken(...);
}

Critical Missing Pieces in Refactored Code
Scope Handling:
Original: Attached scopes to tokens for granular permissions.
Refactored: Scopes are stored but not enforced.
Token Expiry:
Original: Hardcoded 1-hour lifetime.
Refactored: No expiry logic (security risk).
User Authorization:
Original: Used UserSubject to bind tokens to users (providerNo).
Refactored: Still stores providerNo but does not attach it to tokens.

Recommendations
Add Scope Support:
java
public class ScopedOAuth1AccessToken extends OAuth1AccessToken {
private List scopes;
// ... getters/setters ...
}
Implement Token Expiry:
Add expiryDate to ServiceAccessToken.
Validate in getAccessToken().
Reattach User Context:
Extend OAuth1AccessToken to include providerNo or use a wrapper class.
Update Database Schema:
Add expiry_date column to service_access_token table.

@kateyang1998
Copy link
Copy Markdown
Author

@yingbull I will start to look into this branch today, please let me know if there is any other issue you want me to work on first, or I will just focus on this PR now :-)

@yingbull
Copy link
Copy Markdown

yingbull commented Jun 4, 2025

No, work on open issues there are many

@kateyang1998
Copy link
Copy Markdown
Author

@yingbull Sure, will pick from the ticket board.

@yingbull
Copy link
Copy Markdown

@sebastian-j-ibanez this PR might have some of the jakarta related changes that you might be able to point claude at to summarize as part of moving them to experimental/next update.

@keploy
Copy link
Copy Markdown

keploy bot commented Jan 15, 2026

To generate Unit Tests for this PR, please click here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 15, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


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

@sebastian-j-ibanez
Copy link
Copy Markdown
Collaborator

The majority of changes in this PR have either already made their way into the code base or aren't directly useful.

However there were several classes that were migrated to Jakarta that might be useful.

Class Purpose Jakarta Library
ConsentService.java REST Service jakarta.servlet.http.HttpServletRequest
EctIncomingEncounter2Action.java Action jakarta.servlet.http.HttpSession
MyOscarLoggedInInfo.java Utility jakarta.servlet.http.HttpSession
PersonInfoDAO.java DAO jakarta.persistence.EntityManager, jakarta.persistence.PersistenceContext

@sebastian-j-ibanez sebastian-j-ibanez changed the base branch from archive/dolphin to maintenance March 6, 2026 22:51
@sebastian-j-ibanez
Copy link
Copy Markdown
Collaborator

This PR is being closed because it is stale.

A lot of the work has been in the following PRs:

PHR / MyOscar removal:

OAuth: CXF → ScribeJava migration:

Axis2 upgrade (1.8.0 → 1.8.2):

POM cleanup:

The remaining work are epics that are still in the backlog. This includes things like the jakarta migration and struts 6 upgrade.

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.

5 participants