From dcb7cf1ef10d8050c8077ef72bd8f55294eb1d9e Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 21 Oct 2026 14:56:43 +0200 Subject: [PATCH 1/4] Restrict asset endpoint to authenticated users --- .../app/__snapshots__/app.module.spec.ts.snap | 4 +++- apps/api/src/app/app.module.spec.ts | 1 - .../asset-profiles/asset.controller.ts | 10 +++++++++- .../src/app/components/markets/markets.html | 1 + .../lib/benchmark/benchmark.component.html | 2 +- .../src/lib/benchmark/benchmark.component.ts | 19 +++++++++++++------ 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/apps/api/src/app/__snapshots__/app.module.spec.ts.snap b/apps/api/src/app/__snapshots__/app.module.spec.ts.snap index f5e8b793d4..6d23e3bf7a 100644 --- a/apps/api/src/app/__snapshots__/app.module.spec.ts.snap +++ b/apps/api/src/app/__snapshots__/app.module.spec.ts.snap @@ -366,7 +366,9 @@ exports[`AppModule should keep the security of each route 1`] = ` ], }, "GET /asset/:dataSource/:symbol": { - "guards": [], + "guards": [ + "AuthGuard('jwt')", + ], "interceptors": [ "TransformDataSourceInResponseInterceptor", "TransformDataSourceInRequestInterceptor", diff --git a/apps/api/src/app/app.module.spec.ts b/apps/api/src/app/app.module.spec.ts index f04485ccdd..27e11ea919 100644 --- a/apps/api/src/app/app.module.spec.ts +++ b/apps/api/src/app/app.module.spec.ts @@ -52,7 +52,6 @@ const AUTHENTICATION_STRATEGIES = ['api-key', 'google', 'jwt', 'oidc']; * are not served by a controller */ const PUBLIC_ROUTES = [ - 'GET /asset/:dataSource/:symbol', 'GET /assets/:languageCode/site.webmanifest', 'GET /auth/google', 'GET /auth/google/callback', diff --git a/apps/api/src/app/endpoints/asset-profiles/asset.controller.ts b/apps/api/src/app/endpoints/asset-profiles/asset.controller.ts index 9c90691388..a296354c20 100644 --- a/apps/api/src/app/endpoints/asset-profiles/asset.controller.ts +++ b/apps/api/src/app/endpoints/asset-profiles/asset.controller.ts @@ -2,7 +2,14 @@ import { TransformDataSourceInRequestInterceptor } from '@ghostfolio/api/interce import { TransformDataSourceInResponseInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor'; import type { AssetResponse } from '@ghostfolio/common/interfaces'; -import { Controller, Get, Param, UseInterceptors } from '@nestjs/common'; +import { + Controller, + Get, + Param, + UseGuards, + UseInterceptors +} from '@nestjs/common'; +import { AuthGuard } from '@nestjs/passport'; import { DataSource } from '@prisma/client'; import { pick } from 'lodash-es'; @@ -15,6 +22,7 @@ export class AssetController { ) {} @Get(':dataSource/:symbol') + @UseGuards(AuthGuard('jwt')) @UseInterceptors(TransformDataSourceInRequestInterceptor) @UseInterceptors(TransformDataSourceInResponseInterceptor) public async getAsset( diff --git a/apps/client/src/app/components/markets/markets.html b/apps/client/src/app/components/markets/markets.html index 73e27e181e..176b847235 100644 --- a/apps/client/src/app/components/markets/markets.html +++ b/apps/client/src/app/components/markets/markets.html @@ -52,6 +52,7 @@