Remove | secure | async
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package com.adityachandel.booklore.config.security;
|
||||||
|
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ImageCachingFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
|
|
||||||
|
if (request.getRequestURI().startsWith("/api/v1/books") && request.getRequestURI().contains("/cover")) {
|
||||||
|
response.setHeader(HttpHeaders.CACHE_CONTROL, "public, max-age=3600");
|
||||||
|
response.setHeader(HttpHeaders.EXPIRES, String.valueOf(System.currentTimeMillis() + 3600000));
|
||||||
|
}
|
||||||
|
|
||||||
|
filterChain.doFilter(request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-1
@@ -1,6 +1,7 @@
|
|||||||
package com.adityachandel.booklore.config.security;
|
package com.adityachandel.booklore.config.security;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||||
@@ -49,7 +50,7 @@ public class SecurityConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public CorsConfigurationSource corsConfigurationSource() {
|
public CorsConfigurationSource corsConfigurationSource() {
|
||||||
CorsConfiguration configuration = new CorsConfiguration();
|
CorsConfiguration configuration = new CorsConfiguration();
|
||||||
configuration.setAllowedOrigins(List.of("http://localhost:4200")); // Allow frontend origin
|
configuration.setAllowedOrigins(List.of("http://localhost:4200"));
|
||||||
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
|
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
|
||||||
configuration.setAllowedHeaders(List.of("Authorization", "Cache-Control", "Content-Type"));
|
configuration.setAllowedHeaders(List.of("Authorization", "Cache-Control", "Content-Type"));
|
||||||
configuration.setExposedHeaders(List.of("Content-Disposition"));
|
configuration.setExposedHeaders(List.of("Content-Disposition"));
|
||||||
@@ -59,4 +60,12 @@ public class SecurityConfig {
|
|||||||
source.registerCorsConfiguration("/**", configuration);
|
source.registerCorsConfiguration("/**", configuration);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean<ImageCachingFilter> loggingFilter() {
|
||||||
|
FilterRegistrationBean<ImageCachingFilter> registrationBean = new FilterRegistrationBean<>();
|
||||||
|
registrationBean.setFilter(new ImageCachingFilter());
|
||||||
|
registrationBean.addUrlPatterns("/api/v1/books/*/cover");
|
||||||
|
return registrationBean;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,15 +13,14 @@ import {MetadataFetchOptionsComponent} from '../../../../metadata/metadata-optio
|
|||||||
import {MetadataRefreshType} from '../../../../metadata/model/request/metadata-refresh-type.enum';
|
import {MetadataRefreshType} from '../../../../metadata/model/request/metadata-refresh-type.enum';
|
||||||
import {MetadataRefreshRequest} from '../../../../metadata/model/request/metadata-refresh-request.model';
|
import {MetadataRefreshRequest} from '../../../../metadata/model/request/metadata-refresh-request.model';
|
||||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||||
import {AsyncPipe, NgIf} from '@angular/common';
|
import {NgIf} from '@angular/common';
|
||||||
import {SecurePipe} from '../../../../secure-pipe';
|
|
||||||
import {UserService} from '../../../../user.service';
|
import {UserService} from '../../../../user.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-book-card',
|
selector: 'app-book-card',
|
||||||
templateUrl: './book-card.component.html',
|
templateUrl: './book-card.component.html',
|
||||||
styleUrls: ['./book-card.component.scss'],
|
styleUrls: ['./book-card.component.scss'],
|
||||||
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgIf, SecurePipe, AsyncPipe],
|
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgIf],
|
||||||
standalone: true
|
standalone: true
|
||||||
})
|
})
|
||||||
export class BookCardComponent implements OnInit {
|
export class BookCardComponent implements OnInit {
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
<p-tableCheckbox [value]="book"></p-tableCheckbox>
|
<p-tableCheckbox [value]="book"></p-tableCheckbox>
|
||||||
</td>
|
</td>
|
||||||
<td (click)="openMetadataCenter(book.id)">
|
<td (click)="openMetadataCenter(book.id)">
|
||||||
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn) | secure | async" alt="Book Cover" class="size-7"/>
|
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)" alt="Book Cover" class="size-7"/>
|
||||||
</td>
|
</td>
|
||||||
<td class="min-w-[15rem] max-w-[20rem] overflow-hidden truncate">{{ metadata.title }}</td>
|
<td class="min-w-[15rem] max-w-[20rem] overflow-hidden truncate">{{ metadata.title }}</td>
|
||||||
<td class="min-w-[10rem] max-w-[13rem] overflow-hidden truncate">{{ getAuthorNames(metadata.authors) }}</td>
|
<td class="min-w-[10rem] max-w-[13rem] overflow-hidden truncate">{{ getAuthorNames(metadata.authors) }}</td>
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import {Component, EventEmitter, inject, Input, OnChanges, Output} from '@angular/core';
|
import {Component, EventEmitter, inject, Input, OnChanges, Output} from '@angular/core';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import {AsyncPipe, NgIf} from '@angular/common';
|
import {NgIf} from '@angular/common';
|
||||||
import {Rating} from 'primeng/rating';
|
import {Rating} from 'primeng/rating';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Book} from '../../../model/book.model';
|
import {Book} from '../../../model/book.model';
|
||||||
import {SortOption} from '../../../model/sort.model';
|
import {SortOption} from '../../../model/sort.model';
|
||||||
import {MetadataDialogService} from '../../../../metadata/service/metadata-dialog.service';
|
import {MetadataDialogService} from '../../../../metadata/service/metadata-dialog.service';
|
||||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||||
import {SecurePipe} from '../../../../secure-pipe';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-book-table',
|
selector: 'app-book-table',
|
||||||
@@ -17,9 +16,7 @@ import {SecurePipe} from '../../../../secure-pipe';
|
|||||||
TableModule,
|
TableModule,
|
||||||
NgIf,
|
NgIf,
|
||||||
Rating,
|
Rating,
|
||||||
FormsModule,
|
FormsModule
|
||||||
SecurePipe,
|
|
||||||
AsyncPipe
|
|
||||||
],
|
],
|
||||||
styleUrl: './book-table.component.scss'
|
styleUrl: './book-table.component.scss'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<ng-container *ngIf="books.length > 0; else noResults">
|
<ng-container *ngIf="books.length > 0; else noResults">
|
||||||
<div class="search-dropdown-item flex flex-col" *ngFor="let book of books" (click)="onBookClick(book)">
|
<div class="search-dropdown-item flex flex-col" *ngFor="let book of books" (click)="onBookClick(book)">
|
||||||
<div class="flex flex-row w-full px-2">
|
<div class="flex flex-row w-full px-2">
|
||||||
<img [attr.src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn) | secure | async" alt="Book Cover" class="search-book-cover"/>
|
<img [attr.src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)" alt="Book Cover" class="search-book-cover"/>
|
||||||
<div class="search-book-details">
|
<div class="search-book-details">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<p class="search-book-name text-lg font-medium truncate">{{ book.metadata?.title | slice:0:70 }}</p>
|
<p class="search-book-name text-lg font-medium truncate">{{ book.metadata?.title | slice:0:70 }}</p>
|
||||||
|
|||||||
@@ -6,11 +6,10 @@ import {FormsModule} from '@angular/forms';
|
|||||||
import {InputTextModule} from 'primeng/inputtext';
|
import {InputTextModule} from 'primeng/inputtext';
|
||||||
import {BookService} from '../../service/book.service';
|
import {BookService} from '../../service/book.service';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {AsyncPipe, NgForOf, NgIf, SlicePipe} from '@angular/common';
|
import {NgForOf, NgIf, SlicePipe} from '@angular/common';
|
||||||
import {MetadataDialogService} from '../../../metadata/service/metadata-dialog.service';
|
import {MetadataDialogService} from '../../../metadata/service/metadata-dialog.service';
|
||||||
import {Divider} from 'primeng/divider';
|
import {Divider} from 'primeng/divider';
|
||||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||||
import {SecurePipe} from '../../../secure-pipe';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-book-searcher',
|
selector: 'app-book-searcher',
|
||||||
@@ -22,9 +21,7 @@ import {SecurePipe} from '../../../secure-pipe';
|
|||||||
NgIf,
|
NgIf,
|
||||||
NgForOf,
|
NgForOf,
|
||||||
SlicePipe,
|
SlicePipe,
|
||||||
Divider,
|
Divider
|
||||||
AsyncPipe,
|
|
||||||
SecurePipe
|
|
||||||
],
|
],
|
||||||
styleUrls: ['./book-searcher.component.scss'],
|
styleUrls: ['./book-searcher.component.scss'],
|
||||||
standalone: true
|
standalone: true
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
<div class="flex flex-col items-center gap-2 relative">
|
<div class="flex flex-col items-center gap-2 relative">
|
||||||
|
|
||||||
<img
|
<img
|
||||||
[attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn) | secure | async"
|
[attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)"
|
||||||
alt="Image"
|
alt="Image"
|
||||||
width="250"
|
width="250"
|
||||||
[ngClass]="{ 'brightness-50': isUploading }"
|
[ngClass]="{ 'brightness-50': isUploading }"
|
||||||
|
|||||||
+1
-3
@@ -14,7 +14,6 @@ import {FileUpload, FileUploadErrorEvent, FileUploadEvent} from 'primeng/fileupl
|
|||||||
import {HttpResponse} from '@angular/common/http';
|
import {HttpResponse} from '@angular/common/http';
|
||||||
import {BookService} from '../../../book/service/book.service';
|
import {BookService} from '../../../book/service/book.service';
|
||||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||||
import {SecurePipe} from '../../../secure-pipe';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-editor',
|
selector: 'app-metadata-editor',
|
||||||
@@ -32,8 +31,7 @@ import {SecurePipe} from '../../../secure-pipe';
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
FileUpload,
|
FileUpload,
|
||||||
ProgressSpinner,
|
ProgressSpinner,
|
||||||
NgClass,
|
NgClass
|
||||||
SecurePipe
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class MetadataEditorComponent implements OnInit {
|
export class MetadataEditorComponent implements OnInit {
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
<div class="book-metadata-container flex-shrink-0" *ngIf="metadata$ | async as metadata">
|
<div class="book-metadata-container flex-shrink-0" *ngIf="metadata$ | async as metadata">
|
||||||
<div class="flex flex-row w-full">
|
<div class="flex flex-row w-full">
|
||||||
|
|
||||||
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn) | secure | async"
|
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)"
|
||||||
class="book-cover placeholder"
|
class="book-cover placeholder"
|
||||||
alt="Cover of {{ metadata.title }}"
|
alt="Cover of {{ metadata.title }}"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
|||||||
+1
-2
@@ -10,14 +10,13 @@ import {Tag} from 'primeng/tag';
|
|||||||
import {BookMetadata} from '../../../book/model/book.model';
|
import {BookMetadata} from '../../../book/model/book.model';
|
||||||
import {Divider} from 'primeng/divider';
|
import {Divider} from 'primeng/divider';
|
||||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||||
import {SecurePipe} from '../../../secure-pipe';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-viewer',
|
selector: 'app-metadata-viewer',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './metadata-viewer.component.html',
|
templateUrl: './metadata-viewer.component.html',
|
||||||
styleUrl: './metadata-viewer.component.scss',
|
styleUrl: './metadata-viewer.component.scss',
|
||||||
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider, SecurePipe]
|
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider]
|
||||||
})
|
})
|
||||||
export class MetadataViewerComponent {
|
export class MetadataViewerComponent {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user