Skip to content

Commit

Permalink
Restore thread-local auth cache so that it still applies some caching…
Browse files Browse the repository at this point in the history
… (old style) when caching is disabled.
  • Loading branch information
chrisknoll committed Oct 11, 2024
1 parent 5d62dee commit ab80743
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public UserSimpleAuthorizationInfo getAuthorizationInfo(final String login) {

@CacheEvict(cacheNames = CachingSetup.AUTH_INFO_CACHE, allEntries = true)
public void clearAuthorizationInfoCache() {
authorizationInfoCache.remove();
authorizationInfoCache.set(new ConcurrentHashMap<>());
}

@Transactional
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/org/ohdsi/webapi/shiro/filters/CacheFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.ohdsi.webapi.shiro.filters;

import org.ohdsi.webapi.security.PermissionService;
import org.ohdsi.webapi.shiro.PermissionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;

@Component
public class CacheFilter implements Filter {

@Autowired
private PermissionManager permissionManager;

@Override
public void init(FilterConfig filterConfig) throws ServletException {

}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

permissionManager.clearAuthorizationInfoCache();
chain.doFilter(request, response);
}

@Override
public void destroy() {

}
}

0 comments on commit ab80743

Please sign in to comment.