Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(backend:auth): update token expiration and enforce no-store Cache-Control headers
johavenb94ac0ed135f
diff --git a/backend/src/applications/links/links.controller.ts b/backend/src/applications/links/links.controller.tsindex 0f26527b..9e456701 100644--- a/backend/src/applications/links/links.controller.ts+++ b/backend/src/applications/links/links.controller.ts@@ -1,4 +1,4 @@-import { Body, Controller, Get, Param, Post, Req, Res, StreamableFile, UseGuards } from '@nestjs/common'+import { Body, Controller, Get, Header, Param, Post, Req, Res, StreamableFile, UseGuards } from '@nestjs/common'import { Throttle } from '@nestjs/throttler'import { FastifyReply, FastifyRequest } from 'fastify'import { AuthTokenOptional } from '../../authentication/decorators/auth-token-optional.decorator'@@ -31,6 +31,7 @@ export class LinksController {}@Get(`${PUBLIC_LINKS_ROUTE.ACCESS}/:uuid`)+ @Header('Cache-Control', 'no-store')@UseGuards(AuthRateLimitGuard)linkAccess(@GetUser() user: UserModel,@@ -54,6 +55,7 @@ export class LinksController {}@Post(`${PUBLIC_LINKS_ROUTE.AUTH}/:uuid`)+ @Header('Cache-Control', 'no-store')@UseGuards(AuthRateLimitGuard)linkAuthentication(@GetUser() user: UserModel,diff --git a/backend/src/applications/sync/sync.controller.ts b/backend/src/applications/sync/sync.controller.tsindex 7116631c..15d7232a 100644--- a/backend/src/applications/sync/sync.controller.ts+++ b/backend/src/applications/sync/sync.controller.ts@@ -4,6 +4,7 @@ import {Copy,Delete,Get,+ Header,HttpException,HttpStatus,Move,@@ -70,6 +71,7 @@ export class SyncController {}@Post(SYNC_ROUTE.REGISTER)+ @Header('Cache-Control', 'no-store')@AuthTokenSkip()@UseGuards(AuthRateLimitGuard)register(@Body() syncClientRegistrationDto: SyncClientRegistrationDto, @Req() req: FastifyRequest): Promise<SyncClientAuthRegistration> {@@ -77,6 +79,7 @@ export class SyncController {}@Post(SYNC_ROUTE.REGISTER_AUTH)+ @Header('Cache-Control', 'no-store')@UserHavePermission(USER_PERMISSION.DESKTOP_APP)@UseGuards(UserPermissionsGuard)registerWithAuth(@@ -101,6 +104,7 @@ export class SyncController {}@Post(`${SYNC_ROUTE.AUTH}/:type`)+ @Header('Cache-Control', 'no-store')@AuthTokenSkip()@UseGuards(AuthRateLimitGuard)authenticate(diff --git a/backend/src/applications/users/users.md b/backend/src/applications/users/users.mdindex 6b0d8e1c..5f546819 100644--- a/backend/src/applications/users/users.md+++ b/backend/src/applications/users/users.md@@ -35,7 +35,8 @@ the password-attempt limit does not suspend the account.`isActive` is the durable administrative switch for a local user record:- `isActive: false` is rejected by local password and app-password paths as well as by the LDAP and OIDC provider flows;-- authenticated requests and token refreshes reload the local user record, so disabling the account also invalidates existing sessions;+- new authentication and token refreshes reload the local user record and reject an inactive account. Already-issued access tokens and positive+ WebDAV authentication cache entries remain usable until they expire;- the account remains disabled until an administrator reactivates it; there is no automatic expiration;- reactivating the account resets `passwordAttempts` to zero.diff --git a/backend/src/authentication/auth.config.ts b/backend/src/authentication/auth.config.tsindex f8c195d8..3bdf8509 100644--- a/backend/src/authentication/auth.config.ts+++ b/backend/src/authentication/auth.config.ts@@ -17,7 +17,7 @@ export class AuthTokenAccessConfig {@IsString()@IsNotEmpty()- expiration = '30m'+ expiration = '15m'}export class AuthTokenRefreshConfig {diff --git a/backend/src/authentication/auth.controller.ts b/backend/src/authentication/auth.controller.tsindex 393d6575..8519be72 100755--- a/backend/src/authentication/auth.controller.ts+++ b/backend/src/authentication/auth.controller.ts@@ -51,6 +51,7 @@ export class AuthController {}@Post(AUTH_ROUTE.TOKEN)+ @Header('Cache-Control', 'no-store')@AuthTokenSkip()@UseGuards(AuthRateLimitGuard, AuthLocalGuard, AuthTwoFaVerificationWithoutPasswordGuard)token(@GetUser() user: UserModel): Promise<TokenResponseDto> {@@ -58,6 +59,7 @@ export class AuthController {}@Post(AUTH_ROUTE.TOKEN_REFRESH)+ @Header('Cache-Control', 'no-store')@AuthTokenSkip()@UseGuards(AuthTokenRefreshGuard)refreshToken(@GetUser() user: UserModel): Promise<TokenResponseDto> {@@ -81,6 +83,7 @@ export class AuthController {}@Post(`${AUTH_ROUTE.TWO_FA_BASE}/${AUTH_ROUTE.TWO_FA_ENABLE}`)+ @Header('Cache-Control', 'no-store')@UseGuards(AuthRateLimitGuard, UserRolesGuard)@UserHaveRole(USER_ROLE.USER)twoFaEnable(@Body() body: TwoFaVerifyWithPasswordDto, @Req() req: FastifyAuthenticatedRequest): Promise<TwoFaVerifyResult> {diff --git a/environment/environment.dist.yaml b/environment/environment.dist.yamlindex d833043a..02862439 100644--- a/environment/environment.dist.yaml+++ b/environment/environment.dist.yaml@@ -100,8 +100,8 @@ auth:# requiredsecret:# token expiration = cookie maxAge- # default: `30m`- expiration: 30m+ # default: `15m`+ expiration: 15mrefresh:# Used for token and cookie signatures# required