Search in sources :

Example 1 with DuoSecurityAuthenticationService

use of org.apereo.cas.adaptors.duo.authn.DuoSecurityAuthenticationService in project cas by apereo.

the class DetermineDuoUserAccountAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) {
    final Authentication authentication = WebUtils.getAuthentication(requestContext);
    final Principal p = authentication.getPrincipal();
    final Collection<MultifactorAuthenticationProvider> providers = WebUtils.getResolvedMultifactorAuthenticationProviders(requestContext);
    for (final MultifactorAuthenticationProvider pr : providers) {
        final DuoMultifactorAuthenticationProvider duoProvider = this.provider.findProvider(pr.getId(), DuoMultifactorAuthenticationProvider.class);
        final DuoSecurityAuthenticationService duoAuthenticationService = duoProvider.getDuoAuthenticationService();
        final DuoUserAccount account = duoAuthenticationService.getDuoUserAccount(p.getId());
        if (account.getStatus() == DuoUserAccountAuthStatus.ENROLL && StringUtils.isNotBlank(duoProvider.getRegistrationUrl())) {
            requestContext.getFlowScope().put("duoRegistrationUrl", duoProvider.getRegistrationUrl());
            return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_ENROLL);
        }
    }
    return success();
}
Also used : DuoUserAccount(org.apereo.cas.adaptors.duo.DuoUserAccount) Authentication(org.apereo.cas.authentication.Authentication) DuoMultifactorAuthenticationProvider(org.apereo.cas.adaptors.duo.authn.DuoMultifactorAuthenticationProvider) MultifactorAuthenticationProvider(org.apereo.cas.services.MultifactorAuthenticationProvider) DuoMultifactorAuthenticationProvider(org.apereo.cas.adaptors.duo.authn.DuoMultifactorAuthenticationProvider) VariegatedMultifactorAuthenticationProvider(org.apereo.cas.services.VariegatedMultifactorAuthenticationProvider) DuoSecurityAuthenticationService(org.apereo.cas.adaptors.duo.authn.DuoSecurityAuthenticationService) Principal(org.apereo.cas.authentication.principal.Principal) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 2 with DuoSecurityAuthenticationService

use of org.apereo.cas.adaptors.duo.authn.DuoSecurityAuthenticationService in project cas by apereo.

the class PrepareDuoWebLoginFormAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) {
    final Principal p = WebUtils.getAuthentication(requestContext).getPrincipal();
    final DuoCredential c = requestContext.getFlowScope().get(CasWebflowConstants.VAR_ID_CREDENTIAL, DuoCredential.class);
    c.setUsername(p.getId());
    final Collection<MultifactorAuthenticationProvider> providers = WebUtils.getResolvedMultifactorAuthenticationProviders(requestContext);
    providers.forEach(pr -> {
        final DuoSecurityAuthenticationService duoAuthenticationService = provider.findProvider(pr.getId(), DuoMultifactorAuthenticationProvider.class).getDuoAuthenticationService();
        final MutableAttributeMap<Object> viewScope = requestContext.getViewScope();
        viewScope.put("sigRequest", duoAuthenticationService.signRequestToken(p.getId()));
        viewScope.put("apiHost", duoAuthenticationService.getApiHost());
        viewScope.put("commandName", "credential");
        viewScope.put("principal", p);
    });
    return success();
}
Also used : DuoCredential(org.apereo.cas.adaptors.duo.authn.DuoCredential) DuoMultifactorAuthenticationProvider(org.apereo.cas.adaptors.duo.authn.DuoMultifactorAuthenticationProvider) MultifactorAuthenticationProvider(org.apereo.cas.services.MultifactorAuthenticationProvider) DuoMultifactorAuthenticationProvider(org.apereo.cas.adaptors.duo.authn.DuoMultifactorAuthenticationProvider) VariegatedMultifactorAuthenticationProvider(org.apereo.cas.services.VariegatedMultifactorAuthenticationProvider) DuoSecurityAuthenticationService(org.apereo.cas.adaptors.duo.authn.DuoSecurityAuthenticationService) Principal(org.apereo.cas.authentication.principal.Principal)

Aggregations

DuoMultifactorAuthenticationProvider (org.apereo.cas.adaptors.duo.authn.DuoMultifactorAuthenticationProvider)2 DuoSecurityAuthenticationService (org.apereo.cas.adaptors.duo.authn.DuoSecurityAuthenticationService)2 Principal (org.apereo.cas.authentication.principal.Principal)2 MultifactorAuthenticationProvider (org.apereo.cas.services.MultifactorAuthenticationProvider)2 VariegatedMultifactorAuthenticationProvider (org.apereo.cas.services.VariegatedMultifactorAuthenticationProvider)2 DuoUserAccount (org.apereo.cas.adaptors.duo.DuoUserAccount)1 DuoCredential (org.apereo.cas.adaptors.duo.authn.DuoCredential)1 Authentication (org.apereo.cas.authentication.Authentication)1 EventFactorySupport (org.springframework.webflow.action.EventFactorySupport)1