// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http.filter.security.misc;

import com.yahoo.jdisc.http.filter.DiscFilterResponse;
import com.yahoo.jdisc.http.filter.RequestView;
import com.yahoo.jdisc.http.filter.SecurityResponseFilter;

/**
 * Adds recommended security response headers intended for hardening Rest APIs over https.
 *
 * @author bjorncs
 */
public class SecurityHeadersResponseFilter implements SecurityResponseFilter {

    @Override
    public void filter(DiscFilterResponse response, RequestView request) {
        response.setHeader("Cache-control", "no-store");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
        response.setHeader("X-Content-Type-Options", "nosniff");
        response.setHeader("X-Frame-Options", "DENY");
    }
}

@@ -922,20 +922,102 @@
 %22, %22DENY%22);%0A
+        response.setHeader(%22Referrer-Policy%22, %22strict-origin-when-cross-origin%22);%0A
     %7D%0A%7D%0A

Add Referrer-Policy header