use of org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties in project cas by apereo.
the class DuoSecurityPingEndpointTests method verifyOperation.
@Test
public void verifyOperation() {
ApplicationContextProvider.holdApplicationContext(applicationContext);
val duoService = mock(DuoSecurityAuthenticationService.class);
when(duoService.ping()).thenReturn(true);
val props = new DuoSecurityMultifactorAuthenticationProperties().setDuoApiHost("https://api.duosecurity.com");
when(duoService.getProperties()).thenReturn(props);
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");
val indicator = new DuoSecurityPingEndpoint(casProperties, this.applicationContext);
val result = indicator.pingDuo(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER);
assertNotNull(result);
assertTrue(result.containsKey(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER));
}
use of org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties in project cas by apereo.
the class BasicDuoSecurityAuthenticationServiceTests method verifyPing.
@Test
public void verifyPing() throws Exception {
var entity = MAPPER.writeValueAsString(Map.of("stat", "OK", "response", "pong"));
try (val webServer = new MockWebServer(9310, new ByteArrayResource(entity.getBytes(UTF_8), "Output"), OK)) {
webServer.start();
val props = new DuoSecurityMultifactorAuthenticationProperties().setDuoApiHost("http://localhost:9310");
val service = new BasicDuoSecurityAuthenticationService(props, httpClient, List.of(MultifactorAuthenticationPrincipalResolver.identical()), Caffeine.newBuilder().build());
assertTrue(service.ping());
}
}
use of org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties in project cas by apereo.
the class BasicDuoSecurityAuthenticationServiceTests method verifyAccountStatusDisabled.
@Test
public void verifyAccountStatusDisabled() throws Exception {
val props = new DuoSecurityMultifactorAuthenticationProperties();
BeanUtils.copyProperties(props, casProperties.getAuthn().getMfa().getDuo().get(0));
props.setAccountStatusEnabled(false);
val service = new BasicDuoSecurityAuthenticationService(props, httpClient, List.of(MultifactorAuthenticationPrincipalResolver.identical()), Caffeine.newBuilder().build());
assertEquals(DuoSecurityUserAccountStatus.AUTH, service.getUserAccount("casuser").getStatus());
}
use of org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties in project cas by apereo.
the class DuoSecurityMultifactorWebflowConfigurer method doInitialize.
@Override
protected void doInitialize() {
val duoConfig = casProperties.getAuthn().getMfa().getDuo();
var flowRegistryBeans = duoConfig.stream().map(duo -> {
val duoFlowRegistry = buildDuoFlowRegistry(duo);
val duoFlowRegistryInstance = ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, duoFlowRegistry, duo.getId());
return Pair.of(duo.getId(), duoFlowRegistryInstance);
}).collect(Collectors.toList());
val flowRegistries = flowRegistryBeans.stream().map(Pair::getValue).collect(Collectors.toList());
getMultifactorAuthenticationFlowDefinitionRegistries().addAll(flowRegistries);
flowRegistryBeans.forEach(duo -> registerMultifactorProviderAuthenticationWebflow(getLoginFlow(), duo.getKey(), duo.getKey()));
duoConfig.stream().filter(DuoSecurityMultifactorAuthenticationProperties::isTrustedDeviceEnabled).forEach(duo -> {
val id = duo.getId();
LOGGER.debug("Activating multifactor trusted authentication for webflow [{}]", id);
val registry = applicationContext.getBean(id, FlowDefinitionRegistry.class);
registerMultifactorTrustedAuthentication(registry);
});
}
use of org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties in project cas by apereo.
the class DefaultDuoSecurityAdminApiServiceTests method setup.
@BeforeEach
public void setup() {
ApplicationContextProvider.holdApplicationContext(applicationContext);
properties = new DuoSecurityMultifactorAuthenticationProperties().setDuoApiHost("localhost:8443").setDuoAdminIntegrationKey(UUID.randomUUID().toString()).setDuoAdminSecretKey(UUID.randomUUID().toString());
val duoService = new BasicDuoSecurityAuthenticationService(properties, 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