protected void enforceInitialMandatoryService(final RequestContext context,
                                                  final String ticketGrantingTicketId,
                                                  final Pattern initialServicePattern) {
        if (shouldSkipRequiredServiceCheck(context, initialServicePattern)) {
            return;
        }

        val servicesToMatch = collectServicesToMatch(context, ticketGrantingTicketId);
        if (!servicesToMatch.isEmpty()) {
            val matches = servicesToMatch
                .stream()
                .anyMatch(service -> RegexUtils.find(initialServicePattern, service.getId()));
            if (!matches) {
                throw new NoSuchFlowExecutionException(context.getFlowExecutionContext().getKey(), UnauthorizedServiceException.requested());
            }
        }
    }
Configure webflow for initial mandatory service.

@param context                the context
@param ticketGrantingTicketId the ticket granting ticket id
@param initialServicePattern  the initial service pattern
support/cas-server-support-actions-core/src/main/java/org/apereo/cas/web/flow/login/VerifyRequiredServiceAction.java