Skip to content

Commit

Permalink
fix: do not depend on WebFacade to be instantiated when processing Ss…
Browse files Browse the repository at this point in the history
…oLoginToken
  • Loading branch information
jenshp committed Jul 17, 2024
1 parent e34f26a commit 884467d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public long getChildrenRunningTime() {
@Override
public ArtifactExecutionInfo getParent() { return parentAeii; }
@Override
public BigDecimal getPercentOfParentTime() { return parentAeii != null && endTimeNanos != 0 ?
public BigDecimal getPercentOfParentTime() { return parentAeii != null && endTimeNanos != 0 && parentAeii.endTimeNanos != 0 ?
new BigDecimal((getRunningTime() / parentAeii.getRunningTime()) * 100).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO; }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class UserFacadeImpl implements UserFacade {
if (ssoAuthFlowId)
ssoAuthFlowId = ssoAuthFlowId.trim()
if (!ssoAccessToken.isEmpty() && !"null".equals(ssoAccessToken) && !"undefined".equals(ssoAccessToken))
this.loginSsoToken(ssoAccessToken, ssoAuthFlowId)
this.loginSsoToken(ssoAccessToken, ssoAuthFlowId, request, response)
}
if (currentInfo.username == null && secureParameters.authUsername) {
// try the Moqui-specific parameters for instant login
Expand Down Expand Up @@ -811,13 +811,13 @@ class UserFacadeImpl implements UserFacade {
return loginKey
}

@Override boolean loginSsoToken(String ssoAccessToken, String ssoAuthFlowId) {
@Override boolean loginSsoToken(String ssoAccessToken, String ssoAuthFlowId, HttpServletRequest request, HttpServletResponse response) {
if (eci.resourceFacade.ssoTokenHandlerFactory == null) {
eci.logger.error("No SingleSignOnTokenLoginHandler ToolFactory configured, cannot handle SsoToken login")
return false
}
final SingleSignOnTokenLoginHandler ssoTokenLoginHandler = eci.resourceFacade.ssoTokenHandlerFactory.getInstance()
return ssoTokenLoginHandler.handleSsoLoginToken(eci, ssoAccessToken, ssoAuthFlowId)
return ssoTokenLoginHandler.handleSsoLoginToken(eci, request, response, ssoAccessToken, ssoAuthFlowId)
}

@Override boolean loginAnonymousIfNoUser() {
Expand Down
4 changes: 3 additions & 1 deletion framework/src/main/java/org/moqui/context/UserFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import org.moqui.entity.EntityValue;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Timestamp;
import java.util.*;

Expand Down Expand Up @@ -109,7 +111,7 @@ public interface UserFacade {
* @param ssoAccessToken the accessToken provided by the SSO server
* @param ssoAuthFlowId the (optional) authFlowId for identifying the SSO server
*/
boolean loginSsoToken(String ssoAccessToken, String ssoAuthFlowId);
boolean loginSsoToken(String ssoAccessToken, String ssoAuthFlowId, HttpServletRequest request, HttpServletResponse response);

/** If no user is logged in consider an anonymous user logged in. For internal purposes to run things that require authentication. */
boolean loginAnonymousIfNoUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import org.moqui.context.ExecutionContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public interface SingleSignOnTokenLoginHandler {
public boolean handleSsoLoginToken(ExecutionContext ec, String ssoAccessToken, String ssoAuthFlowId);
public boolean handleSsoLoginToken(ExecutionContext ec, HttpServletRequest request, HttpServletResponse response, String ssoAccessToken, String ssoAuthFlowId);
}

0 comments on commit 884467d

Please sign in to comment.