[KEYCLOAK-7029] - Configuration of cache policies for cached resources/path
This commit is contained in:
1 parent
28d0ab9da8
commit
a939c45d58
13 files changed
+402
-56
No files matched your search
@@ -33,18 +33,16 @@ public class AuthorizationContext {
|
||||
|
||||
private final AccessToken authzToken;
|
||||
private final PathConfig current;
|
||||
private final Map<String, PathConfig> paths;
|
||||
private boolean granted;
|
||||
|
||||
public AuthorizationContext(AccessToken authzToken, PathConfig current, Map<String, PathConfig> paths) {
|
||||
public AuthorizationContext(AccessToken authzToken, PathConfig current) {
|
||||
this.authzToken = authzToken;
|
||||
this.current = current;
|
||||
this.paths = paths;
|
||||
this.granted = true;
|
||||
}
|
||||
|
||||
public AuthorizationContext() {
|
||||
this(null, null, null);
|
||||
this(null, null);
|
||||
this.granted = false;
|
||||
}
|
||||
|
||||
|
||||
+35
@@ -38,6 +38,10 @@ public class PolicyEnforcerConfig {
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<PathConfig> paths = new ArrayList<>();
|
||||
|
||||
@JsonProperty("path-cache")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private PathCacheConfig pathCacheConfig;
|
||||
|
||||
@JsonProperty("lazy-load-paths")
|
||||
private Boolean lazyLoadPaths = Boolean.FALSE;
|
||||
|
||||
@@ -53,6 +57,10 @@ public class PolicyEnforcerConfig {
|
||||
return this.paths;
|
||||
}
|
||||
|
||||
public PathCacheConfig getPathCacheConfig() {
|
||||
return pathCacheConfig;
|
||||
}
|
||||
|
||||
public Boolean getLazyLoadPaths() {
|
||||
return lazyLoadPaths;
|
||||
}
|
||||
@@ -77,6 +85,10 @@ public class PolicyEnforcerConfig {
|
||||
this.paths = paths;
|
||||
}
|
||||
|
||||
public void setPathCacheConfig(PathCacheConfig pathCacheConfig) {
|
||||
this.pathCacheConfig = pathCacheConfig;
|
||||
}
|
||||
|
||||
public String getOnDenyRedirectTo() {
|
||||
return onDenyRedirectTo;
|
||||
}
|
||||
@@ -250,6 +262,29 @@ public class PolicyEnforcerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
public static class PathCacheConfig {
|
||||
|
||||
@JsonProperty("max-entries")
|
||||
int maxEntries = 1000;
|
||||
long lifespan = 30000;
|
||||
|
||||
public int getMaxEntries() {
|
||||
return maxEntries;
|
||||
}
|
||||
|
||||
public void setMaxEntries(int maxEntries) {
|
||||
this.maxEntries = maxEntries;
|
||||
}
|
||||
|
||||
public long getLifespan() {
|
||||
return lifespan;
|
||||
}
|
||||
|
||||
public void setLifespan(long lifespan) {
|
||||
this.lifespan = lifespan;
|
||||
}
|
||||
}
|
||||
|
||||
public enum EnforcementMode {
|
||||
PERMISSIVE,
|
||||
ENFORCING,
|
||||
|
||||
+6
@@ -99,6 +99,12 @@ public class AbstractPolicyRepresentation {
|
||||
this.policies.addAll(Arrays.asList(id));
|
||||
}
|
||||
|
||||
public void removePolicy(String policy) {
|
||||
if (policies != null) {
|
||||
policies.remove(policy);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user