Skip to content

Commit 7fe4de2

Browse files
committed
feat(authorization): Trigger migration automatically
Instead of doing a synchronization of roles in Keycloak, trigger a migration to new access rights structures on startup of the core component. Signed-off-by: Oliver Heger <[email protected]>
1 parent 5ab570f commit 7fe4de2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/src/main/kotlin/plugins/Lifecycle.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,21 @@ fun Application.configureLifecycle() {
4848
thread {
4949
MDC.setContextMap(mdcContext)
5050
runBlocking(Dispatchers.IO) {
51-
syncRoles(authorizationService)
51+
migrateRoles(authorizationService)
5252
}
5353
}
5454
}
5555
}
5656

5757
/**
58-
* Trigger the synchronization of permissions and roles in Keycloak. The synchronization then runs in the background.
58+
* Perform a migration to new database-based structures for access rights if necessary. This makes sure that the
59+
* new structures are populated once when switching from access rights stored in Keycloak to the new storage in the
60+
* database. The migration then runs in the background.
5961
*/
60-
private suspend fun syncRoles(authorizationService: AuthorizationService) {
62+
private suspend fun migrateRoles(authorizationService: AuthorizationService) {
6163
withMdcContext("component" to "core") {
6264
launch {
63-
authorizationService.ensureSuperuserAndSynchronizeRolesAndPermissions()
65+
authorizationService.migrateRolesToDb()
6466
}
6567
}
6668
}

0 commit comments

Comments
 (0)