Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(auth): restore OIDC step-up checks and local password setup

johavencb5789c8c890
diff --git a/backend/src/applications/users/services/users-manager.service.spec.ts b/backend/src/applications/users/services/users-manager.service.spec.ts
index 6cd2c999..0d737997 100755
--- a/backend/src/applications/users/services/users-manager.service.spec.ts
+++ b/backend/src/applications/users/services/users-manager.service.spec.ts
@@ -9,6 +9,7 @@ import { Readable } from 'node:stream'
import { AuthManager } from '../../../authentication/auth.service'
import { CACHE_AUTH_WEBDAV_PREFIX } from '../../../authentication/constants/cache'
import { AUTH_SCOPE } from '../../../authentication/constants/scope'
+import { AUTH_SESSION } from '../../../authentication/providers/auth-providers.constants'
import { comparePassword } from '../../../common/functions'
import * as imageModule from '../../../common/image'
import { pngMimeType, svgMimeType } from '../../../common/image'
@@ -161,12 +162,16 @@ describe(UsersManager.name, () => {
await expect(usersManager.me({ id: 0 } as UserModel)).rejects.toThrow()
usersQueriesService.from = vi.fn().mockResolvedValue(null)
await expect(usersManager.fromUserId(123)).resolves.toBeNull()
- const authUser = new UserModel({ ...generateUserTest(), id: 42, clientId: 'CID', impersonatedFromId: 1 } as any, true)
+ const authUser = new UserModel(
+ { ...generateUserTest(), id: 42, clientId: 'CID', authSession: AUTH_SESSION.OIDC, impersonatedFromId: 1 } as any,
+ true
+ )
const fromUser = new UserModel({ ...generateUserTest(), id: 42 }, true)
usersQueriesService.from = vi.fn().mockResolvedValue(fromUser)
const me2 = await usersManager.me(authUser)
expect(me2.user.impersonated).toBe(true)
expect(me2.user.clientId).toBe('CID')
+ expect(me2.user.authSession).toBe(AUTH_SESSION.OIDC)
})
it('should resolve token users from current database state', async () => {
@@ -176,6 +181,7 @@ describe(UsersManager.name, () => {
role: USER_ROLE.ADMINISTRATOR,
applications: Object.values(USER_PERMISSION),
clientId: 'client-id',
+ authSession: AUTH_SESSION.OIDC,
exp: 1234
} as any)
const currentUser = {
@@ -191,6 +197,7 @@ describe(UsersManager.name, () => {
expect(resolved.role).toBe(USER_ROLE.USER)
expect(resolved.applications).toEqual([USER_PERMISSION.SPACES])
expect(resolved.clientId).toBe('client-id')
+ expect(resolved.authSession).toBe(AUTH_SESSION.OIDC)
expect(resolved.exp).toBe(1234)
usersQueriesService.from = vi.fn().mockResolvedValue({ ...currentUser, isActive: false })
@@ -517,11 +524,22 @@ describe(UsersManager.name, () => {
usersQueriesService.selectUserProperties = vi.fn().mockResolvedValue({ password: 'HASH' })
vi.mocked(comparePassword).mockResolvedValue(false)
await expect(usersManager.updatePassword(userTest, { oldPassword: 'a', newPassword: 'b' })).rejects.toThrow('Password mismatch')
+ vi.mocked(comparePassword).mockClear()
+ await expect(usersManager.updatePassword(userTest, { oldPassword: 'same-password', newPassword: 'same-password' })).rejects.toThrow(
+ 'Password mismatch'
+ )
+ expect(comparePassword).toHaveBeenCalledWith('same-password', 'HASH')
vi.mocked(comparePassword).mockResolvedValue(true)
;(bcrypt.hash as unknown as Mock).mockResolvedValue('HASHED')
usersQueriesService.updateUserOrGuest = vi.fn().mockResolvedValue(true)
await expect(usersManager.updatePassword(userTest, { oldPassword: 'a', newPassword: 'b' })).resolves.toBeUndefined()
expect(usersQueriesService.updateUserOrGuest).toHaveBeenCalledWith(userTest.id, { password: 'HASHED' })
+ const oidcUser = new UserModel({ ...generateUserTest(), authSession: AUTH_SESSION.OIDC } as any, false)
+ vi.mocked(comparePassword).mockClear()
+ ;(bcrypt.hash as unknown as Mock).mockResolvedValue('OIDC_HASHED')
+ await expect(usersManager.updatePassword(oidcUser, { oldPassword: 'local-password', newPassword: 'local-password' })).resolves.toBeUndefined()
+ expect(comparePassword).not.toHaveBeenCalled()
+ expect(usersQueriesService.updateUserOrGuest).toHaveBeenCalledWith(oidcUser.id, { password: 'OIDC_HASHED' })
usersQueriesService.updateUserOrGuest = vi.fn().mockResolvedValue(false)
usersQueriesService.selectUserProperties = vi.fn().mockResolvedValue({ password: 'HASH' })
vi.mocked(comparePassword).mockResolvedValue(true)
diff --git a/backend/src/applications/users/services/users-manager.service.ts b/backend/src/applications/users/services/users-manager.service.ts
index 64df4d85..f70cb19d 100755
--- a/backend/src/applications/users/services/users-manager.service.ts
+++ b/backend/src/applications/users/services/users-manager.service.ts
@@ -10,6 +10,7 @@ import { AUTH_SCOPE } from '../../../authentication/constants/scope'
import { LoginResponseDto } from '../../../authentication/dto/login-response.dto'
import { FastifyAuthenticatedRequest } from '../../../authentication/interfaces/auth-request.interface'
import { JwtIdentityPayload } from '../../../authentication/interfaces/jwt-payload.interface'
+import { AUTH_SESSION } from '../../../authentication/providers/auth-providers.constants'
import { ACTION } from '../../../common/constants'
import { comparePassword, hashPassword } from '../../../common/functions'
import { convertTempImageToPng, generateAvatar, imgMimeTypePrefix, pngMimeType, svgMimeType } from '../../../common/image'
@@ -193,7 +194,8 @@ export class UsersManager {
if (!r) {
throw new HttpException('Unable to check password', HttpStatus.NOT_FOUND)
}
- if (!(await comparePassword(userPasswordDto.oldPassword, r.password))) {
+ const canSetLocalPasswordFromOIDC = user.authSession === AUTH_SESSION.OIDC && userPasswordDto.oldPassword === userPasswordDto.newPassword
+ if (!canSetLocalPasswordFromOIDC && !(await comparePassword(userPasswordDto.oldPassword, r.password))) {
throw new HttpException('Password mismatch', HttpStatus.BAD_REQUEST)
}
const hash = await bcrypt.hash(userPasswordDto.newPassword, 10)
diff --git a/backend/src/authentication/auth.md b/backend/src/authentication/auth.md
index d0c9fb99..333be2da 100644
--- a/backend/src/authentication/auth.md
+++ b/backend/src/authentication/auth.md
@@ -120,10 +120,7 @@ scopes.
### 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
+Generating and revoking app passwords are self-service actions protected by the usual Sync-in step-up: TOTP when enabled, otherwise local password
confirmation.
### WebDAV and TOTP
@@ -161,8 +158,10 @@ should therefore have a local Sync-in password configured and kept available for
OIDC browser login delegates the primary authentication and MFA policy to the identity provider. Sync-in does not add its local TOTP challenge after a
successful OIDC callback. Local password paths can still exist with OIDC selected for guests, administrators, scoped application authentication, and
-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`.
+regular users when explicitly enabled. OIDC-created users can set a known local password from their profile while authenticated through OIDC, for
+local password access or password-fallback step-up. Users authenticated through OIDC can also configure Sync-in TOTP from their profile; enable,
+reset, and disable flows still verify the local Sync-in password. 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 attempts
diff --git a/backend/src/authentication/auth.service.spec.ts b/backend/src/authentication/auth.service.spec.ts
index 175aa557..c1e342c5 100755
--- a/backend/src/authentication/auth.service.spec.ts
+++ b/backend/src/authentication/auth.service.spec.ts
@@ -3,6 +3,7 @@ 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 { currentTimeStamp } from '../common/shared'
import { AuthManager } from './auth.service'
import { AUTH_SESSION } from './providers/auth-providers.constants'
@@ -50,4 +51,29 @@ describe(AuthManager.name, () => {
expect.any(Object)
)
})
+
+ it('should preserve the authentication method when refreshing cookies', async () => {
+ const user = new UserModel({
+ id: 1,
+ login: 'alice',
+ email: '[email protected]',
+ firstName: 'Alice',
+ lastName: 'Doe',
+ language: 'en',
+ role: USER_ROLE.USER,
+ authSession: AUTH_SESSION.OIDC,
+ exp: currentTimeStamp() + 3600
+ } as any)
+ const res = { setCookie: vi.fn() }
+
+ const response = await authManager.refreshCookies(user, res as any)
+
+ 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/providers/oidc/oidc.md b/backend/src/authentication/providers/oidc/oidc.md
index df79953c..0f1b5b06 100644
--- a/backend/src/authentication/providers/oidc/oidc.md
+++ b/backend/src/authentication/providers/oidc/oidc.md
@@ -124,6 +124,9 @@ When `autoCreateUser` is enabled, a first successful login creates a local user
- the mapped administrator role and storage quota, when present;
- an internal random password required by the local user model but not used for OIDC authentication.
+Users authenticated through OIDC can later set a known local password from their profile. That password can be used for local password authentication
+when enabled, and for password-fallback step-up when no TOTP secret is active.
+
When automatic creation is disabled, authentication succeeds only for an already linked account or a compatible existing account found by email.
For an existing user, each successful OIDC login can synchronize:
@@ -178,7 +181,8 @@ Downloads from private or internal IP ranges are blocked by default to limit ser
## Local password authentication and MFA
OIDC 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 should enforce MFA, when needed, in the IdP policy assigned to the Sync-in client or application.
+callback. Users can still configure Sync-in TOTP from their profile while authenticated through OIDC; enable, reset, and disable flows verify the local
+Sync-in password. 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 identity
binding or profile synchronization.
@@ -190,6 +194,9 @@ 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.
+OIDC-created users start with an internal random password. To use local password authentication later, or password-fallback step-up when no TOTP
+secret is active, they must first set a known local password from their profile while authenticated through OIDC.
+
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.
@@ -200,11 +207,7 @@ Scoped application authentication is non-interactive and does not invoke a TOTP
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.
+Self-service app-password generation and revocation require the usual Sync-in step-up: TOTP when enabled, otherwise local password confirmation.
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 an
existing 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.ts
index 793c587e..fcd946ea 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
@@ -18,9 +18,6 @@ describe(AuthTwoFaVerificationOrPasswordGuard.name, () => {
const originalTotpEnabled = configuration.auth.mfa.totp.enabled
const userWithTotp = { id: 1, twoFaEnabled: true } as UserModel
const 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 UserModel
let guard: CanActivate
let authProvider2FA: DeepMocked<AuthProvider2FA>
@@ -60,6 +57,20 @@ describe(AuthTwoFaVerificationOrPasswordGuard.name, () => {
expect(authProvider2FA.verify).toHaveBeenCalledWith({ code: '123456' }, context.switchToHttp().getRequest())
})
+ it('should not skip step-up verification for OIDC sessions', async () => {
+ authProvider2FA.loadUser.mockResolvedValueOnce(userWithTotp).mockResolvedValueOnce(userWithoutTotp)
+ authProvider2FA.verifyUserPassword.mockResolvedValue(undefined)
+ mockVerifyResult(authProvider2FA, { success: true, message: '' })
+
+ const totpContext = makeContext({ [TWO_FA_HEADER_CODE]: '123456' }, { authSession: AUTH_SESSION.OIDC })
+ await expect(guard.canActivate(totpContext)).resolves.toBe(true)
+ expect(authProvider2FA.verify).toHaveBeenCalledWith({ code: '123456' }, totpContext.switchToHttp().getRequest())
+
+ await expect(guard.canActivate(makeContext({ [TWO_FA_HEADER_PASSWORD]: 'password' }, { authSession: AUTH_SESSION.OIDC }))).resolves.toBe(true)
+ expect(authProvider2FA.verifyUserPassword).toHaveBeenCalledWith(userWithoutTotp, 'password', '127.0.0.1')
+ expect(authProvider2FA.verify).toHaveBeenCalledTimes(1)
+ })
+
it('should require the current password instead of TOTP when the user has no TOTP enabled', async () => {
authProvider2FA.loadUser.mockResolvedValue(userWithoutTotp)
authProvider2FA.verifyUserPassword.mockResolvedValue(undefined)
@@ -79,28 +90,6 @@ 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)
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.ts
index 57da601b..c1919cc4 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,22 +1,15 @@
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,
- skipStepUpForOidcOnlyUser: true,
- withPassword: false
-})
+export const AuthTwoFaVerificationOrPasswordGuard = AuthTwoFaVerificationGuardFactory({ passwordFallback: true, withPassword: false })
interface TwoFaVerificationGuardOptions {
passwordFallback?: boolean
- skipStepUpForOidcOnlyUser?: boolean
withPassword?: boolean
}
@@ -31,10 +24,6 @@ function AuthTwoFaVerificationGuardFactory(options: TwoFaVerificationGuardOption
const twoFaEnabled = configuration.auth.mfa.totp.enabled && user.twoFaEnabled
const passwordFallbackRequired = 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)
@@ -62,7 +51,3 @@ function AuthTwoFaVerificationGuardFactory(options: TwoFaVerificationGuardOption
return mixin(MixinAuthTwoFaVerificationGuard)
}
-
-function canSkipStepUpForOidcOnlyUser(authUser: UserModel, user: UserModel): boolean {
- return authUser.authSession === AUTH_SESSION.OIDC && user.isUser && !user.isAdmin
-}
diff --git a/backend/src/authentication/providers/two-fa/two-fa.md b/backend/src/authentication/providers/two-fa/two-fa.md
index cd78574c..a5630257 100644
--- a/backend/src/authentication/providers/two-fa/two-fa.md
+++ b/backend/src/authentication/providers/two-fa/two-fa.md
@@ -53,6 +53,9 @@ The route is authenticated and limited to regular users. It returns:
Sync-in stores the pending setup secret in cache for five minutes. The response disables caching with `Cache-Control: no-store`.
+Users whose browser session was created through OIDC can open this setup flow from their profile. The final enable or reset request still verifies the
+current local Sync-in password; OIDC-created users must set a known local password first.
+
The user completes setup with:
```text
@@ -126,9 +129,6 @@ sync-in-two-fa-code
When global TOTP is disabled, or when the loaded user has no TOTP secret, guards that allow password fallback use the current local password instead
of a TOTP code. Guards without password fallback simply allow the request when TOTP is inactive.
-Regular users whose current browser session was created through OIDC can skip the app-password step-up guard. Administrators cannot skip it; an OIDC
-administrator with TOTP enabled must still pass TOTP verification for app-password step-up.
-
## API tokens and client registration
Bearer tokens are requested with:
diff --git a/environment/environment.dist.yaml b/environment/environment.dist.yaml
index ea267320..22e2928f 100644
--- a/environment/environment.dist.yaml
+++ b/environment/environment.dist.yaml
@@ -210,7 +210,8 @@ auth:
enablePasswordAuthFallback: false
oidc:
# OIDC authentication, including MFA, is delegated to the identity provider.
- # Sync-in TOTP applies only to local password authentication.
+ # Sync-in TOTP login enforcement applies only to local password authentication.
+ # Users can configure Sync-in TOTP from their profile while authenticated through OIDC; enable/reset/disable still verifies the local Sync-in password.
# Users are resolved by the OIDC `sub` first, then by email only when no external identity is linked yet.
# The first successful email match stores `sub` as the user's external identity for subsequent logins.
# `preferred_username` initializes the local login for a new user. A deterministic `sub`-based suffix resolves collisions.
@@ -274,8 +275,9 @@ auth:
# - guest users
# - administrator users (break-glass access)
# - application scopes (app passwords)
- # Regular users are allowed only when this option is enabled.
- # Users must already exist locally and have a password set.
+ # For this local login flow, regular users are allowed only when this option is enabled and they know their local Sync-in password.
+ # Users created through OIDC can set a known local password from their profile while authenticated with OIDC.
+ # That local password is also required to enable, reset, or disable Sync-in TOTP from an OIDC browser session.
# Administrator accounts should have a local Sync-in password configured and kept available for break-glass recovery.
# default: false
enablePasswordAuth: false
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.ts
index 2bb37334..2bd4d5c8 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,14 +65,10 @@ export class UserAuthManageAppPasswordsDialogComponent {
}
async deleteAppPassword(passwordName: string) {
- const auth2FaHeaders = await this.userService.authAppPasswordVerifyDialog()
+ const auth2FaHeaders: false | HttpHeaders = await this.userService.auth2FaVerifyDialog(false, true)
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)
@@ -89,14 +85,10 @@ export class UserAuthManageAppPasswordsDialogComponent {
return
}
}
- const auth2FaHeaders = await this.userService.authAppPasswordVerifyDialog()
+ const auth2FaHeaders: false | HttpHeaders = await this.userService.auth2FaVerifyDialog(false, true)
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.html
index 249a6b02..87f2405d 100755
--- a/frontend/src/app/applications/users/components/user-account.component.html
+++ b/frontend/src/app/applications/users/components/user-account.component.html
@@ -214,19 +214,23 @@
}
</div>
<div class="d-flex flex-column gap-2">
- <div class="row g-2 align-items-center">
- <label for="" class="form-label col-12 col-md-6 mb-0">{{ 'current password' | translate:locale.language | capitalize }}</label>
- <div class="col-12 col-md-6">
- <app-input-password [(password)]="oldPassword"></app-input-password>
+ @if (requiresCurrentPassword) {
+ <div class="row g-2 align-items-center">
+ <label for="" class="form-label col-12 col-md-6 mb-0">{{ 'current password' | translate:locale.language | capitalize }}</label>
+ <div class="col-12 col-md-6">
+ <app-input-password [(password)]="oldPassword"></app-input-password>
+ </div>
</div>
- </div>
+ }
<div class="row g-2 align-items-center">
- <label for="" class="form-label col-12 col-md-6 mb-0">{{ 'new password' | translate:locale.language | capitalize }}</label>
+ <label for="" class="form-label col-12 col-md-6 mb-0">
+ {{ (requiresCurrentPassword ? 'new password' : 'local password') | translate:locale.language | capitalize }}
+ </label>
<div class="col-12 col-md-6">
<app-input-password [(password)]="newPassword"
- [disabled]="!oldPassword?.length"
- [isRequired]="!!oldPassword?.length"
+ [disabled]="requiresCurrentPassword && !oldPassword?.length"
+ [isRequired]="requiresCurrentPassword && !!oldPassword?.length"
[passwordMinLength]="passwordMinLength"
[showGenerator]="true">
</app-input-password>
@@ -235,7 +239,7 @@
<div class="row g-2">
<div class="col-12 col-md-6 offset-md-6">
- <button [disabled]="!newPassword || !oldPassword || newPassword.length < passwordMinLength"
+ <button [disabled]="!newPassword || (requiresCurrentPassword && !oldPassword) || newPassword.length < passwordMinLength"
(click)="submitPassword()"
class="btn btn-primary text-nowrap"
type="button"
@@ -252,29 +256,27 @@
<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">
- @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()"
+ <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()"
[disabled]="!store.server().twoFaEnabled"
- class="btn btn-primary"
+ class="btn btn-danger"
type="button"
l10nTranslate>
- {{ user.twoFaEnabled ? 'Reset' : 'Enable' }}
+ Disable
</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.ts
index 9b315c0c..636c3d25 100644
--- a/frontend/src/app/applications/users/components/user-account.component.ts
+++ b/frontend/src/app/applications/users/components/user-account.component.ts
@@ -66,7 +66,6 @@ export class UserAccountComponent implements OnInit, OnDestroy {
// password
protected oldPassword: string
protected newPassword: string
- protected showTwoFaSettings = true
protected readonly store = inject(StoreService)
protected showEditorPreference = false
protected userEditorPreference: keyof FileEditorProviders
@@ -78,12 +77,7 @@ export class UserAccountComponent implements OnInit, OnDestroy {
private subscriptions: Subscription[] = []
constructor() {
- 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.user.subscribe((user: UserType) => (this.user = user)))
this.subscriptions.push(this.store.userAvatarUrl.subscribe((avatarUrl) => (this.userAvatar = avatarUrl)))
this.layout.setBreadcrumbIcon(USER_ICON.ACCOUNT)
this.layout.setBreadcrumbNav({
@@ -121,6 +115,10 @@ export class UserAccountComponent implements OnInit, OnDestroy {
})
}
+ get requiresCurrentPassword() {
+ return this.user?.authSession !== AUTH_SESSION.OIDC
+ }
+
ngOnInit() {
this.userService.refreshUser()
}
@@ -142,7 +140,7 @@ export class UserAccountComponent implements OnInit, OnDestroy {
}
async submitPassword() {
- if (!this.oldPassword) {
+ if (this.requiresCurrentPassword && !this.oldPassword) {
this.layout.sendNotification('error', 'Configuration', 'Current password missing !')
return
}
@@ -158,7 +156,8 @@ export class UserAccountComponent implements OnInit, OnDestroy {
if (auth2FaHeaders === false) {
return
}
- this.userService.changePassword({ oldPassword: this.oldPassword, newPassword: this.newPassword }, auth2FaHeaders).subscribe({
+ const oldPassword = this.requiresCurrentPassword ? this.oldPassword : this.newPassword
+ this.userService.changePassword({ oldPassword, newPassword: this.newPassword }, auth2FaHeaders).subscribe({
next: () => {
this.oldPassword = ''
this.newPassword = ''
diff --git a/frontend/src/app/applications/users/user.service.ts b/frontend/src/app/applications/users/user.service.ts
index a341a3e7..edeec8ed 100644
--- a/frontend/src/app/applications/users/user.service.ts
+++ b/frontend/src/app/applications/users/user.service.ts
@@ -47,7 +47,6 @@ import type {
} 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,
@@ -317,12 +316,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, twoFaHeaders ? { headers: twoFaHeaders } : undefined)
+ generateAppPassword(userAppPasswordDto: UserAppPasswordDto, twoFaHeaders: HttpHeaders): Observable<UserAppPassword> {
+ return this.http.post<UserAppPassword>(API_USERS_MY_APP_PASSWORDS, userAppPasswordDto, { headers: twoFaHeaders })
}
- deleteAppPassword(name: string, twoFaHeaders?: HttpHeaders): Observable<void> {
- return this.http.delete<void>(`${API_USERS_MY_APP_PASSWORDS}/${name}`, twoFaHeaders ? { headers: twoFaHeaders } : undefined)
+ deleteAppPassword(name: string, twoFaHeaders: HttpHeaders): Observable<void> {
+ return this.http.delete<void>(`${API_USERS_MY_APP_PASSWORDS}/${name}`, { headers: twoFaHeaders })
}
init2Fa(): Observable<TwoFaSetup> {
@@ -341,10 +340,6 @@ 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>
@@ -368,10 +363,6 @@ 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) return
if (user.storageQuota) {
diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.json
index 99603a84..c45e9af4 100644
--- a/frontend/src/i18n/de.json
+++ b/frontend/src/i18n/de.json
@@ -162,6 +162,7 @@
"Update": "Aktualisieren",
"current password": "aktuelles Passwort",
"new password": "neues Passwort",
+ "local password": "lokales Passwort",
"Change me !": "Ändern Sie mich!",
"Current password missing !": "Aktuelles Passwort fehlt!",
"New password missing !": "Neues Passwort fehlt!",
diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.json
index 2adcca80..fe94d839 100644
--- a/frontend/src/i18n/es.json
+++ b/frontend/src/i18n/es.json
@@ -162,6 +162,7 @@
"Update": "Actualizar",
"current password": "contraseña actual",
"new password": "nueva contraseña",
+ "local password": "contraseña local",
"Change me !": "¡Cámbiame!",
"Current password missing !": "¡Falta la contraseña actual!",
"New password missing !": "¡Falta la nueva contraseña!",
diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.json
index 4d383ce8..415f33e6 100644
--- a/frontend/src/i18n/fr.json
+++ b/frontend/src/i18n/fr.json
@@ -162,6 +162,7 @@
"Update": "Mettre à jour",
"current password": "mot de passe actuel",
"new password": "nouveau mot de passe",
+ "local password": "mot de passe local",
"Change me !": "Changez moi !",
"Current password missing !": "Mot de passe actuel manquant !",
"New password missing !": "Nouveau mot de passe manquant !",
diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.json
index 00da11ed..e7d5c31b 100644
--- a/frontend/src/i18n/hi.json
+++ b/frontend/src/i18n/hi.json
@@ -162,6 +162,7 @@
"Update": "अपडेट करें",
"current password": "वर्तमान पासवर्ड",
"new password": "नया पासवर्ड",
+ "local password": "स्थानीय पासवर्ड",
"Change me !": "मुझे बदलें!",
"Current password missing !": "वर्तमान पासवर्ड अनुपस्थित है!",
"New password missing !": "नया पासवर्ड अनुपस्थित है!",
diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.json
index 426f62a7..61f9d62a 100644
--- a/frontend/src/i18n/it.json
+++ b/frontend/src/i18n/it.json
@@ -162,6 +162,7 @@
"Update": "Aggiorna",
"current password": "password attuale",
"new password": "nuova password",
+ "local password": "password locale",
"Change me !": "Cambiami!",
"Current password missing !": "Password attuale mancante!",
"New password missing !": "Nuova password mancante!",
diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.json
index 235374ad..92042048 100644
--- a/frontend/src/i18n/ja.json
+++ b/frontend/src/i18n/ja.json
@@ -162,6 +162,7 @@
"Update": "更新",
"current password": "現在のパスワード",
"new password": "新しいパスワード",
+ "local password": "ローカルパスワード",
"Change me !": "変更してください!",
"Current password missing !": "現在のパスワードが未入力です!",
"New password missing !": "新しいパスワードが未入力です!",
diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.json
index d5c58892..9c769b76 100644
--- a/frontend/src/i18n/ko.json
+++ b/frontend/src/i18n/ko.json
@@ -162,6 +162,7 @@
"Update": "업데이트",
"current password": "현재 비밀번호",
"new password": "새 비밀번호",
+ "local password": "로컬 비밀번호",
"Change me !": "변경해 주세요!",
"Current password missing !": "현재 비밀번호가 입력되지 않았습니다!",
"New password missing !": "새 비밀번호가 입력되지 않았습니다!",
diff --git a/frontend/src/i18n/nl.json b/frontend/src/i18n/nl.json
index 108a5596..e59c574e 100644
--- a/frontend/src/i18n/nl.json
+++ b/frontend/src/i18n/nl.json
@@ -162,6 +162,7 @@
"Update": "Bijwerken",
"current password": "huidig wachtwoord",
"new password": "nieuw wachtwoord",
+ "local password": "lokaal wachtwoord",
"Change me !": "Pas mij aan!",
"Current password missing !": "Huidig wachtwoord ontbreekt!",
"New password missing !": "Nieuw wachtwoord ontbreekt!",
diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.json
index 52c437a5..706b95e3 100644
--- a/frontend/src/i18n/pl.json
+++ b/frontend/src/i18n/pl.json
@@ -162,6 +162,7 @@
"Update": "Zaktualizuj",
"current password": "aktualne hasło",
"new password": "nowe hasło",
+ "local password": "hasło lokalne",
"Change me !": "Zmień mnie!",
"Current password missing !": "Brak aktualnego hasła!",
"New password missing !": "Brak nowego hasła!",
diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.json
index 92abf8b1..6eef57a5 100644
--- a/frontend/src/i18n/pt-BR.json
+++ b/frontend/src/i18n/pt-BR.json
@@ -162,6 +162,7 @@
"Update": "Atualizar",
"current password": "senha atual",
"new password": "nova senha",
+ "local password": "senha local",
"Change me !": "Mude-me!",
"Current password missing !": "Senha atual ausente!",
"New password missing !": "Nova senha ausente!",
diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.json
index c5fb32fc..d5995764 100644
--- a/frontend/src/i18n/pt.json
+++ b/frontend/src/i18n/pt.json
@@ -162,6 +162,7 @@
"Update": "Atualizar",
"current password": "senha atual",
"new password": "nova senha",
+ "local password": "senha local",
"Change me !": "Mude-me!",
"Current password missing !": "Senha atual ausente!",
"New password missing !": "Nova senha ausente!",
diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.json
index abe35874..fc97124c 100644
--- a/frontend/src/i18n/ru.json
+++ b/frontend/src/i18n/ru.json
@@ -162,6 +162,7 @@
"Update": "Обновить",
"current password": "текущий пароль",
"new password": "новый пароль",
+ "local password": "локальный пароль",
"Change me !": "Измените меня!",
"Current password missing !": "Не указан текущий пароль!",
"New password missing !": "Не указан новый пароль!",
diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.json
index 0bdb3aeb..9d693c9f 100644
--- a/frontend/src/i18n/tr.json
+++ b/frontend/src/i18n/tr.json
@@ -162,6 +162,7 @@
"Update": "Güncelle",
"current password": "mevcut parola",
"new password": "yeni parola",
+ "local password": "yerel parola",
"Change me !": "Beni değiştir!",
"Current password missing !": "Mevcut parola eksik!",
"New password missing !": "Yeni parola eksik!",
diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.json
index f07d7675..f24a611f 100644
--- a/frontend/src/i18n/zh.json
+++ b/frontend/src/i18n/zh.json
@@ -162,6 +162,7 @@
"Update": "更新",
"current password": "当前密码",
"new password": "新密码",
+ "local password": "本地密码",
"Change me !": "请修改我!",
"Current password missing !": "缺少当前密码!",
"New password missing !": "缺少新密码!",