Fix OPDS
This commit is contained in:
-2
@@ -15,12 +15,10 @@ public class ImageCachingFilter extends OncePerRequestFilter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
|
|
||||||
if (request.getRequestURI().startsWith("/api/v1/books") && request.getRequestURI().contains("/cover")) {
|
if (request.getRequestURI().startsWith("/api/v1/books") && request.getRequestURI().contains("/cover")) {
|
||||||
response.setHeader(HttpHeaders.CACHE_CONTROL, "public, max-age=3600");
|
response.setHeader(HttpHeaders.CACHE_CONTROL, "public, max-age=3600");
|
||||||
response.setHeader(HttpHeaders.EXPIRES, String.valueOf(System.currentTimeMillis() + 3600000));
|
response.setHeader(HttpHeaders.EXPIRES, String.valueOf(System.currentTimeMillis() + 3600000));
|
||||||
}
|
}
|
||||||
|
|
||||||
filterChain.doFilter(request, response);
|
filterChain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -65,9 +65,17 @@ public class SecurityConfig {
|
|||||||
public SecurityFilterChain opdsBasicAuthSecurityChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain opdsBasicAuthSecurityChain(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
.securityMatcher("/api/v1/opds/**")
|
.securityMatcher("/api/v1/opds/**")
|
||||||
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
|
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
.authorizeHttpRequests(auth -> auth.anyRequest().authenticated())
|
.authorizeHttpRequests(auth -> auth.anyRequest().authenticated())
|
||||||
.httpBasic(basic -> basic.realmName("Booklore OPDS"))
|
.httpBasic(basic -> basic
|
||||||
.csrf(AbstractHttpConfigurer::disable);
|
.realmName("Booklore OPDS")
|
||||||
|
.authenticationEntryPoint((request, response, authException) -> {
|
||||||
|
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||||
|
response.setHeader("WWW-Authenticate", "Basic realm=\"Booklore OPDS\"");
|
||||||
|
response.getWriter().write("HTTP Status 401 - " + authException.getMessage());
|
||||||
|
})
|
||||||
|
);
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user