parent
6cbe424916
commit
bb0eb899a7
5 changed files with 76 additions and 19 deletions
|
@ -34,7 +34,7 @@ import java.nio.file.FileAlreadyExistsException;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -49,7 +49,7 @@ public class FileMapKeycloakTransaction<V extends AbstractEntity & UpdatableEnti
|
|||
extends ConcurrentHashMapKeycloakTransaction<String, V, M> {
|
||||
|
||||
private final List<Path> pathsToDelete = new LinkedList<>();
|
||||
private Map<Path, Path> renameOnCommit = new IdentityHashMap<>();
|
||||
private final Map<Path, Path> renameOnCommit = new HashMap<>();
|
||||
|
||||
private final String txId = StringKey.INSTANCE.yieldNewUniqueKey();
|
||||
|
||||
|
|
|
@ -70,7 +70,9 @@ public class FileMapStorageProviderFactory implements AmphibianProviderFactory<M
|
|||
private static final Map<Class<?>, Function<?, String[]>> UNIQUE_HUMAN_READABLE_NAME_FIELD = Map.ofEntries(
|
||||
entry(MapClientEntity.class, ((Function<MapClientEntity, String[]>) v -> new String[] { v.getClientId() })),
|
||||
entry(MapClientScopeEntity.class, ((Function<MapClientScopeEntity, String[]>) v -> new String[] { v.getName() })),
|
||||
entry(MapGroupEntity.class, ((Function<MapGroupEntity, String[]>) v -> new String[] { v.getName()})),
|
||||
entry(MapGroupEntity.class, ((Function<MapGroupEntity, String[]>) v -> v.getParentId() == null
|
||||
? new String[] { v.getName() }
|
||||
: new String[] { v.getParentId(), v.getName() })),
|
||||
entry(MapRealmEntity.class, ((Function<MapRealmEntity, String[]>) v -> new String[] { v.getName()})),
|
||||
entry(MapRoleEntity.class, ((Function<MapRoleEntity, String[]>) (v -> v.getClientId() == null
|
||||
? new String[] { v.getName() }
|
||||
|
|
|
@ -980,6 +980,54 @@
|
|||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>map-storage-file</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!--
|
||||
The following properties needs to be synchronized across all map-storage profiles
|
||||
-->
|
||||
<keycloak.profile.feature.map_storage>enabled</keycloak.profile.feature.map_storage>
|
||||
<keycloak.realm.provider>map</keycloak.realm.provider>
|
||||
<keycloak.client.provider>map</keycloak.client.provider>
|
||||
<keycloak.clientScope.provider>map</keycloak.clientScope.provider>
|
||||
<keycloak.group.provider>map</keycloak.group.provider>
|
||||
<keycloak.role.provider>map</keycloak.role.provider>
|
||||
<keycloak.user.provider>map</keycloak.user.provider>
|
||||
<keycloak.deploymentState.provider>map</keycloak.deploymentState.provider>
|
||||
<keycloak.authSession.provider>map</keycloak.authSession.provider>
|
||||
<keycloak.userSession.provider>map</keycloak.userSession.provider>
|
||||
<keycloak.loginFailure.provider>map</keycloak.loginFailure.provider>
|
||||
<keycloak.authorization.provider>map</keycloak.authorization.provider>
|
||||
<keycloak.eventsStore.provider>map</keycloak.eventsStore.provider>
|
||||
<keycloak.singleUseObject.provider>map</keycloak.singleUseObject.provider>
|
||||
<keycloak.publicKeyStorage.provider>map</keycloak.publicKeyStorage.provider>
|
||||
<keycloak.authorizationCache.enabled>false</keycloak.authorizationCache.enabled>
|
||||
<keycloak.realmCache.enabled>false</keycloak.realmCache.enabled>
|
||||
<keycloak.userCache.enabled>false</keycloak.userCache.enabled>
|
||||
<keycloak.publicKeyCache.enabled>false</keycloak.publicKeyCache.enabled>
|
||||
<keycloak.userSessionPersister.provider></keycloak.userSessionPersister.provider>
|
||||
<keycloak.userFederatedStorage.provider></keycloak.userFederatedStorage.provider>
|
||||
<!--
|
||||
The end of the block synchronized across all map-storage profiles
|
||||
-->
|
||||
<keycloak.mapStorage.provider.default>file</keycloak.mapStorage.provider.default>
|
||||
<keycloak.singleUseObject.map.storage.provider>concurrenthashmap</keycloak.singleUseObject.map.storage.provider>
|
||||
<project.version>${project.version}</project.version>
|
||||
<auth.server.quarkus.mapStorage.profile.config>file</auth.server.quarkus.mapStorage.profile.config>
|
||||
<keycloak.globalLock.provider>none</keycloak.globalLock.provider>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>map-storage-jpa-cockroach</id>
|
||||
<properties>
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
},
|
||||
"map": {
|
||||
"storage-admin-events": {
|
||||
"provider": "${keycloak.adminEventsStore.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.adminEventsStore.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
},
|
||||
"storage-auth-events": {
|
||||
"provider": "${keycloak.authEventsStore.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.authEventsStore.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -59,7 +59,7 @@
|
|||
"provider": "${keycloak.realm.provider:jpa}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.realm.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.realm.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -68,7 +68,7 @@
|
|||
"provider": "${keycloak.user.provider:jpa}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.user.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.user.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -77,7 +77,7 @@
|
|||
"provider": "${keycloak.client.provider:jpa}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.client.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.client.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -86,7 +86,7 @@
|
|||
"provider": "${keycloak.clientScope.provider:jpa}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.clientScope.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.clientScope.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -95,7 +95,7 @@
|
|||
"provider": "${keycloak.group.provider:jpa}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.group.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.group.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -104,7 +104,7 @@
|
|||
"provider": "${keycloak.role.provider:jpa}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.role.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.role.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -113,7 +113,7 @@
|
|||
"provider": "${keycloak.authSession.provider:infinispan}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.authSession.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.authSession.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
},
|
||||
"infinispan": {
|
||||
|
@ -125,7 +125,7 @@
|
|||
"provider": "${keycloak.userSession.provider:infinispan}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.userSession.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.userSession.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -134,7 +134,7 @@
|
|||
"provider": "${keycloak.loginFailure.provider:infinispan}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.loginFailure.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.loginFailure.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -143,7 +143,7 @@
|
|||
"provider": "${keycloak.singleUseObject.provider:infinispan}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.singleUseObject.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.singleUseObject.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -152,7 +152,7 @@
|
|||
"provider": "${keycloak.publicKeyStorage.provider:infinispan}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.publicKeyStorage.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.publicKeyStorage.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -171,6 +171,9 @@
|
|||
"driver": "org.postgresql.Driver",
|
||||
"driverDialect": "org.keycloak.models.map.storage.jpa.hibernate.dialect.JsonbPostgreSQL95Dialect",
|
||||
"showSql": "${keycloak.map.storage.connectionsJpa,showSql:false}"
|
||||
},
|
||||
"file": {
|
||||
"dir": "${keycloak.map.storage.file.directory:target/file}"
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -186,7 +189,7 @@
|
|||
"provider": "${keycloak.authorization.provider:jpa}",
|
||||
"map": {
|
||||
"storage": {
|
||||
"provider": "${keycloak.authorization.map.storage.provider:concurrenthashmap}"
|
||||
"provider": "${keycloak.authorization.map.storage.provider,keycloak.mapStorage.provider.default:concurrenthashmap}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -70,6 +70,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.KeyStore;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -80,6 +81,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import javax.servlet.Filter;
|
||||
|
||||
/**
|
||||
|
@ -310,8 +312,10 @@ public class KeycloakServer {
|
|||
|
||||
if (tmpDataDir.mkdirs()) {
|
||||
tmpDataDir.deleteOnExit();
|
||||
} else {
|
||||
throw new IOException("Could not create directory " + tmpDataDir);
|
||||
} else try (Stream<Path> dir = Files.list(tmpDataDir.toPath())) {
|
||||
if (dir.findAny().isPresent()) { // Works well if directory is empty
|
||||
throw new IOException("Could not create directory " + tmpDataDir);
|
||||
}
|
||||
}
|
||||
|
||||
dataPath = tmpDataDir.getAbsolutePath();
|
||||
|
|
Loading…
Reference in a new issue