Avoid native login dialog when JWT token expires
This commit is contained in:
+12
-1
@@ -60,6 +60,14 @@ public class DualJwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
String token = extractToken(request);
|
||||
|
||||
String path = request.getRequestURI();
|
||||
|
||||
if (path.equals("/api/v1/auth/refresh")) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (token == null) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
@@ -70,11 +78,14 @@ public class DualJwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
} else if (appSettingService.getAppSettings().isOidcEnabled()) {
|
||||
authenticateOidcUser(token, request);
|
||||
} else {
|
||||
log.debug("OIDC is disabled. Skipping OIDC authentication.");
|
||||
log.debug("OIDC is disabled and token is invalid. Rejecting request.");
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("Authentication error: {}", ex.getMessage(), ex);
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
-1
@@ -55,7 +55,6 @@ public class SecurityConfig {
|
||||
).permitAll()
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.httpBasic(customizer -> customizer.realmName("Booklore OPDS"))
|
||||
.addFilterBefore(dualJwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
return http.build();
|
||||
|
||||
@@ -33,7 +33,7 @@ public enum ApiError {
|
||||
USERNAME_ALREADY_TAKEN(HttpStatus.BAD_REQUEST, "Username already taken: %s"),
|
||||
USER_NOT_FOUND(HttpStatus.BAD_REQUEST, "User not found: %s"),
|
||||
CANNOT_DELETE_ADMIN(HttpStatus.FORBIDDEN, "Admin user cannot be deleted"),
|
||||
UNAUTHORIZED(HttpStatus.FORBIDDEN, "%s"),
|
||||
UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "%s"),
|
||||
BAD_REQUEST(HttpStatus.BAD_REQUEST, "%s"),
|
||||
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "%s"),
|
||||
PASSWORD_INCORRECT(HttpStatus.BAD_REQUEST, "Incorrect current password"),
|
||||
|
||||
@@ -321,7 +321,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
private trackProgress(): void {
|
||||
if (!this.book || !this.rendition) return;
|
||||
this.rendition.on('relocated', (location: any) => {
|
||||
const cfi = location.start.cfi;
|
||||
const cfi = location.end.cfi;
|
||||
const currentIndex = location.start.index;
|
||||
const totalSpineItems = this.book.spine.items.length;
|
||||
let percentage: number;
|
||||
|
||||
Reference in New Issue
Block a user