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(auth): skip app-password step-up for OIDC user sessions
johavenac118be4e3c9
diff --git a/backend/src/applications/users/models/user.model.ts b/backend/src/applications/users/models/user.model.tsindex 82981ba5..79cdf1e9 100644--- a/backend/src/applications/users/models/user.model.ts+++ b/backend/src/applications/users/models/user.model.ts@@ -1,6 +1,7 @@import { Exclude, Expose } from 'class-transformer'import fs from 'node:fs/promises'import path from 'node:path'+import type { AUTH_SESSION } from '../../../authentication/providers/auth-providers.constants'import { popFromObject } from '../../../common/shared'import { configuration } from '../../../configuration/config.environment'import { isPathInside } from '../../files/utils/files'@@ -49,6 +50,7 @@ export class UserModel implements User {// outside db schemafullName: stringimpersonated?: boolean+ authSession?: AUTH_SESSIONavatarBase64?: string// permissions as a listapplications: string[] = []diff --git a/backend/src/applications/users/services/users-manager.service.ts b/backend/src/applications/users/services/users-manager.service.tsindex 1310cce0..64df4d85 100755--- a/backend/src/applications/users/services/users-manager.service.ts+++ b/backend/src/applications/users/services/users-manager.service.ts@@ -76,6 +76,7 @@ export class UsersManager {user.impersonatedClientId = authUser.impersonatedClientId}user.clientId = authUser.clientId+ user.authSession = authUser.authSessionuser.exp = authUser.expreturn user}@@ -172,6 +173,7 @@ export class UsersManager {}user.impersonated = !!authUser.impersonatedFromIduser.clientId = authUser.clientId+ user.authSession = authUser.authSessionreturn { user: user, server: serverConfig }}diff --git a/backend/src/authentication/auth.md b/backend/src/authentication/auth.mdindex 69630748..de5a3044 100644--- a/backend/src/authentication/auth.md+++ b/backend/src/authentication/auth.md@@ -115,6 +115,14 @@ Some authentication flows are non-interactive and pass an `AUTH_SCOPE` to the coScoped authentication can validate app passwords stored in user secrets. App passwords are scoped to one application and do not grant access to otherscopes.+### App passwords++Generating and revoking app passwords are self-service actions. Regular users whose current browser session was created through OIDC do not need to+pass a Sync-in step-up challenge for these actions. Sync-in relies on the IdP authentication policy that issued the local session.++Local password sessions, administrators, and non-OIDC sessions must still pass the usual Sync-in step-up: TOTP when enabled, otherwise local password+confirmation.+### WebDAV and TOTPWebDAV uses HTTP Basic authentication and cannot complete the interactive Sync-in TOTP challenge. For that reason, the WebDAV password rule is:@@ -145,11 +153,13 @@ Client tokens are long-lived registration credentials, not user passwords. TheirMySQL delegates password checks directly to the local user manager.LDAP authenticates regular users against LDAP. Local password authentication is still used for guest users and application scopes. Administrators can-use local password fallback as break-glass access when LDAP authentication fails according to the configured fallback rules.+use local password fallback as break-glass access when LDAP authentication fails according to the configured fallback rules. Administrator accounts+should therefore have a local Sync-in password configured and kept available for break-glass recovery.OIDC browser login delegates the primary authentication and MFA policy to the identity provider. Sync-in does not add its local TOTP challenge after asuccessful OIDC callback. Local password paths can still exist with OIDC selected for guests, administrators, scoped application authentication, and-regular users when explicitly enabled. See `providers/oidc/oidc.md`.+regular users when explicitly enabled. Administrator accounts should have a local Sync-in password configured and kept available for break-glass+recovery. See `providers/oidc/oidc.md`.## Access updates and password attemptsdiff --git a/backend/src/authentication/auth.service.spec.ts b/backend/src/authentication/auth.service.spec.tsindex 18c183fd..175aa557 100755--- a/backend/src/authentication/auth.service.spec.ts+++ b/backend/src/authentication/auth.service.spec.ts@@ -1,21 +1,53 @@import { ConfigService } from '@nestjs/config'import { JwtService } from '@nestjs/jwt'import { Test, TestingModule } from '@nestjs/testing'+import { USER_ROLE } from '../applications/users/constants/user'+import { UserModel } from '../applications/users/models/user.model'import { AuthManager } from './auth.service'+import { AUTH_SESSION } from './providers/auth-providers.constants'describe(AuthManager.name, () => {+ const jwtService = { signAsync: vi.fn() }let authManager: AuthManagerbeforeAll(async () => {const module: TestingModule = await Test.createTestingModule({- providers: [AuthManager, { provide: JwtService, useValue: {} }, { provide: ConfigService, useValue: { get: () => null } }]+ providers: [AuthManager, { provide: JwtService, useValue: jwtService }, { provide: ConfigService, useValue: { get: () => null } }]}).compile()module.useLogger(['fatal'])authManager = module.get<AuthManager>(AuthManager)})+ beforeEach(() => {+ jwtService.signAsync.mockReset()+ jwtService.signAsync.mockResolvedValue('token')+ })+it('should be defined', () => {expect(authManager).toBeDefined()})++ it('should preserve the authentication method in cookies and response user', async () => {+ const user = new UserModel({+ id: 1,+ login: 'alice',+ email: '[email protected]',+ firstName: 'Alice',+ lastName: 'Doe',+ language: 'en',+ role: USER_ROLE.USER+ })+ const res = { setCookie: vi.fn() }++ const response = await authManager.setCookies(user, res as any, false, AUTH_SESSION.OIDC)++ expect(response.user.authSession).toBe(AUTH_SESSION.OIDC)+ expect(jwtService.signAsync).toHaveBeenCalledWith(+ expect.objectContaining({+ identity: expect.objectContaining({ authSession: AUTH_SESSION.OIDC })+ }),+ expect.any(Object)+ )+ })})diff --git a/backend/src/authentication/auth.service.ts b/backend/src/authentication/auth.service.tsindex 0b9f1fdb..94c5451c 100755--- a/backend/src/authentication/auth.service.ts+++ b/backend/src/authentication/auth.service.ts@@ -14,7 +14,7 @@ import { LoginResponseDto, LoginVerify2FaDto } from './dto/login-response.dto'import { TokenResponseDto } from './dto/token-response.dto'import { JwtIdentity2FaPayload, JwtIdentityPayload, JwtPayload } from './interfaces/jwt-payload.interface'import { TOKEN_TYPE } from './interfaces/token.interface'-import { AUTH_PROVIDER } from './providers/auth-providers.constants'+import { AUTH_PROVIDER, AUTH_SESSION } from './providers/auth-providers.constants'import type { AuthOIDCSettings } from './providers/oidc/auth-oidc.interfaces'@Injectable()@@ -39,11 +39,17 @@ export class AuthManager {}}- async setCookies(user: UserModel, res: FastifyReply, init2FaVerify: true): Promise<LoginVerify2FaDto>- async setCookies(user: UserModel, res: FastifyReply, init2FaVerify?: false): Promise<LoginResponseDto>- async setCookies(user: UserModel, res: FastifyReply, init2FaVerify = false): Promise<LoginResponseDto | LoginVerify2FaDto> {+ async setCookies(user: UserModel, res: FastifyReply, init2FaVerify: true, authSession?: AUTH_SESSION): Promise<LoginVerify2FaDto>+ async setCookies(user: UserModel, res: FastifyReply, init2FaVerify?: false, authSession?: AUTH_SESSION): Promise<LoginResponseDto>+ async setCookies(+ user: UserModel,+ res: FastifyReply,+ init2FaVerify = false,+ authSession: AUTH_SESSION = AUTH_SESSION.LOCAL+ ): Promise<LoginResponseDto | LoginVerify2FaDto> {// If `verify2Fa` is true, it sets the cookies and response required for valid 2FA authentication.const verify2Fa = init2FaVerify && configuration.auth.mfa.totp.enabled && user.twoFaEnabled+ user.authSession = authSessionconst response = verify2Fa ? new LoginVerify2FaDto(serverConfig) : new LoginResponseDto(user, serverConfig)const currentTime = currentTimeStamp()const csrfToken: string = crypto.randomUUID()@@ -159,6 +165,7 @@ export class AuthManager {applications: user.applications,impersonatedFromId: user.impersonatedFromId || undefined,impersonatedClientId: user.impersonatedClientId || undefined,+ authSession: user.authSession || AUTH_SESSION.LOCAL,clientId: user.clientId || undefined,twoFaEnabled: user.twoFaEnabled || undefined} satisfies JwtIdentityPayload,diff --git a/backend/src/authentication/interfaces/jwt-payload.interface.ts b/backend/src/authentication/interfaces/jwt-payload.interface.tsindex 04a87500..7af11c69 100644--- a/backend/src/authentication/interfaces/jwt-payload.interface.ts+++ b/backend/src/authentication/interfaces/jwt-payload.interface.ts@@ -1,3 +1,4 @@+import type { AUTH_SESSION } from '../providers/auth-providers.constants'import { TOKEN_TYPE } from './token.interface'export class JwtIdentityPayload {@@ -10,6 +11,7 @@ export class JwtIdentityPayload {applications: string[]impersonatedFromId?: numberimpersonatedClientId?: string+ authSession?: AUTH_SESSIONclientId?: stringtwoFaEnabled?: boolean}diff --git a/backend/src/authentication/providers/auth-providers.constants.ts b/backend/src/authentication/providers/auth-providers.constants.tsindex ee4586c2..4f9e1b08 100644--- a/backend/src/authentication/providers/auth-providers.constants.ts+++ b/backend/src/authentication/providers/auth-providers.constants.ts@@ -1,4 +1,10 @@export const DEFAULT_STORAGE_QUOTA_FIELD = 'storageQuota'++export enum AUTH_SESSION {+ LOCAL = 'local',+ OIDC = 'oidc'+}+export enum AUTH_PROVIDER {MYSQL = 'mysql',LDAP = 'ldap',diff --git a/backend/src/authentication/providers/oidc/auth-oidc.controller.ts b/backend/src/authentication/providers/oidc/auth-oidc.controller.tsindex cb1c6a68..04b10066 100644--- a/backend/src/authentication/providers/oidc/auth-oidc.controller.ts+++ b/backend/src/authentication/providers/oidc/auth-oidc.controller.ts@@ -5,6 +5,7 @@ import { AuthManager } from '../../auth.service'import { AUTH_ROUTE } from '../../constants/routes'import { AuthTokenSkip } from '../../decorators/auth-token-skip.decorator'import type { LoginResponseDto } from '../../dto/login-response.dto'+import { AUTH_SESSION } from '../auth-providers.constants'import { OAuthDesktopPortParam } from './auth-oidc-desktop.constants'import { AuthProviderOIDC } from './auth-provider-oidc.service'@@ -27,7 +28,7 @@ export class AuthOIDCController {@AuthTokenSkip()async oidcCallback(@Query() query: Record<string, string>, @Req() req: FastifyRequest, @Res() res: FastifyReply): Promise<void> {const user: UserModel = await this.authProviderOIDC.handleCallback(req, res, query)- const r: LoginResponseDto = await this.authManager.setCookies(user, res, false)+ const r: LoginResponseDto = await this.authManager.setCookies(user, res, false, AUTH_SESSION.OIDC)return res.redirect(this.authProviderOIDC.getRedirectCallbackUrl(r.token.access_expiration, r.token.refresh_expiration), HttpStatus.FOUND)}}diff --git a/backend/src/authentication/providers/oidc/oidc.md b/backend/src/authentication/providers/oidc/oidc.mdindex bdb21f20..316a3147 100644--- a/backend/src/authentication/providers/oidc/oidc.md+++ b/backend/src/authentication/providers/oidc/oidc.md@@ -178,7 +178,7 @@ Downloads from private or internal IP ranges are blocked by default to limit ser## Local password authentication and MFAOIDC login trusts the authentication policy enforced by the identity provider. Sync-in does not add its local TOTP challenge after a successful OIDC-callback. Administrators must require MFA, when needed, in the IdP policy assigned to the Sync-in client or application.+callback. Administrators should enforce MFA, when needed, in the IdP policy assigned to the Sync-in client or application.A successful IdP authentication does not override local account access: an existing user disabled in Sync-in is rejected before external identitybinding or profile synchronization.@@ -190,8 +190,22 @@ Sync-in TOTP still applies to interactive local password authentication. With th- scoped application or app-password authentication;- regular users when `options.enablePasswordAuth` is enabled.+Administrator accounts should have a local Sync-in password configured and kept available so they can use break-glass access if the identity provider+is unavailable or misconfigured.+Scoped application authentication is non-interactive and does not invoke a TOTP challenge.+### App passwords++App passwords remain local Sync-in secrets used for scoped application authentication, such as WebDAV or client access. They are not OIDC tokens and+they are not synchronized with the identity provider.++For self-service generation or revocation, regular users do not need to pass a Sync-in step-up challenge when their current browser session was+created through OIDC. The OIDC provider is expected to enforce the primary authentication and MFA policy before issuing the Sync-in browser session.++This exception does not apply to administrators or to local password sessions, including regular users who authenticate locally when+`options.enablePasswordAuth` is enabled. Those sessions must still pass the usual Sync-in step-up before app passwords can be generated or revoked.+The Sync-in logout endpoint clears only the local session cookies. It does not currently call the IdP end-session or token revocation endpoints, so anexisting IdP SSO session can authenticate the browser again without prompting for credentials.diff --git a/backend/src/authentication/providers/two-fa/guards/auth-two-fa-verification.guard.spec.ts b/backend/src/authentication/providers/two-fa/guards/auth-two-fa-verification.guard.spec.tsindex 0965730e..793c587e 100644--- a/backend/src/authentication/providers/two-fa/guards/auth-two-fa-verification.guard.spec.ts+++ b/backend/src/authentication/providers/two-fa/guards/auth-two-fa-verification.guard.spec.ts@@ -6,6 +6,7 @@ import { UserModel } from '../../../../applications/users/models/user.model'import { configuration } from '../../../../configuration/config.environment'import { TWO_FA_HEADER_CODE, TWO_FA_HEADER_PASSWORD } from '../../../constants/auth'import { FastifyAuthenticatedRequest } from '../../../interfaces/auth-request.interface'+import { AUTH_SESSION } from '../../auth-providers.constants'import { AuthProvider2FA } from '../auth-provider-two-fa.service'import type { TwoFaVerifyDto } from '../auth-two-fa.dtos'import type { TwoFaVerifyResult } from '../auth-two-fa.interfaces'@@ -17,6 +18,9 @@ describe(AuthTwoFaVerificationOrPasswordGuard.name, () => {const originalTotpEnabled = configuration.auth.mfa.totp.enabledconst userWithTotp = { id: 1, twoFaEnabled: true } as UserModelconst userWithoutTotp = { id: 1, twoFaEnabled: false } as UserModel+ const regularUserWithoutTotp = { id: 1, isAdmin: false, isUser: true, twoFaEnabled: false } as UserModel+ const regularUserWithTotp = { id: 1, isAdmin: false, isUser: true, twoFaEnabled: true } as UserModel+ const adminWithTotp = { id: 1, isAdmin: true, isUser: true, twoFaEnabled: true } as UserModellet guard: CanActivatelet authProvider2FA: DeepMocked<AuthProvider2FA>@@ -75,6 +79,28 @@ describe(AuthTwoFaVerificationOrPasswordGuard.name, () => {expect(authProvider2FA.verify).not.toHaveBeenCalled()})+ it.each([+ ['without TOTP', regularUserWithoutTotp],+ ['with TOTP', regularUserWithTotp]+ ])('should skip app-password step-up for regular OIDC sessions %s', async (_, user) => {+ authProvider2FA.loadUser.mockResolvedValue(user)++ await expect(guard.canActivate(makeContext({}, { authSession: AUTH_SESSION.OIDC }))).resolves.toBe(true)+ expect(authProvider2FA.verifyUserPassword).not.toHaveBeenCalled()+ expect(authProvider2FA.verify).not.toHaveBeenCalled()+ })++ it('should keep TOTP verification for OIDC administrators with TOTP', async () => {+ authProvider2FA.loadUser.mockResolvedValue(adminWithTotp)+ mockVerifyResult(authProvider2FA, { success: true, message: '' })++ const context = makeContext({ [TWO_FA_HEADER_CODE]: '123456' }, { authSession: AUTH_SESSION.OIDC })++ await expect(guard.canActivate(context)).resolves.toBe(true)+ expect(authProvider2FA.verifyUserPassword).not.toHaveBeenCalled()+ expect(authProvider2FA.verify).toHaveBeenCalledWith({ code: '123456' }, context.switchToHttp().getRequest())+ })+it('should reject the request when the password fallback is missing', async () => {authProvider2FA.loadUser.mockResolvedValue(userWithoutTotp)@@ -114,10 +140,10 @@ function mockVerifyResult(authProvider2FA: DeepMocked<AuthProvider2FA>, result:;(authProvider2FA.verify as unknown as MockInstance<VerifyWithoutLogin>).mockResolvedValue(result)}-function makeContext(headers: Record<string, string> = {}): DeepMocked<ExecutionContext> {+function makeContext(headers: Record<string, string> = {}, user: Partial<UserModel> = {}): DeepMocked<ExecutionContext> {const context = createMock<ExecutionContext>()context.switchToHttp().getRequest.mockReturnValue({- user: { id: 1 },+ user: { id: 1, ...user },ip: '127.0.0.1',headers} as FastifyAuthenticatedRequest)diff --git a/backend/src/authentication/providers/two-fa/guards/auth-two-fa-verification.guard.ts b/backend/src/authentication/providers/two-fa/guards/auth-two-fa-verification.guard.tsindex 04c7597b..57da601b 100644--- a/backend/src/authentication/providers/two-fa/guards/auth-two-fa-verification.guard.ts+++ b/backend/src/authentication/providers/two-fa/guards/auth-two-fa-verification.guard.ts@@ -1,15 +1,22 @@import { CanActivate, ExecutionContext, HttpException, HttpStatus, Injectable, mixin, Type } from '@nestjs/common'+import { UserModel } from '../../../../applications/users/models/user.model'import { configuration } from '../../../../configuration/config.environment'import { TWO_FA_HEADER_CODE, TWO_FA_HEADER_PASSWORD } from '../../../constants/auth'import { FastifyAuthenticatedRequest } from '../../../interfaces/auth-request.interface'+import { AUTH_SESSION } from '../../auth-providers.constants'import { AuthProvider2FA } from '../auth-provider-two-fa.service'export const AuthTwoFaVerificationGuard = AuthTwoFaVerificationGuardFactory()export const AuthTwoFaVerificationWithoutPasswordGuard = AuthTwoFaVerificationGuardFactory({ withPassword: false })-export const AuthTwoFaVerificationOrPasswordGuard = AuthTwoFaVerificationGuardFactory({ passwordFallback: true, withPassword: false })+export const AuthTwoFaVerificationOrPasswordGuard = AuthTwoFaVerificationGuardFactory({+ passwordFallback: true,+ skipStepUpForOidcOnlyUser: true,+ withPassword: false+})interface TwoFaVerificationGuardOptions {passwordFallback?: boolean+ skipStepUpForOidcOnlyUser?: booleanwithPassword?: boolean}@@ -22,8 +29,13 @@ function AuthTwoFaVerificationGuardFactory(options: TwoFaVerificationGuardOptionconst req: FastifyAuthenticatedRequest = ctx.switchToHttp().getRequest()const user = await this.authProvider2FA.loadUser(req.user.id, req.ip)const twoFaEnabled = configuration.auth.mfa.totp.enabled && user.twoFaEnabled+ const passwordFallbackRequired = options.passwordFallback && !twoFaEnabled- if (options.withPassword || (options.passwordFallback && !twoFaEnabled)) {+ if (options.skipStepUpForOidcOnlyUser && canSkipStepUpForOidcOnlyUser(req.user, user)) {+ return true+ }++ if (options.withPassword || passwordFallbackRequired) {if (!req.headers[TWO_FA_HEADER_PASSWORD]) {throw new HttpException('Missing TWO-FA password', HttpStatus.FORBIDDEN)}@@ -50,3 +62,7 @@ function AuthTwoFaVerificationGuardFactory(options: TwoFaVerificationGuardOptionreturn mixin(MixinAuthTwoFaVerificationGuard)}++function canSkipStepUpForOidcOnlyUser(authUser: UserModel, user: UserModel): boolean {+ return authUser.authSession === AUTH_SESSION.OIDC && user.isUser && !user.isAdmin+}diff --git a/environment/environment.dist.yaml b/environment/environment.dist.yamlindex 4254734f..ea267320 100644--- a/environment/environment.dist.yaml+++ b/environment/environment.dist.yaml@@ -205,6 +205,7 @@ auth:# enablePasswordAuthFallback: Allow local password authentication for regular users when the LDAP service is unavailable.# Applies only to LDAP connection/DNS/timeout errors after all configured LDAP servers fail.# Always allowed for administrator users (break-glass access).+ # Administrator accounts should have a local Sync-in password configured and kept available for break-glass recovery.# default: falseenablePasswordAuthFallback: falseoidc:@@ -275,6 +276,7 @@ auth:# - application scopes (app passwords)# Regular users are allowed only when this option is enabled.# Users must already exist locally and have a password set.+ # Administrator accounts should have a local Sync-in password configured and kept available for break-glass recovery.# default: falseenablePasswordAuth: false# autoSyncAvatar: Automatically download and synchronize the user avatar from the OIDC `picture` claim.diff --git a/frontend/src/app/applications/users/components/dialogs/user-auth-manage-app-passwords-dialog.component.ts b/frontend/src/app/applications/users/components/dialogs/user-auth-manage-app-passwords-dialog.component.tsindex 2bd4d5c8..2bb37334 100644--- a/frontend/src/app/applications/users/components/dialogs/user-auth-manage-app-passwords-dialog.component.ts+++ b/frontend/src/app/applications/users/components/dialogs/user-auth-manage-app-passwords-dialog.component.ts@@ -65,10 +65,14 @@ export class UserAuthManageAppPasswordsDialogComponent {}async deleteAppPassword(passwordName: string) {- const auth2FaHeaders: false | HttpHeaders = await this.userService.auth2FaVerifyDialog(false, true)+ const auth2FaHeaders = await this.userService.authAppPasswordVerifyDialog()if (auth2FaHeaders === false) {return}+ this.deleteAppPasswordWithVerification(passwordName, auth2FaHeaders)+ }++ private deleteAppPasswordWithVerification(passwordName: string, auth2FaHeaders?: HttpHeaders) {this.userService.deleteAppPassword(passwordName, auth2FaHeaders).subscribe({next: () => {this.appPasswords = this.appPasswords.filter((pwd) => pwd.name !== passwordName)@@ -85,10 +89,14 @@ export class UserAuthManageAppPasswordsDialogComponent {return}}- const auth2FaHeaders: false | HttpHeaders = await this.userService.auth2FaVerifyDialog(false, true)+ const auth2FaHeaders = await this.userService.authAppPasswordVerifyDialog()if (auth2FaHeaders === false) {return}+ this.genAppPasswordWithVerification(auth2FaHeaders)+ }++ private genAppPasswordWithVerification(auth2FaHeaders?: HttpHeaders) {this.userService.generateAppPassword(this.appPasswordForm.value, auth2FaHeaders).subscribe({next: (appPassword: UserAppPassword) => {this.appPasswordForm.patchValue({ name: '', expiration: null })diff --git a/frontend/src/app/applications/users/components/user-account.component.html b/frontend/src/app/applications/users/components/user-account.component.htmlindex fac57953..249a6b02 100755--- a/frontend/src/app/applications/users/components/user-account.component.html+++ b/frontend/src/app/applications/users/components/user-account.component.html@@ -252,27 +252,29 @@<div class="card-body"><div class="text-muted text-uppercase fs-sm text-bold mb-2" l10nTranslate>Security</div><div class="d-flex flex-column gap-3">- <div class="row g-2 align-items-center">- <label for="" class="form-label col-12 col-md-6 mb-0" l10nTranslate>Two-Factor Authentication</label>- <div class="col-12 col-md-6 d-flex flex-wrap align-items-center gap-2">- <button (click)="enable2Fa()"- [disabled]="!store.server().twoFaEnabled"- class="btn btn-primary"- type="button"- l10nTranslate>- {{ user.twoFaEnabled ? 'Reset' : 'Enable' }}- </button>- @if (user.twoFaEnabled) {- <button (click)="disable2Fa()"+ @if (showTwoFaSettings) {+ <div class="row g-2 align-items-center">+ <label for="" class="form-label col-12 col-md-6 mb-0" l10nTranslate>Two-Factor Authentication</label>+ <div class="col-12 col-md-6 d-flex flex-wrap align-items-center gap-2">+ <button (click)="enable2Fa()"[disabled]="!store.server().twoFaEnabled"- class="btn btn-danger"+ class="btn btn-primary"type="button"l10nTranslate>- Disable+ {{ user.twoFaEnabled ? 'Reset' : 'Enable' }}</button>- }+ @if (user.twoFaEnabled) {+ <button (click)="disable2Fa()"+ [disabled]="!store.server().twoFaEnabled"+ class="btn btn-danger"+ type="button"+ l10nTranslate>+ Disable+ </button>+ }+ </div></div>- </div>+ }<div class="row g-2 align-items-center"><label for="" class="form-label col-12 col-md-6 mb-0" l10nTranslate>Application Passwords</label>diff --git a/frontend/src/app/applications/users/components/user-account.component.ts b/frontend/src/app/applications/users/components/user-account.component.tsindex 303459ca..9b315c0c 100644--- a/frontend/src/app/applications/users/components/user-account.component.ts+++ b/frontend/src/app/applications/users/components/user-account.component.ts@@ -11,6 +11,7 @@ import { USER_PASSWORD_MIN_LENGTH } from '@sync-in-server/backend/src/applicatioimport { UserAppPassword } from '@sync-in-server/backend/src/applications/users/interfaces/user-secrets.interface'import { WEBDAV_BASE_PATH } from '@sync-in-server/backend/src/applications/webdav/constants/routes'import { TWO_FA_HEADER_CODE, TWO_FA_HEADER_PASSWORD } from '@sync-in-server/backend/src/authentication/constants/auth'+import { AUTH_SESSION } from '@sync-in-server/backend/src/authentication/providers/auth-providers.constants'import type { TwoFaSetup } from '@sync-in-server/backend/src/authentication/providers/two-fa/auth-two-fa.interfaces'import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'import { BsModalRef } from 'ngx-bootstrap/modal'@@ -65,6 +66,7 @@ export class UserAccountComponent implements OnInit, OnDestroy {// passwordprotected oldPassword: stringprotected newPassword: string+ protected showTwoFaSettings = trueprotected readonly store = inject(StoreService)protected showEditorPreference = falseprotected userEditorPreference: keyof FileEditorProviders@@ -76,7 +78,12 @@ export class UserAccountComponent implements OnInit, OnDestroy {private subscriptions: Subscription[] = []constructor() {- this.subscriptions.push(this.store.user.subscribe((user: UserType) => (this.user = user)))+ this.subscriptions.push(+ this.store.user.subscribe((user: UserType) => {+ this.user = user+ this.showTwoFaSettings = !user || user.authSession !== AUTH_SESSION.OIDC || user.isAdmin+ })+ )this.subscriptions.push(this.store.userAvatarUrl.subscribe((avatarUrl) => (this.userAvatar = avatarUrl)))this.layout.setBreadcrumbIcon(USER_ICON.ACCOUNT)this.layout.setBreadcrumbNav({diff --git a/frontend/src/app/applications/users/user.service.ts b/frontend/src/app/applications/users/user.service.tsindex 7c90134d..a341a3e7 100644--- a/frontend/src/app/applications/users/user.service.ts+++ b/frontend/src/app/applications/users/user.service.ts@@ -46,6 +46,8 @@ import type {UserOnline} from '@sync-in-server/backend/src/applications/users/interfaces/websocket.interface'import { API_TWO_FA_ADMIN_RESET_USER, API_TWO_FA_DISABLE, API_TWO_FA_ENABLE } from '@sync-in-server/backend/src/authentication/constants/routes'+import type { LoginResponseDto } from '@sync-in-server/backend/src/authentication/dto/login-response.dto'+import { AUTH_SESSION } from '@sync-in-server/backend/src/authentication/providers/auth-providers.constants'import type { TwoFaVerifyWithPasswordDto } from '@sync-in-server/backend/src/authentication/providers/two-fa/auth-two-fa.dtos'import type {TwoFaEnableResult,@@ -67,7 +69,6 @@ import { GuestUserModel } from './models/guest.model'import { MemberModel } from './models/member.model'import { UserOnlineModel } from './models/user-online.model'import { myAvatarUrl } from './user.functions'-import type { LoginResponseDto } from '@sync-in-server/backend/src/authentication/dto/login-response.dto'type Auth2FaVerifyDialogResult = false | HttpHeaders | undefined@@ -316,12 +317,12 @@ export class UserService {return this.http.get<Omit<UserAppPassword, 'password'>[]>(API_USERS_MY_APP_PASSWORDS)}- generateAppPassword(userAppPasswordDto: UserAppPasswordDto, twoFaHeaders: HttpHeaders): Observable<UserAppPassword> {- return this.http.post<UserAppPassword>(API_USERS_MY_APP_PASSWORDS, userAppPasswordDto, { headers: twoFaHeaders })+ generateAppPassword(userAppPasswordDto: UserAppPasswordDto, twoFaHeaders?: HttpHeaders): Observable<UserAppPassword> {+ return this.http.post<UserAppPassword>(API_USERS_MY_APP_PASSWORDS, userAppPasswordDto, twoFaHeaders ? { headers: twoFaHeaders } : undefined)}- deleteAppPassword(name: string, twoFaHeaders: HttpHeaders): Observable<void> {- return this.http.delete<void>(`${API_USERS_MY_APP_PASSWORDS}/${name}`, { headers: twoFaHeaders })+ deleteAppPassword(name: string, twoFaHeaders?: HttpHeaders): Observable<void> {+ return this.http.delete<void>(`${API_USERS_MY_APP_PASSWORDS}/${name}`, twoFaHeaders ? { headers: twoFaHeaders } : undefined)}init2Fa(): Observable<TwoFaSetup> {@@ -340,6 +341,10 @@ export class UserService {return this.http.post<TwoFaVerifyResult>(`${API_TWO_FA_ADMIN_RESET_USER}/${userId}`, null, { headers: twoFaHeaders })}+ async authAppPasswordVerifyDialog(): Promise<Auth2FaVerifyDialogResult> {+ return this.canSkipAppPasswordStepUp(this.user) ? undefined : this.auth2FaVerifyDialog(false, true)+ }+async auth2FaVerifyDialog(withPassword: true, passwordFallback?: boolean): Promise<false | HttpHeaders>async auth2FaVerifyDialog(withPassword: false, passwordFallback: true): Promise<false | HttpHeaders>async auth2FaVerifyDialog(withPassword?: false, passwordFallback?: false): Promise<Auth2FaVerifyDialogResult>@@ -363,6 +368,10 @@ export class UserService {return undefined}+ private canSkipAppPasswordStepUp(user: UserType): boolean {+ return user?.authSession === AUTH_SESSION.OIDC && user.isUser && !user.isAdmin+ }+private checkQuota(user: UserType) {if (user.isGuest || user.isLink) returnif (user.storageQuota) {