use of org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProviderBypassProperties in project cas by apereo.
the class MultifactorAuthenticationProviderBypassTests method verifyMultifactorAuthenticationBypassByHttpRequestHeader.
@Test
public void verifyMultifactorAuthenticationBypassByHttpRequestHeader() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
val request = new MockHttpServletRequest();
request.addHeader("headerbypass", "true");
val props = new MultifactorAuthenticationProviderBypassProperties();
props.setHttpRequestHeaders("headerbypass");
val principal = MultifactorAuthenticationTestUtils.getPrincipal("casuser");
val authentication = MultifactorAuthenticationTestUtils.getAuthentication(principal);
val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val bypass = new HttpRequestMultifactorAuthenticationProviderBypassEvaluator(props, provider.getId());
val service = MultifactorAuthenticationTestUtils.getRegisteredService();
assertFalse(bypass.shouldMultifactorAuthenticationProviderExecute(authentication, service, provider, request));
}
use of org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProviderBypassProperties in project cas by apereo.
the class MultifactorAuthenticationProviderBypassTests method verifyMultifactorAuthenticationBypassByHttpRequestRemoteAddress.
@Test
public void verifyMultifactorAuthenticationBypassByHttpRequestRemoteAddress() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
val request = new MockHttpServletRequest();
request.setRemoteAddr("123.456.789.000");
val props = new MultifactorAuthenticationProviderBypassProperties();
props.setHttpRequestRemoteAddress("123.+");
val principal = MultifactorAuthenticationTestUtils.getPrincipal("casuser");
val authentication = MultifactorAuthenticationTestUtils.getAuthentication(principal);
val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val bypass = new HttpRequestMultifactorAuthenticationProviderBypassEvaluator(props, provider.getId());
val service = MultifactorAuthenticationTestUtils.getRegisteredService();
assertFalse(bypass.shouldMultifactorAuthenticationProviderExecute(authentication, service, provider, request));
}
use of org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProviderBypassProperties in project cas by apereo.
the class MultifactorAuthenticationProviderBypassTests method verifyMultifactorAuthenticationBypassByAuthenticationHandler.
@Test
public void verifyMultifactorAuthenticationBypassByAuthenticationHandler() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
val request = new MockHttpServletRequest();
val props = new MultifactorAuthenticationProviderBypassProperties();
props.setAuthenticationHandlerName("SimpleAuthenticationHandler");
val principal = MultifactorAuthenticationTestUtils.getPrincipal("casuser", CollectionUtils.wrap("givenName", "CAS"));
val authentication = MultifactorAuthenticationTestUtils.getAuthentication(principal, CollectionUtils.wrap(AuthenticationHandler.SUCCESSFUL_AUTHENTICATION_HANDLERS, "SimpleAuthenticationHandler"));
val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val bypass = new AuthenticationMultifactorAuthenticationProviderBypassEvaluator(props, provider.getId());
val service = MultifactorAuthenticationTestUtils.getRegisteredService();
assertFalse(bypass.shouldMultifactorAuthenticationProviderExecute(authentication, service, provider, request));
}
use of org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProviderBypassProperties in project cas by apereo.
the class MultifactorAuthenticationProviderBypassTests method verifyMultifactorAuthenticationBypassByHttpRequestRemoteHost.
@Test
public void verifyMultifactorAuthenticationBypassByHttpRequestRemoteHost() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
val request = new MockHttpServletRequest();
request.setRemoteHost("somewhere.example.org");
val props = new MultifactorAuthenticationProviderBypassProperties();
props.setHttpRequestRemoteAddress(".+example\\.org");
val principal = MultifactorAuthenticationTestUtils.getPrincipal("casuser");
val authentication = MultifactorAuthenticationTestUtils.getAuthentication(principal);
val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val bypass = new HttpRequestMultifactorAuthenticationProviderBypassEvaluator(props, provider.getId());
val service = MultifactorAuthenticationTestUtils.getRegisteredService();
assertFalse(bypass.shouldMultifactorAuthenticationProviderExecute(authentication, service, provider, request));
}
use of org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProviderBypassProperties in project cas by apereo.
the class MultifactorAuthenticationProviderBypassTests method verifyMultifactorAuthenticationBypassByPrincipalAttributes.
@Test
public void verifyMultifactorAuthenticationBypassByPrincipalAttributes() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
val request = new MockHttpServletRequest();
val props = new MultifactorAuthenticationProviderBypassProperties();
props.setPrincipalAttributeName("givenName");
props.setPrincipalAttributeValue("CAS");
val principal = MultifactorAuthenticationTestUtils.getPrincipal("casuser", CollectionUtils.wrap("givenName", "CAS"));
val authentication = MultifactorAuthenticationTestUtils.getAuthentication(principal, CollectionUtils.wrap("authnFlag", "bypass"));
val provider = TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val bypass = new PrincipalMultifactorAuthenticationProviderBypassEvaluator(props, provider.getId());
val service = MultifactorAuthenticationTestUtils.getRegisteredService();
assertFalse(bypass.shouldMultifactorAuthenticationProviderExecute(authentication, service, provider, request));
}
Aggregations