Skip to content

Commit 005a9bc

Browse files
leventegal-sheLevente Gal
andauthored
#13140 Restore User Synchronization Button and Ensure Proper Keycloak Synchronization Configuration (#13146)
Co-authored-by: Levente Gal <levente.gal.ext@vitagroup.ag>
1 parent 50bf45e commit 005a9bc

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

docs/SERVER_SETUP.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,25 @@ In case Keycloak is set up alongside an already running instance of SORMAS, thes
190190
3. Login to SORMAS and trigger the **Sync Users** button from the **Users** page
191191
4. This will sync users to Keycloak keeping their original password - see [SORMAS Keycloak Service Provider](sormas-keycloak-service-provider/README.md) for more information about this
192192

193+
### Synchronization between SORMAS and Keycloak
194+
195+
The synchronization of users between SORMAS and Keycloak is can be done in two ways:
196+
from SORMAS to Keycloak or from Keycloak to SORMAS depending on how the `AUTH_PROVIDER_TO_SORMAS_USER_SYNC` feature is configured.
197+
198+
By default, the `AUTH_PROVIDER_TO_SORMAS_USER_SYNC` feature is disabled so the synchronization happens from SORMAS to Keycloak.
199+
An automatic synchronization happens when a user is created/changed/deleted in SORMAS,
200+
and there is another way to trigger this manually by an admin on the users page meaning the users are managed in SORMAS.
201+
202+
If the feature is enabled, the synchronization is done from Keycloak to SORMAS.
203+
In order to make this feature work you also need to configure the `authentication.provider.syncedNewUserRole`configuration property in the `sormas.properties` file
204+
to the name of the role that you want to be assigned to the new users coming from Keycloak.
205+
206+
This feature doesn't allow changing the users in SORMAS, except their roles and language, so users will be managed in keycloak.
207+
The synchronization is done automatically each day at night, or manually by an admin on the users page when needed.
208+
193209
### Keycloak configuration
194210
195-
More about the default configuration and how to customize can be found here [Keycloak](sormas-base/doc/keycloak.md)
211+
More about the default configuration and how to customize can be found here [Keycloak](../sormas-base/doc/keycloak.md)
196212
197213
## Web Server Setup
198214

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,7 @@ public interface Strings {
14921492
String messageSubcontinentsDearchived = "messageSubcontinentsDearchived";
14931493
String messageSymptomsHint = "messageSymptomsHint";
14941494
String messageSymptomsVisitHint = "messageSymptomsVisitHint";
1495+
String messageSyncUsersFromAuthProviderConfigurationError = "messageSyncUsersFromAuthProviderConfigurationError";
14951496
String messageSystemFollowUpCanceled = "messageSystemFollowUpCanceled";
14961497
String messageSystemFollowUpCanceledByDropping = "messageSystemFollowUpCanceledByDropping";
14971498
String messageTaskArchived = "messageTaskArchived";

sormas-api/src/main/resources/strings.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,8 @@ messageCustomizableEnumValueSaved = Customizable enum value saved
15211521
messageExternalEmailAttachmentPassword=Please use this password to open the documents sent to you via email from SORMAS: %s
15221522
messageExternalEmailAttachmentNotAvailableInfo=Attaching documents is disabled because encryption would not be possible. To encrypt documents, the person needs to have either a national health ID specified, or a primary mobile phone number set with SMS sending set up on this system.
15231523
messagePersonNationalHealthIdInvalid=The entered national health ID does not seem to be correct
1524+
messageSyncUsersFromAuthProviderConfigurationError=Syncing users from authentication provider is not possible because the configuration is incorrect. Please contact an admin and inform them about this issue.
1525+
15241526
# Notifications
15251527
notificationCaseClassificationChanged = The classification of case %s has changed to %s.
15261528
notificationCaseInvestigationDone = The investigation of case %s has been done.

sormas-backend/src/main/java/de/symeda/sormas/backend/user/UserFacadeEjb.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,7 @@ public void syncUsersFromAuthenticationProvider() {
10961096
UserRight._SYSTEM })
10971097
public boolean isSyncEnabled() {
10981098
AuthProvider authProvider = AuthProvider.getProvider(configFacade);
1099-
return KEYCLOAK.equalsIgnoreCase(authProvider.getName())
1100-
&& (featureConfigurationFacade.isFeatureDisabled(FeatureType.AUTH_PROVIDER_TO_SORMAS_USER_SYNC)
1101-
|| StringUtils.isNotBlank(configFacade.getAuthenticationProviderSyncedNewUserRole()));
1102-
1099+
return KEYCLOAK.equalsIgnoreCase(authProvider.getName());
11031100
}
11041101

11051102
@Override

sormas-ui/src/main/java/de/symeda/sormas/ui/user/UserController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,12 @@ public void setFlagIcons(ComboBox cbLanguage) {
347347

348348
public void sync() {
349349
if (UiUtil.permitted(FeatureType.AUTH_PROVIDER_TO_SORMAS_USER_SYNC)) {
350+
if (StringUtils.isBlank(FacadeProvider.getConfigFacade().getAuthenticationProviderSyncedNewUserRole())) {
351+
VaadinUiUtil.showSimplePopupWindow(
352+
I18nProperties.getString(Strings.headingSyncUsers),
353+
I18nProperties.getString(Strings.messageSyncUsersFromAuthProviderConfigurationError));
354+
return;
355+
}
350356
FacadeProvider.getUserFacade().syncUsersFromAuthenticationProvider();
351357
SormasUI.refreshView();
352358
} else {

0 commit comments

Comments
 (0)