@Operation(summary = "Create bypass codes using Duo Admin API", parameters = {
        @Parameter(name = "username", required = true, in = ParameterIn.QUERY, description = "The username to create bypass codes for"),
        @Parameter(name = "providerId", description = "The multifactor authentication provider id defined in CAS settings"),
        @Parameter(name = "userId", description = "The user identifier, supplied by Duo Security to create bypass codes for")
    })
    @PostMapping(path = "/bypassCodes",
        consumes = MediaType.APPLICATION_JSON_VALUE,
        produces = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, List<Long>> createBypassCodes(@RequestParam(value = "username", required = false) final String username,
                                                     @RequestParam(value = "providerId", required = false) final String providerId,
                                                     @RequestParam(value = "userId", required = false) final String userId) {
        val results = new LinkedHashMap<String, List<Long>>();
        val providers = applicationContext.getBeansOfType(DuoSecurityMultifactorAuthenticationProvider.class).values();
        providers
            .stream()
            .filter(Objects::nonNull)
            .filter(BeanSupplier::isNotProxy)
            .filter(provider -> StringUtils.isBlank(providerId) || provider.matches(providerId))
            .filter(provider -> provider.getDuoAuthenticationService().getAdminApiService().isPresent())
            .forEach(Unchecked.consumer(provider -> {
                val duoService = provider.getDuoAuthenticationService().getAdminApiService().orElseThrow();
                val uid = StringUtils.isBlank(userId)
                    ? duoService.getDuoSecurityUserAccount(username).map(DuoSecurityUserAccount::getUserId).orElse(StringUtils.EMPTY)
                    : userId;
                if (StringUtils.isNotBlank(uid)) {
                    val codes = duoService.createDuoSecurityBypassCodesFor(uid);
                    results.put(provider.getId(), codes);
                }
            }));
        return results;
    }
Create bypass codes.

@param username   the username
@param providerId the provider id
@param userId     the user id
@return the map
support/cas-server-support-duo-core/src/main/java/org/apereo/cas/adaptors/duo/web/DuoSecurityAdminApiEndpoint.java