Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/OIDC discovery with trailing slash (#7886)
Thomas Kaul68f99609f55b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c09e057b2d..91586f2345 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed- Fixed an issue where holdings without a quote have been valued at the unit price of the latest activity instead of the latest market price+- Fixed the discovery of the _OpenID Connect_ (`OIDC`) configuration for issuer URLs with a trailing slash (experimental)## 3.74.0 - 2026-09-27diff --git a/apps/api/src/app/auth/auth.module.ts b/apps/api/src/app/auth/auth.module.tsindex e2a71ca843..879463cc13 100644--- a/apps/api/src/app/auth/auth.module.ts+++ b/apps/api/src/app/auth/auth.module.ts@@ -22,6 +22,7 @@ import { AuthController } from './auth.controller';import { AuthService } from './auth.service';import { GoogleStrategy } from './google.strategy';import { JwtStrategy } from './jwt.strategy';+import { getOidcDiscoveryUrl } from './oidc.helper';import { OidcStrategy } from './oidc.strategy';@Module({@@ -94,9 +95,15 @@ import { OidcStrategy } from './oidc.strategy';// Fetch OIDC configuration from discovery endpointtry {const response = await fetchService.fetch(- `${issuer}/.well-known/openid-configuration`+ getOidcDiscoveryUrl(issuer));+ if (!response.ok) {+ throw new Error(+ `OIDC discovery request failed with status ${response.status}`+ );+ }+const config = (await response.json()) as {authorization_endpoint: string;token_endpoint: string;diff --git a/apps/api/src/app/auth/oidc.helper.spec.ts b/apps/api/src/app/auth/oidc.helper.spec.tsnew file mode 100644index 0000000000..9234f12c95--- /dev/null+++ b/apps/api/src/app/auth/oidc.helper.spec.ts@@ -0,0 +1,20 @@+import { getOidcDiscoveryUrl } from './oidc.helper';++describe('getOidcDiscoveryUrl', () => {+ it.each([+ [+ 'https://auth.example.com',+ 'https://auth.example.com/.well-known/openid-configuration'+ ],+ [+ 'https://auth.example.com/',+ 'https://auth.example.com/.well-known/openid-configuration'+ ],+ [+ 'https://auth.example.com/application/o/ghostfolio/',+ 'https://auth.example.com/application/o/ghostfolio/.well-known/openid-configuration'+ ]+ ])('creates the discovery URL for %s', (issuer, expected) => {+ expect(getOidcDiscoveryUrl(issuer)).toBe(expected);+ });+});diff --git a/apps/api/src/app/auth/oidc.helper.ts b/apps/api/src/app/auth/oidc.helper.tsnew file mode 100644index 0000000000..4e8de829fc--- /dev/null+++ b/apps/api/src/app/auth/oidc.helper.ts@@ -0,0 +1,4 @@+export function getOidcDiscoveryUrl(issuer: string) {+ // Remove trailing slashes+ return `${issuer.replace(/\/+$/, '')}/.well-known/openid-configuration`;+}