Skip to content

Commit 24fec92

Browse files
committed
Filter available authentication providers for FICAM setting
1 parent e8b4f8d commit 24fec92

6 files changed

Lines changed: 49 additions & 9 deletions

File tree

api/src/org/labkey/api/security/AuthenticationManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,12 @@ public static void deleteConfiguration(User user, int rowId)
662662
{
663663
// Delete any logos attached to the configuration
664664
AuthenticationConfiguration<?> configuration = AuthenticationConfigurationCache.getConfiguration(AuthenticationConfiguration.class, rowId);
665+
666+
if (null == configuration)
667+
{
668+
throw new NotFoundException("Unable to delete authentication configuration");
669+
}
670+
665671
AttachmentService.get().deleteAttachments(configuration);
666672

667673
// Delete configuration
@@ -746,6 +752,7 @@ public static void setAcceptOnlyFicamProviders(User user, boolean enable)
746752
if (isAcceptOnlyFicamProviders() != enable)
747753
{
748754
saveAuthSetting(user, ACCEPT_ONLY_FICAM_PROVIDERS_KEY, enable);
755+
AuthenticationProviderCache.clear();
749756
AuthenticationConfigurationCache.clear();
750757
}
751758
}

api/src/org/labkey/api/security/AuthenticationProvider.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ interface ResetPasswordProvider extends AuthenticationProvider
234234
* @param isAdminCopy true for sending admin a copy of reset password email
235235
*/
236236
@Nullable SecurityMessage getAPIResetPasswordMessage(User user, boolean isAdminCopy);
237+
238+
@Override
239+
default boolean isFicamApproved()
240+
{
241+
return true;
242+
}
237243
}
238244

239245
interface SecondaryAuthenticationProvider<SAC extends SecondaryAuthenticationConfiguration<?>> extends ConfigurableAuthenticationProvider<SAC>
@@ -286,11 +292,23 @@ interface DisableLoginProvider extends AuthenticationProvider
286292
void addUserDelay(HttpServletRequest request, String id, int addCount);
287293

288294
void resetUserDelay(String id);
295+
296+
@Override
297+
default boolean isFicamApproved()
298+
{
299+
return true;
300+
}
289301
}
290302

291303
interface ExpireAccountProvider extends AuthenticationProvider
292304
{
293305
boolean isEnabled();
306+
307+
@Override
308+
default boolean isFicamApproved()
309+
{
310+
return true;
311+
}
294312
}
295313

296314
class AuthenticationResponse

api/src/org/labkey/api/security/AuthenticationProviderCache.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ protected Set<AuthenticationProvider> createCollection()
5656

5757
private AuthenticationProviderCollections()
5858
{
59-
for (AuthenticationProvider provider : AuthenticationManager.getAllProviders())
60-
{
61-
AuthenticationProvider.ALL_PROVIDER_INTERFACES
59+
boolean acceptOnlyFicamProviders = AuthenticationManager.isAcceptOnlyFicamProviders();
60+
61+
AuthenticationManager.getAllProviders().stream()
62+
.filter(provider -> !acceptOnlyFicamProviders || provider.isFicamApproved())
63+
.forEach(provider -> AuthenticationProvider.ALL_PROVIDER_INTERFACES
6264
.stream()
6365
.filter(providerClass -> providerClass.isInstance(provider))
64-
.forEach(providerClass -> _map.put(providerClass, provider));
65-
}
66+
.forEach(providerClass -> _map.put(providerClass, provider)));
6667
}
6768

6869
private <T extends AuthenticationProvider> Collection<T> get(Class<T> clazz)

api/src/org/labkey/api/security/SaveConfigurationAction.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,16 @@ protected AC getFromCache(int rowId)
136136
return (AC)AuthenticationConfigurationCache.getConfiguration(AuthenticationConfiguration.class, rowId);
137137
}
138138

139-
protected Map<String, Object> getConfigurationMap(int rowId)
139+
protected final Map<String, Object> getConfigurationMap(int rowId)
140140
{
141141
AC configuration = getFromCache(rowId);
142+
if (null == configuration)
143+
throw new NotFoundException("Unable to save configuration");
144+
return getConfigurationMap(configuration);
145+
}
146+
147+
protected Map<String, Object> getConfigurationMap(@NotNull AC configuration)
148+
{
142149
return AuthenticationManager.getConfigurationMap(configuration);
143150
}
144151
}

api/src/org/labkey/api/security/SsoSaveConfigurationAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ public static void logLogoAction(User user, SSOAuthenticationConfiguration<?> co
120120
}
121121

122122
@Override
123-
protected Map<String, Object> getConfigurationMap(int rowId)
123+
protected Map<String, Object> getConfigurationMap(@NotNull AC configuration)
124124
{
125-
AC configuration = getFromCache(rowId);
126125
return AuthenticationManager.getSsoConfigurationMap(configuration);
127126
}
128127

core/src/client/components/AuthRow.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,15 @@ export default class AuthRow extends PureComponent<Props, Partial<State>> {
145145
this.onToggleModal('deleteModalOpen', this.state.deleteModalOpen);
146146
toggleModalOpen(false);
147147
}}
148-
onConfirm={onDelete}
148+
onConfirm={() => {
149+
// Close the confirmation modal as soon as the user confirms, regardless of whether the
150+
// delete succeeds. On success the row unmounts anyway; on failure (e.g. the configuration
151+
// was already removed, or FICAM-only mode was enabled in another tab and the provider is no
152+
// longer available) the error is surfaced in the main window and the modal should not linger.
153+
this.onToggleModal('deleteModalOpen', this.state.deleteModalOpen);
154+
toggleModalOpen(false);
155+
onDelete?.();
156+
}}
149157
title={`Permanently delete ${authConfig.provider} configuration?`}
150158
>
151159
<div className="auth-row__delete-modal__textBox">

0 commit comments

Comments
 (0)