diff --git a/CHANGELOG.md b/CHANGELOG.md index 297677b966..4bb5b04598 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved the market price in the benchmark detail dialog by adding the currency and reducing the precision on mobile - Improved the style of the close button in the dialog footer component - Improved the style of the close button in the dialog header component +- Restricted the asset endpoint (`GET api/v1/asset/:dataSource/:symbol`) to authenticated users - Improved the language localization for German (`de`) - Upgraded `prettier` from version `3.9.9` to `3.9.10` 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.component.ts b/apps/client/src/app/components/markets/markets.component.ts index 1c8fdb1e1d..c4782b7db4 100644 --- a/apps/client/src/app/components/markets/markets.component.ts +++ b/apps/client/src/app/components/markets/markets.component.ts @@ -66,6 +66,7 @@ export class GfMarketsComponent implements OnInit { protected fearAndGreedIndex: number | undefined; protected fearAndGreedIndexMode: FearAndGreedIndexMode = 'STOCKS'; protected hasPermissionToAccessFearAndGreedIndex: boolean; + protected hasPermissionToOpenBenchmarkDetails = false; protected hasPermissionToReadMarketDataOfMarkets: boolean; protected historicalDataItems: LineChartItem[]; protected isLoadingFearAndGreedIndex = true; @@ -99,6 +100,8 @@ export class GfMarketsComponent implements OnInit { if (state?.user) { this.user = state.user; + this.hasPermissionToOpenBenchmarkDetails = true; + this.hasPermissionToReadMarketDataOfMarkets = hasPermission( this.user.permissions, permissions.readMarketDataOfMarkets diff --git a/apps/client/src/app/components/markets/markets.html b/apps/client/src/app/components/markets/markets.html index 73e27e181e..eafb3224f2 100644 --- a/apps/client/src/app/components/markets/markets.html +++ b/apps/client/src/app/components/markets/markets.html @@ -52,6 +52,7 @@