Search in sources :

Example 1 with TrustedDevicesMultifactorProperties

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;
}
Also used : InMemoryMultifactorAuthenticationTrustStorage(org.apereo.cas.trusted.authentication.storage.InMemoryMultifactorAuthenticationTrustStorage) MultifactorAuthenticationTrustRecord(org.apereo.cas.trusted.authentication.api.MultifactorAuthenticationTrustRecord) BaseMultifactorAuthenticationTrustStorage(org.apereo.cas.trusted.authentication.storage.BaseMultifactorAuthenticationTrustStorage) TrustedDevicesMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.TrustedDevicesMultifactorProperties) JsonMultifactorAuthenticationTrustStorage(org.apereo.cas.trusted.authentication.storage.JsonMultifactorAuthenticationTrustStorage) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with TrustedDevicesMultifactorProperties

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);
}
Also used : TrustedDevicesMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.TrustedDevicesMultifactorProperties) LocalDate(java.time.LocalDate) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

TrustedDevicesMultifactorProperties (org.apereo.cas.configuration.model.support.mfa.TrustedDevicesMultifactorProperties)2 LocalDate (java.time.LocalDate)1 MultifactorAuthenticationTrustRecord (org.apereo.cas.trusted.authentication.api.MultifactorAuthenticationTrustRecord)1 BaseMultifactorAuthenticationTrustStorage (org.apereo.cas.trusted.authentication.storage.BaseMultifactorAuthenticationTrustStorage)1 InMemoryMultifactorAuthenticationTrustStorage (org.apereo.cas.trusted.authentication.storage.InMemoryMultifactorAuthenticationTrustStorage)1 JsonMultifactorAuthenticationTrustStorage (org.apereo.cas.trusted.authentication.storage.JsonMultifactorAuthenticationTrustStorage)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1