protected Pair<String, String> createAuthUrlWithState(final DuoSecurityMultifactorAuthenticationProvider provider,
                                                          final Map<String, Object> properties,
                                                          final RequestContext requestContext,
                                                          final String state) throws Exception {
        val authentication = WebUtils.getAuthentication(requestContext);
        val principal = resolvePrincipal(authentication.getPrincipal(), requestContext);
        LOGGER.debug("Principal resolved for Duo Security as [{}]", principal);
        var principalId = principal.getId();
        val principalAttribute = provider.getDuoAuthenticationService().getProperties().getPrincipalAttribute();
        if (principal.getAttributes().containsKey(principalAttribute)) {
            principalId = principal.getAttributes().get(principalAttribute).getFirst().toString();
        }

        val duoSecurityIdentifier = MultifactorAuthenticationWebflowUtils.getMultifactorAuthenticationProvider(requestContext);
        val client = getDuoSecurityClient(requestContext, provider, duoSecurityIdentifier).getInstance();
        var effectiveState = state;
        if (provider.getDuoAuthenticationService().getProperties().getSessionStorageType().isTicketRegistry()) {
            val service = WebUtils.getService(requestContext);
            val factory = (TransientSessionTicketFactory) ticketFactory.get(TransientSessionTicket.class);
            val ticket = factory.create(state, service, properties);
            ticketRegistry.addTicket(ticket);
            effectiveState = ticket.getId();
            LOGGER.debug("Stored Duo Security session via [{}]", ticket);
        }

        return Pair.of(client.createAuthUrl(principalId, effectiveState), effectiveState);
    }
This is {@link DuoSecurityUniversalPromptPrepareLoginAction}.

@author Misagh Moayyed
@since 6.3.0
support/cas-server-support-duo-core/src/main/java/org/apereo/cas/adaptors/duo/web/flow/action/DuoSecurityUniversalPromptPrepareLoginAction.java