Skip to content

Commit 10054b9

Browse files
committed
Add @global annotation to SecurityHeadersFilter for automatic registration
1 parent ade9820 commit 10054b9

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

src/main/java/org/juv25d/filter/SecurityHeadersFilter.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11

22
package org.juv25d.filter;
33

4+
import org.juv25d.filter.annotation.Global;
45
import org.juv25d.http.HttpRequest;
56
import org.juv25d.http.HttpResponse;
67
import java.io.IOException;
78

8-
/**
9-
* Filter som lägger till säkerhetsheaders till varje HTTP-svar.
10-
* Detta hjälper till att skydda mot attacker som Clickjacking och MIME-sniffing.
11-
*/
12-
public class SecurityHeadersFilter implements Filter {
13-
14-
@Override
15-
public void doFilter(HttpRequest req, HttpResponse res, FilterChain chain) throws IOException {
16-
try {
17-
chain.doFilter(req, res);
18-
} finally {
9+
/**
10+
* Filter that adds security headers to every HTTP response.
11+
* This helps protect against attacks such as Clickjacking and MIME sniffing.
12+
*/
13+
@Global(order = 0)
14+
public class SecurityHeadersFilter implements Filter {
15+
16+
@Override
17+
public void doFilter(HttpRequest req, HttpResponse res, FilterChain chain) throws IOException {
18+
try {
19+
chain.doFilter(req, res);
20+
} finally {
1921

2022
res.setHeader("X-Content-Type-Options", "nosniff");
2123
res.setHeader("X-Frame-Options", "DENY");

0 commit comments

Comments
 (0)