Search in sources :

Example 1 with CookieSameSiteSupplier

use of org.springframework.boot.web.servlet.server.CookieSameSiteSupplier in project spring-boot by spring-projects.

the class TomcatServletWebServerFactory method configureCookieProcessor.

private void configureCookieProcessor(Context context) {
    SameSite sessionSameSite = getSession().getCookie().getSameSite();
    List<CookieSameSiteSupplier> suppliers = new ArrayList<>();
    if (sessionSameSite != null) {
        suppliers.add(CookieSameSiteSupplier.of(sessionSameSite).whenHasName(() -> SessionConfig.getSessionCookieName(context)));
    }
    if (!CollectionUtils.isEmpty(getCookieSameSiteSuppliers())) {
        suppliers.addAll(getCookieSameSiteSuppliers());
    }
    if (!suppliers.isEmpty()) {
        context.setCookieProcessor(new SuppliedSameSiteCookieProcessor(suppliers));
    }
}
Also used : ArrayList(java.util.ArrayList) SameSite(org.springframework.boot.web.server.Cookie.SameSite) CookieSameSiteSupplier(org.springframework.boot.web.servlet.server.CookieSameSiteSupplier)

Example 2 with CookieSameSiteSupplier

use of org.springframework.boot.web.servlet.server.CookieSameSiteSupplier in project spring-boot by spring-projects.

the class UndertowServletWebServerFactory method getCookieHandlerFactory.

private HttpHandlerFactory getCookieHandlerFactory(Deployment deployment) {
    SameSite sessionSameSite = getSession().getCookie().getSameSite();
    List<CookieSameSiteSupplier> suppliers = new ArrayList<>();
    if (sessionSameSite != null) {
        String sessionCookieName = deployment.getServletContext().getSessionCookieConfig().getName();
        suppliers.add(CookieSameSiteSupplier.of(sessionSameSite).whenHasName(sessionCookieName));
    }
    if (!CollectionUtils.isEmpty(getCookieSameSiteSuppliers())) {
        suppliers.addAll(getCookieSameSiteSuppliers());
    }
    return (!suppliers.isEmpty()) ? (next) -> new SuppliedSameSiteCookieHandler(next, suppliers) : null;
}
Also used : ArrayList(java.util.ArrayList) SameSite(org.springframework.boot.web.server.Cookie.SameSite) CookieSameSiteSupplier(org.springframework.boot.web.servlet.server.CookieSameSiteSupplier)

Aggregations

ArrayList (java.util.ArrayList)2 SameSite (org.springframework.boot.web.server.Cookie.SameSite)2 CookieSameSiteSupplier (org.springframework.boot.web.servlet.server.CookieSameSiteSupplier)2