use of org.apereo.cas.adaptors.duo.authn.BasicDuoSecurityAuthenticationService in project cas by apereo.
the class DuoSecurityAuthenticationEventExecutionPlanConfiguration method duoMultifactorAuthenticationProvider.
@ConditionalOnMissingBean(name = "duoMultifactorAuthenticationProvider")
@Bean
@RefreshScope
public VariegatedMultifactorAuthenticationProvider duoMultifactorAuthenticationProvider() {
final DefaultVariegatedMultifactorAuthenticationProvider provider = new DefaultVariegatedMultifactorAuthenticationProvider();
casProperties.getAuthn().getMfa().getDuo().stream().filter(duo -> StringUtils.isNotBlank(duo.getDuoApiHost()) && StringUtils.isNotBlank(duo.getDuoIntegrationKey()) && StringUtils.isNotBlank(duo.getDuoSecretKey()) && StringUtils.isNotBlank(duo.getDuoApplicationKey())).forEach(duo -> {
final BasicDuoSecurityAuthenticationService s = new BasicDuoSecurityAuthenticationService(duo, httpClient);
final DefaultDuoMultifactorAuthenticationProvider duoP = new DefaultDuoMultifactorAuthenticationProvider(duo.getRegistrationUrl(), s);
duoP.setGlobalFailureMode(casProperties.getAuthn().getMfa().getGlobalFailureMode());
duoP.setBypassEvaluator(MultifactorAuthenticationUtils.newMultifactorAuthenticationProviderBypass(duo.getBypass()));
duoP.setOrder(duo.getRank());
duoP.setId(duo.getId());
provider.addProvider(duoP);
});
if (provider.getProviders().isEmpty()) {
throw new IllegalArgumentException("At least one Duo instance must be defined");
}
return provider;
}
use of org.apereo.cas.adaptors.duo.authn.BasicDuoSecurityAuthenticationService in project cas by apereo.
the class DuoSecurityAdminApiEndpointTests method setup.
@BeforeEach
public void setup() {
ApplicationContextProvider.holdApplicationContext(applicationContext);
val props = new DuoSecurityMultifactorAuthenticationProperties().setDuoApiHost("localhost:8443").setDuoAdminIntegrationKey(UUID.randomUUID().toString()).setDuoAdminSecretKey(UUID.randomUUID().toString());
val duoService = new BasicDuoSecurityAuthenticationService(props, httpClient, List.of(), Caffeine.newBuilder().build());
val bean = mock(DuoSecurityMultifactorAuthenticationProvider.class);
when(bean.getId()).thenReturn(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER);
when(bean.getDuoAuthenticationService()).thenReturn(duoService);
when(bean.matches(eq(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER))).thenReturn(true);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, bean, "duoProvider");
}
Aggregations