Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kc change #1062

Merged
merged 18 commits into from
Jun 30, 2021
Prev Previous commit
Next Next commit
minor chnage
  • Loading branch information
Nolan Tellis committed Jun 24, 2021
commit e3c74b1184191ea40f5e3890e2d41feba6c2794d
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.keycloak.adapters.RefreshableKeycloakSecurityContext;
import org.keycloak.representations.AccessToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


Expand All @@ -47,6 +48,8 @@ public class AuthDetailsFilter implements Filter {
@Autowired
ManagerService managerService;

@Value("${site.useKeycloakSso}")
private boolean useKeyCloak = true;

@Override
public void init(FilterConfig filterConfig) throws ServletException {
Expand All @@ -66,8 +69,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
boolean isExistingSession = existingSession == null ? false
: existingSession.getAttribute("USER") == null ? false : true;

if (!FilterRegexUtil.useKeyCloak() || FilterRegexUtil.isMatchingFilterRegex(requestPath)
|| isExistingSession) {
if (!useKeyCloak || FilterRegexUtil.isMatchingFilterRegex(requestPath) || isExistingSession) {
chain.doFilter(request, response);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
boolean isExistingSession = existingSession == null ? false
: existingSession.getAttribute("USER") == null ? false : true;

System.out.println("Auth-path=" + requestPath);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove this

Copy link
Contributor

Choose a reason for hiding this comment

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

Use logger rather than System.out

if (isExistingSession && requestPath.equals("/j_spring_security_logout")) {
OIDCServletHttpFacade facade = new OIDCServletHttpFacade(request, response);
KeycloakDeployment deployment = deploymentContext.resolveDeployment(facade);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ public class FilterObjectFactory implements FactoryBean<Filter>, ServletContextA
@Qualifier("springSecurityFilterChain")
Filter securityFilter;



ServletContext context;

@Override
public Filter getObject() throws Exception {


if (FilterRegexUtil.useKeyCloak()) {
KeycloakOIDCFilter kcFiler = new CustomOIDCFilter(context);
kcFiler.init(null);
return kcFiler;
if (useKeyCloak) {
KeycloakOIDCFilter kcFilter = new CustomOIDCFilter(context);
kcFilter.init(null);
return kcFilter;
}
return securityFilter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
public class FilterRegexUtil {

static Pattern p = Pattern.compile("^/(zkau|zkau/.*|.*\\.css|.*\\.js"
+ "|.*\\.svg|.*\\.png|themes/.*|favicon\\.ico" + "|css/.*)", Pattern.DOTALL);
+ "|.*\\.(svg|jpg|jpeg|png)|themes/.*|favicon\\.ico" + "|css/.*|" + ".*/js/.* |.*/fonts/.*)",
Pattern.DOTALL);

public static boolean isMatchingFilterRegex(String urlData) {
return p.matcher(urlData).matches();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

package org.apromore.portal.common;

import java.util.regex.Pattern;
import org.apromore.portal.common.notification.Notification;
import org.apromore.portal.servlet.filter.FilterRegexUtil;
import org.junit.Test;

/* Test suite for {@link Navigation}. */
Expand All @@ -37,9 +37,9 @@ public class NotificationUnitTest {

@Test
public void test1() {
Pattern p = Pattern.compile("^/(zkau|zkau/.*|.*\\.css|.*\\.js)", Pattern.DOTALL);

boolean isMathed = p.matcher("/zkau/web/_zv2018112010/js/zul.wnd.wpd").matches();
String dString = "/dashboard/fonts/icomoon.jpeg";
boolean isMathed = FilterRegexUtil.isMatchingFilterRegex(dString);
System.out.println(isMathed);
}

Expand Down
2 changes: 0 additions & 2 deletions core-assemblies/core-features/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@
<bundle>mvn:org.keycloak/keycloak-servlet-filter-adapter/12.0.4</bundle>
<bundle>mvn:org.keycloak/keycloak-core/12.0.4</bundle>
<bundle>mvn:org.keycloak/keycloak-common/12.0.4</bundle>


<bundle>mvn:org.keycloak/keycloak-adapter-spi/12.0.4</bundle>
<bundle>mvn:org.keycloak/keycloak-servlet-adapter-spi/12.0.4</bundle>
<bundle>mvn:org.keycloak/keycloak-adapter-core/12.0.4</bundle>
Expand Down