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

68 disable acl caching #69

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.imi.mopat.config;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import de.imi.mopat.helper.controller.NoOpAclCache;
import de.imi.mopat.auth.CustomAuthenticationFailureHandler;
import de.imi.mopat.auth.CustomPostAuthenticationChecks;
import de.imi.mopat.auth.CustomPreAuthenticationChecks;
Expand All @@ -23,7 +24,6 @@
import org.springframework.security.acls.domain.AclAuthorizationStrategyImpl;
import org.springframework.security.acls.domain.ConsoleAuditLogger;
import org.springframework.security.acls.domain.DefaultPermissionGrantingStrategy;
import org.springframework.security.acls.domain.SpringCacheBasedAclCache;
import org.springframework.security.acls.jdbc.BasicLookupStrategy;
import org.springframework.security.acls.jdbc.JdbcMutableAclService;
import org.springframework.security.acls.model.AclCache;
Expand Down Expand Up @@ -146,8 +146,7 @@ public DefaultPermissionGrantingStrategy permissionGrantingStrategy() {
*/
@Bean
public AclCache aclCache() {
return new SpringCacheBasedAclCache(cacheManager.getCache("aclCache"),
permissionGrantingStrategy(), aclAuthorizationStrategy());
return new NoOpAclCache("aclCache");
}

/**
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/de/imi/mopat/controller/AdminController.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package de.imi.mopat.controller;

import de.imi.mopat.dao.ConfigurationDao;
import de.imi.mopat.helper.controller.CacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

/**
* AdminController controller.
Expand All @@ -21,8 +19,6 @@ public class AdminController {
@Autowired
private ConfigurationDao configurationDao;

@Autowired
private CacheService cacheService;

/**
* @param model The model, which holds the information for the view.
Expand All @@ -34,14 +30,6 @@ public class AdminController {
public String showAdmin(final Model model) {
//Get the default language of the application from the configuration
model.addAttribute("defaultLanguage", configurationDao.getDefaultLocale());
model.addAttribute("cacheTimestamp", cacheService.getTimeStamp());
return "admin/index";
}

@PostMapping(value = "/admin/clearCache")
@PreAuthorize("hasRole('ROLE_ADMIN')")
public String clearCache() {
cacheService.evictAllCaches();
return "redirect:/admin/index";
}
}
5 changes: 0 additions & 5 deletions src/main/java/de/imi/mopat/controller/ClinicController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import de.imi.mopat.dao.user.AclEntryDao;
import de.imi.mopat.dao.user.AclObjectIdentityDao;
import de.imi.mopat.dao.user.UserDao;
import de.imi.mopat.helper.controller.CacheService;
import de.imi.mopat.helper.controller.BundleService;
import de.imi.mopat.helper.controller.ClinicService;
import de.imi.mopat.model.Bundle;
Expand Down Expand Up @@ -61,8 +60,6 @@ public class ClinicController {
@Autowired
private ClinicDTOValidator clinicDTOValidator;
@Autowired
private CacheService cacheService;
@Autowired
private BundleDao bundleDao;
@Autowired
private BundleDao bundleClinicDao;
Expand Down Expand Up @@ -415,8 +412,6 @@ public String editClinic(@RequestParam final String action,
bundleDao.merge(deletedBundle);
}
clinicDao.updateUserRights(clinic, deletedBundles, clinicDTO.getAssignedUserDTOs());
//Evict the current ACL Cache to make changes available
cacheService.evictAllCaches();

return "redirect:/clinic/list";
}
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/de/imi/mopat/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import de.imi.mopat.dao.user.InvitationDao;
import de.imi.mopat.dao.user.UserDao;
import de.imi.mopat.helper.controller.ApplicationMailer;
import de.imi.mopat.helper.controller.CacheService;
import de.imi.mopat.helper.controller.Constants;
import de.imi.mopat.model.user.AclEntry;
import de.imi.mopat.model.user.Authority;
Expand Down Expand Up @@ -83,9 +82,6 @@ public class UserController {
private ApplicationMailer applicationMailer;
@Autowired
private ConfigurationDao configurationDao;

@Autowired
private CacheService cacheService;
@Autowired
private MoPatActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider;

Expand Down Expand Up @@ -477,8 +473,6 @@ public String register(@RequestParam(value = "hash", required = false) final Str
Collection<Clinic> assignedClinics = clinicDao.getClinicsFromAclObjectIdentitys(
currentInvitation.getAssignedClinics());
model.addAttribute("clinics", assignedClinics);
//Reset caches so users can directly access assigned questionnaires
cacheService.evictAllCaches();
return "mobile/user/register";
}

Expand Down Expand Up @@ -617,8 +611,6 @@ public String editClinicRights(
}
}
}
//Delete ACL caches to make changes directly visible
cacheService.evictAllCaches();
return "redirect:/user/list";
}

Expand Down
53 changes: 0 additions & 53 deletions src/main/java/de/imi/mopat/helper/controller/CacheService.java

This file was deleted.

49 changes: 49 additions & 0 deletions src/main/java/de/imi/mopat/helper/controller/NoOpAclCache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package de.imi.mopat.helper.controller;

import java.io.Serializable;
import org.springframework.cache.support.NoOpCache;
import org.springframework.security.acls.model.AclCache;
import org.springframework.security.acls.model.MutableAcl;
import org.springframework.security.acls.model.ObjectIdentity;

/**
* Just a simple implementation of the AclCache interface
* that does nothing. Thus disabling the caching mechanism
* of Springs ACL mechanism.
*/
public class NoOpAclCache extends NoOpCache implements AclCache {

public NoOpAclCache(String name) {
super(name);
}

@Override
public void evictFromCache(Serializable pk) {

}

@Override
public void evictFromCache(ObjectIdentity objectIdentity) {

}

@Override
public MutableAcl getFromCache(ObjectIdentity objectIdentity) {
return null;
}

@Override
public MutableAcl getFromCache(Serializable pk) {
return null;
}

@Override
public void putInCache(MutableAcl acl) {

}

@Override
public void clearCache() {

}
}
19 changes: 0 additions & 19 deletions src/main/webapp/WEB-INF/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,6 @@
</div>
<div class="modal-body">
<table>
<tr>
<td class="w-25">
[[${messages.get(#locale, 'admin.information.cache',
'Timestamp of last cache reset')}]]:
</td>
<td class="w-25">[[${cacheTimestamp}]]</td>
<td class="w-25">
<form
method="POST"
action="clearCache"
>
<button
class="btn btn-primary"
type="submit"
th:text="${messages.get(#locale, 'admin.information.cache.action', 'Clear cache')}"
></button>
</form>
</td>
</tr>
</table>
</div>
</div>
Expand Down