Fixed access issues around new Authorize scheme. (#1417)

This commit is contained in:
Joseph Milazzo 2022-08-08 17:00:10 -05:00 committed by GitHub
parent f406a533d9
commit 1ee6c3e506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 8 deletions

View File

@ -8,6 +8,8 @@ using API.DTOs.Reader;
using API.Entities.Enums; using API.Entities.Enums;
using API.Services; using API.Services;
using Kavita.Common; using Kavita.Common;
using HtmlAgilityPack;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using VersOne.Epub; using VersOne.Epub;
@ -91,6 +93,7 @@ namespace API.Controllers
/// <returns></returns> /// <returns></returns>
[HttpGet("{chapterId}/book-resources")] [HttpGet("{chapterId}/book-resources")]
[ResponseCache(Duration = 60 * 1, Location = ResponseCacheLocation.Client, NoStore = false)] [ResponseCache(Duration = 60 * 1, Location = ResponseCacheLocation.Client, NoStore = false)]
[AllowAnonymous]
public async Task<ActionResult> GetBookPageResources(int chapterId, [FromQuery] string file) public async Task<ActionResult> GetBookPageResources(int chapterId, [FromQuery] string file)
{ {
if (chapterId <= 0) return BadRequest("Chapter is not valid"); if (chapterId <= 0) return BadRequest("Chapter is not valid");

View File

@ -11,6 +11,7 @@ namespace API.Controllers
/// <summary> /// <summary>
/// Responsible for servicing up images stored in Kavita for entities /// Responsible for servicing up images stored in Kavita for entities
/// </summary> /// </summary>
[AllowAnonymous]
public class ImageController : BaseApiController public class ImageController : BaseApiController
{ {
private readonly IUnitOfWork _unitOfWork; private readonly IUnitOfWork _unitOfWork;

View File

@ -13,6 +13,7 @@ using API.Extensions;
using API.Services; using API.Services;
using API.SignalR; using API.SignalR;
using Hangfire; using Hangfire;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -80,6 +81,7 @@ namespace API.Controllers
/// <returns></returns> /// <returns></returns>
[HttpGet("image")] [HttpGet("image")]
[ResponseCache(Duration = 60 * 10, Location = ResponseCacheLocation.Client, NoStore = false)] [ResponseCache(Duration = 60 * 10, Location = ResponseCacheLocation.Client, NoStore = false)]
[AllowAnonymous]
public async Task<ActionResult> GetImage(int chapterId, int page) public async Task<ActionResult> GetImage(int chapterId, int page)
{ {
if (page < 0) page = 0; if (page < 0) page = 0;

View File

@ -1,4 +1,4 @@
<div class="{{theme}}"> <div class="{{theme}}" *ngIf="accountService.currentUser$ | async as user">
<ng-container *ngIf="isLoading"> <ng-container *ngIf="isLoading">
<div class="loading mx-auto" style="min-width: 200px; width: 600px;"> <div class="loading mx-auto" style="min-width: 200px; width: 600px;">
@ -14,9 +14,10 @@
<ngx-extended-pdf-viewer <ngx-extended-pdf-viewer
#pdfViewer #pdfViewer
[src]="readerService.downloadPdf(this.chapterId)" [src]="readerService.downloadPdf(this.chapterId)"
[authorization]="'Bearer ' + user.token"
height="100vh" height="100vh"
[(page)]="currentPage" [(page)]="currentPage"
[textLayer]="true" [textLayer]="true"
[useBrowserLocale]="false" [useBrowserLocale]="false"
[showHandToolButton]="true" [showHandToolButton]="true"
[showOpenFileButton]="false" [showOpenFileButton]="false"
@ -27,7 +28,7 @@
[showPropertiesButton]="false" [showPropertiesButton]="false"
[(zoom)]="zoomSetting" [(zoom)]="zoomSetting"
[showSecondaryToolbarButton]="true" [showSecondaryToolbarButton]="true"
[showBorders]="true" [showBorders]="true"
[theme]="theme" [theme]="theme"
[formTheme]="theme" [formTheme]="theme"
@ -38,8 +39,8 @@
(pdfLoadingStarts)="updateLoading(true)" (pdfLoadingStarts)="updateLoading(true)"
(pdfLoaded)="updateLoading(false)" (pdfLoaded)="updateLoading(false)"
(progress)="updateLoadProgress($event)" (progress)="updateLoadProgress($event)"
> >
</ngx-extended-pdf-viewer> </ngx-extended-pdf-viewer>
<ng-template #multiToolbar> <ng-template #multiToolbar>
@ -78,12 +79,12 @@
<i class="toolbar-icon fa-solid {{this.theme === 'light' ? 'fa-sun' : 'fa-moon'}}" [ngStyle]="{color: fontColor}" aria-hidden="true"></i> <i class="toolbar-icon fa-solid {{this.theme === 'light' ? 'fa-sun' : 'fa-moon'}}" [ngStyle]="{color: fontColor}" aria-hidden="true"></i>
<span class="visually-hidden">{{this.theme === 'light' ? 'Light Theme' : 'Dark Theme'}}</span> <span class="visually-hidden">{{this.theme === 'light' ? 'Light Theme' : 'Dark Theme'}}</span>
</button> </button>
<button class="btn btn-icon col-2 col-xs-1 toolbarButton" (click)="closeReader()"> <button class="btn btn-icon col-2 col-xs-1 toolbarButton" (click)="closeReader()">
<i class="toolbar-icon fa fa-times-circle" aria-hidden="true" [ngStyle]="{color: fontColor}"></i> <i class="toolbar-icon fa fa-times-circle" aria-hidden="true" [ngStyle]="{color: fontColor}"></i>
<span class="visually-hidden">Close Reader</span> <span class="visually-hidden">Close Reader</span>
</button> </button>
<div class="verticalToolbarSeparator hiddenSmallView"></div> <div class="verticalToolbarSeparator hiddenSmallView"></div>
<pdf-toggle-secondary-toolbar></pdf-toggle-secondary-toolbar> <pdf-toggle-secondary-toolbar></pdf-toggle-secondary-toolbar>
</div> </div>

View File

@ -77,7 +77,7 @@ export class PdfReaderComponent implements OnInit, OnDestroy {
private readonly onDestroy = new Subject<void>(); private readonly onDestroy = new Subject<void>();
constructor(private route: ActivatedRoute, private router: Router, private accountService: AccountService, constructor(private route: ActivatedRoute, private router: Router, public accountService: AccountService,
private seriesService: SeriesService, public readerService: ReaderService, private seriesService: SeriesService, public readerService: ReaderService,
private navService: NavService, private toastr: ToastrService, private navService: NavService, private toastr: ToastrService,
private bookService: BookService, private themeService: ThemeService, private bookService: BookService, private themeService: ThemeService,