use of org.apereo.cas.configuration.model.support.mfa.TrustedDevicesMultifactorProperties in project cas by apereo.
the class MultifactorAuthnTrustConfiguration method mfaTrustEngine.
@ConditionalOnMissingBean(name = "mfaTrustEngine")
@Bean
@RefreshScope
public MultifactorAuthenticationTrustStorage mfaTrustEngine() {
final TrustedDevicesMultifactorProperties trusted = casProperties.getAuthn().getMfa().getTrusted();
final LoadingCache<String, MultifactorAuthenticationTrustRecord> storage = Caffeine.newBuilder().initialCapacity(INITIAL_CACHE_SIZE).maximumSize(MAX_CACHE_SIZE).expireAfterWrite(trusted.getExpiration(), trusted.getTimeUnit()).build(s -> {
LOGGER.error("Load operation of the cache is not supported.");
return null;
});
storage.asMap();
final BaseMultifactorAuthenticationTrustStorage m;
if (trusted.getJson().getLocation() != null) {
LOGGER.debug("Storing trusted device records inside the JSON resource [{}]", trusted.getJson().getLocation());
m = new JsonMultifactorAuthenticationTrustStorage(trusted.getJson().getLocation());
} else {
LOGGER.warn("Storing trusted device records in runtime memory. Changes and records will be lost upon CAS restarts");
m = new InMemoryMultifactorAuthenticationTrustStorage(storage);
}
m.setCipherExecutor(mfaTrustCipherExecutor());
return m;
}
use of org.apereo.cas.configuration.model.support.mfa.TrustedDevicesMultifactorProperties in project cas by apereo.
the class TrustedDevicesController method getRecords.
/**
* Gets records.
*
* @param request the request
* @param response the response
* @return the records
*/
@GetMapping(value = "/getRecords")
@ResponseBody
public Set<MultifactorAuthenticationTrustRecord> getRecords(final HttpServletRequest request, final HttpServletResponse response) {
ensureEndpointAccessIsAuthorized(request, response);
final TrustedDevicesMultifactorProperties trusted = casProperties.getAuthn().getMfa().getTrusted();
final LocalDate onOrAfter = LocalDate.now().minus(trusted.getExpiration(), DateTimeUtils.toChronoUnit(trusted.getTimeUnit()));
this.mfaTrustEngine.expire(onOrAfter);
return this.mfaTrustEngine.get(onOrAfter);
}
Aggregations