Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fixed IP address handling for SSO

Blue Mousea9223e531dbb
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts
index 0256ec152..c2a2fcf28 100644
--- a/src/auth/auth.controller.ts
+++ b/src/auth/auth.controller.ts
@@ -430,8 +430,12 @@ export class AuthController {
@Public()
async generateAuthURL(
@Body() body: SSOGenerateDto,
- @Ip() ip: string,
+ @Headers() headers: unknown,
+ @Ip() reqIP: string,
): Promise<any> {
+ const ip =
+ headers['cf-connecting-ip'] || headers['x-forwarded-for'] || reqIP || ''
+
await checkRateLimit(
ip,
'sso-generate',
@@ -457,8 +461,12 @@ export class AuthController {
@Public()
async processSSOToken(
@Body() body: ProcessSSOCodeDto,
- @Ip() ip: string,
+ @Headers() headers: unknown,
+ @Ip() reqIP: string,
): Promise<any> {
+ const ip =
+ headers['cf-connecting-ip'] || headers['x-forwarded-for'] || reqIP || ''
+
await checkRateLimit(
ip,
'sso-process',
@@ -478,8 +486,11 @@ export class AuthController {
async getJWTByHash(
@Body() body: SSOGetJWTByHashDto,
@Headers() headers: unknown,
- @Ip() ip: string,
+ @Ip() reqIP: string,
): Promise<any> {
+ const ip =
+ headers['cf-connecting-ip'] || headers['x-forwarded-for'] || reqIP || ''
+
const { hash, provider } = body
return this.authService.authenticateSSO(hash, headers, ip, provider)