Search in sources :

Example 1 with YubiKeyMultifactorAuthenticationProvider

use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.

the class YubiKeyAuthenticationEventExecutionPlanConfiguration method yubikeyAuthenticationProvider.

@Bean
@RefreshScope
public MultifactorAuthenticationProvider yubikeyAuthenticationProvider() {
    final YubiKeyMultifactorAuthenticationProvider p = new YubiKeyMultifactorAuthenticationProvider(yubicoClient(), this.httpClient);
    p.setBypassEvaluator(yubikeyBypassEvaluator());
    p.setGlobalFailureMode(casProperties.getAuthn().getMfa().getGlobalFailureMode());
    p.setOrder(casProperties.getAuthn().getMfa().getYubikey().getRank());
    p.setId(casProperties.getAuthn().getMfa().getYubikey().getId());
    return p;
}
Also used : YubiKeyMultifactorAuthenticationProvider(org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with YubiKeyMultifactorAuthenticationProvider

use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.

the class YubiKeyAccountSaveRegistrationActionTests method setup.

@BeforeEach
public void setup() {
    val applicationContext = new StaticApplicationContext();
    applicationContext.refresh();
    ApplicationContextProvider.holdApplicationContext(applicationContext);
    TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, new YubiKeyMultifactorAuthenticationProvider());
    ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
}
Also used : lombok.val(lombok.val) YubiKeyMultifactorAuthenticationProvider(org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with YubiKeyMultifactorAuthenticationProvider

use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.

the class YubiKeyAccountSaveRegistrationActionTests method verifyActionSuccess.

@Test
public void verifyActionSuccess() throws Exception {
    val context = new MockRequestContext();
    WebUtils.putMultifactorAuthenticationProviderIdIntoFlowScope(context, new YubiKeyMultifactorAuthenticationProvider());
    val request = new MockHttpServletRequest();
    request.addParameter(YubiKeyAccountSaveRegistrationAction.PARAMETER_NAME_TOKEN, "yubikeyToken");
    request.addParameter(YubiKeyAccountSaveRegistrationAction.PARAMETER_NAME_ACCOUNT, UUID.randomUUID().toString());
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
    WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
    val action = new YubiKeyAccountSaveRegistrationAction(new OpenYubiKeyAccountRegistry(new AcceptAllYubiKeyAccountValidator()));
    assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, action.execute(context).getId());
}
Also used : lombok.val(lombok.val) OpenYubiKeyAccountRegistry(org.apereo.cas.adaptors.yubikey.registry.OpenYubiKeyAccountRegistry) YubiKeyMultifactorAuthenticationProvider(org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AcceptAllYubiKeyAccountValidator(org.apereo.cas.adaptors.yubikey.AcceptAllYubiKeyAccountValidator) Test(org.junit.jupiter.api.Test)

Example 4 with YubiKeyMultifactorAuthenticationProvider

use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.

the class YubiKeyAccountCheckRegistrationActionTests method verifyActionSuccess.

@Test
public void verifyActionSuccess() throws Exception {
    val context = new MockRequestContext();
    val request = new MockHttpServletRequest();
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
    WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
    WebUtils.putMultifactorAuthenticationProviderIdIntoFlowScope(context, new YubiKeyMultifactorAuthenticationProvider());
    val action = new YubiKeyAccountCheckRegistrationAction(new OpenYubiKeyAccountRegistry(new AcceptAllYubiKeyAccountValidator()));
    assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, action.execute(context).getId());
}
Also used : lombok.val(lombok.val) OpenYubiKeyAccountRegistry(org.apereo.cas.adaptors.yubikey.registry.OpenYubiKeyAccountRegistry) YubiKeyMultifactorAuthenticationProvider(org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AcceptAllYubiKeyAccountValidator(org.apereo.cas.adaptors.yubikey.AcceptAllYubiKeyAccountValidator) Test(org.junit.jupiter.api.Test)

Example 5 with YubiKeyMultifactorAuthenticationProvider

use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.

the class YubiKeyAccountCheckRegistrationActionTests method setup.

@BeforeEach
public void setup() {
    val applicationContext = new StaticApplicationContext();
    applicationContext.refresh();
    ApplicationContextProvider.holdApplicationContext(applicationContext);
    TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, new YubiKeyMultifactorAuthenticationProvider());
    ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
}
Also used : lombok.val(lombok.val) YubiKeyMultifactorAuthenticationProvider(org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

YubiKeyMultifactorAuthenticationProvider (org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider)9 lombok.val (lombok.val)8 Test (org.junit.jupiter.api.Test)4 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)4 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)4 MockServletContext (org.springframework.mock.web.MockServletContext)4 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)4 AcceptAllYubiKeyAccountValidator (org.apereo.cas.adaptors.yubikey.AcceptAllYubiKeyAccountValidator)3 OpenYubiKeyAccountRegistry (org.apereo.cas.adaptors.yubikey.registry.OpenYubiKeyAccountRegistry)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)3 MockRequestContext (org.springframework.webflow.test.MockRequestContext)3 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)2 Bean (org.springframework.context.annotation.Bean)2 DenyAllYubiKeyAccountValidator (org.apereo.cas.adaptors.yubikey.DenyAllYubiKeyAccountValidator)1 ClosedYubiKeyAccountRegistry (org.apereo.cas.adaptors.yubikey.registry.ClosedYubiKeyAccountRegistry)1 MessageContext (org.springframework.binding.message.MessageContext)1 MockParameterMap (org.springframework.webflow.test.MockParameterMap)1