use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class U2FRegisteredDevicesEndpoint method delete.
/**
* Delete.
*
* @param username the username
*/
@DeleteOperation
@Operation(summary = "Delete all registered devices", parameters = { @Parameter(name = "username", required = true) })
public void delete(@Selector final String username) {
val registeredDevices = new ArrayList<>(u2fDeviceRepository.getObject().getRegisteredDevices(username));
registeredDevices.forEach(u2fDeviceRepository.getObject()::deleteRegisteredDevice);
}
use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class WebAuthnRegisteredDevicesEndpoint method delete.
/**
* Delete.
*
* @param username the username
* @param credentialId the credential id
* @throws Exception the exception
*/
@Operation(summary = "Remove device registration for username and credential id", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "credentialId", required = true) })
@DeleteMapping(path = "{username}/{credentialId}", produces = MediaType.APPLICATION_JSON_VALUE)
public void delete(@PathVariable final String username, @PathVariable final String credentialId) throws Exception {
val ba = ByteArray.fromBase64Url(credentialId);
registrationStorage.getObject().getRegistrationByUsernameAndCredentialId(username, ba).ifPresent(registration -> registrationStorage.getObject().removeRegistrationByUsername(username, registration));
}
use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class WebAuthnRegisteredDevicesEndpoint method write.
/**
* Write.
*
* @param username the username
* @param record the record
* @return the boolean
* @throws Exception the exception
*/
@PostMapping(path = "{username}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Add device registration for username", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "record", required = true) })
public boolean write(@PathVariable final String username, @RequestParam final String record) throws Exception {
val json = EncodingUtils.decodeBase64ToString(record);
val registration = WebAuthnUtils.getObjectMapper().readValue(json, CredentialRegistration.class);
return registrationStorage.getObject().addRegistrationByUsername(username, registration);
}
use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class DuoSecurityAdminApiEndpoint method getUser.
/**
* Fetch duo user account from admin api.
*
* @param username the username
* @param providerId the provider id
* @return the map
*/
@GetMapping(path = "/{username}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Fetch Duo Security user account from Duo Admin API", parameters = { @Parameter(name = "username", required = true, in = ParameterIn.PATH), @Parameter(name = "providerId") })
public Map<String, DuoSecurityUserAccount> getUser(@PathVariable("username") final String username, @RequestParam(required = false) final String providerId) {
val results = new LinkedHashMap<String, DuoSecurityUserAccount>();
val providers = applicationContext.getBeansOfType(DuoSecurityMultifactorAuthenticationProvider.class).values();
providers.stream().filter(Objects::nonNull).map(DuoSecurityMultifactorAuthenticationProvider.class::cast).filter(provider -> StringUtils.isBlank(providerId) || provider.matches(providerId)).filter(provider -> provider.getDuoAuthenticationService().getAdminApiService().isPresent()).forEach(Unchecked.consumer(p -> {
val duoService = p.getDuoAuthenticationService().getAdminApiService().get();
duoService.getDuoSecurityUserAccount(username).ifPresent(user -> results.put(p.getId(), user));
}));
return results;
}
use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class DuoSecurityAdminApiEndpoint method createBypassCodes.
/**
* Create bypass codes.
*
* @param username the username
* @param providerId the provider id
* @param userId the user id
* @return the map
*/
@Operation(summary = "Create bypass codes using Duo Admin API", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "providerId"), @Parameter(name = "userId") })
@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).map(DuoSecurityMultifactorAuthenticationProvider.class::cast).filter(provider -> StringUtils.isBlank(providerId) || provider.matches(providerId)).filter(provider -> provider.getDuoAuthenticationService().getAdminApiService().isPresent()).forEach(Unchecked.consumer(p -> {
val duoService = p.getDuoAuthenticationService().getAdminApiService().get();
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(p.getId(), codes);
}
}));
return results;
}
Aggregations