Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-133624 / 25.10 / Support for single time user passwords in STIG mode #11427

Merged
merged 13 commits into from
Jan 30, 2025

Conversation

AlexKarpov98
Copy link
Contributor

See ticket.

Result:

NAS-133624_1.mov
NAS-133624-2.mov

@AlexKarpov98 AlexKarpov98 self-assigned this Jan 28, 2025
@bugclerk bugclerk changed the title NAS-133624: Support for single time user passwords in STIG mode NAS-133624 / 25.10 / Support for single time user passwords in STIG mode Jan 28, 2025
@bugclerk
Copy link
Contributor

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

Attention: Patch coverage is 97.19626% with 6 lines in your changes missing coverage. Please review.

Project coverage is 83.29%. Comparing base (ff7fb2c) to head (6c95183).
Report is 2 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...credentials/users/user-form/user-form.component.ts 94.25% 5 Missing ⚠️
src/app/modules/auth/auth.service.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11427      +/-   ##
==========================================
+ Coverage   83.22%   83.29%   +0.06%     
==========================================
  Files        1673     1676       +3     
  Lines       59987    60116     +129     
  Branches     6308     6323      +15     
==========================================
+ Hits        49927    50073     +146     
+ Misses      10060    10043      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks promising, nice work. Will test after code updates.

src/app/modules/auth/auth.service.ts Outdated Show resolved Hide resolved
@@ -70,4 +82,17 @@ export class TwoFactorGuardService implements CanActivateChild {
}),
);
}

private showStigFirstLoginDialog(): Observable<boolean> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I would avoid stig in naming here because it's conceivable that this feature may be extended for other scenarios in the future.
  2. How about unifying the flow so that FirstLoginDialogComponent is always shown when it's either otpw user or 2FA setup is needed? And then letting FirstLoginDialogComponent decide which steps to show.

Copy link
Contributor Author

@AlexKarpov98 AlexKarpov98 Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@undsoft
We have such modal as well, if user missed 2fa configuration:

Screenshot 2025-01-29 at 13 41 00

And then navigated to the 2fa setup page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@undsoft - for STIG user, it's impossible to login without one time password or 2fa.
So if I changed password but didn't set up 2fa, I'll see the following.

Screenshot 2025-01-29 at 13 43 31

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I've updated this dialog to work for both:
OtpwUser and NonOtpwUser, but it's useless at this point.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is that we can get rid of showTwoFactorWarning() and only have one branch. If this is an OTPW user OR if 2FA setup is required for normal user, take them to FirstLoginDialogComponent.
If this is an OTPW user, show password form, if this is a normal user, only show the 2FA part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, got it, probably I need to add more descriptions there as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we request it as a separate ticket? I think it worth a separate ticket since a lot of changes were made already as for this one ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make your code simpler, but okay, please create a ticket then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 👌

@@ -39,6 +39,7 @@ import { adminUiInitialized } from 'app/store/admin-panel/admin.actions';
export class AuthService {
@LocalStorage() private token: string | undefined | null;
protected loggedInUser$ = new BehaviorSubject<LoggedInUser | null>(null);
isOptwPasswordChanged$ = new BehaviorSubject<boolean>(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kinda weird to have this here so that two other pieces of code can talk to each other.
See if it's possible to inject TwoFactorGuardService in FirstLoginDialogComponent directly and have that property there directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@undsoft I tried to move it to the TwoFactorGuardService but faced issues.
The main issue is that we should reset that value if user logs out, because if it's a new login with OTPW - the full screen dialog will not show up since password is considered as already changed.

src/app/interfaces/user.interface.ts Outdated Show resolved Hide resolved
src/app/pages/two-factor-auth/two-factor.component.ts Outdated Show resolved Hide resolved
@AlexKarpov98
Copy link
Contributor Author

@undsoft - use latest middleware to make sure it all works.

@AlexKarpov98 AlexKarpov98 marked this pull request as ready for review January 29, 2025 11:50
@AlexKarpov98 AlexKarpov98 requested a review from a team as a code owner January 29, 2025 11:50
@AlexKarpov98 AlexKarpov98 requested review from bvasilenko and undsoft and removed request for a team January 29, 2025 11:50
Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@AlexKarpov98 AlexKarpov98 merged commit 33d4cdf into master Jan 30, 2025
11 checks passed
@AlexKarpov98 AlexKarpov98 deleted the NAS-133624 branch January 30, 2025 07:01
@bugclerk
Copy link
Contributor

JIRA ticket https://ixsystems.atlassian.net/browse/NAS-133624 is targeted to the following versions which have not received their corresponding PRs: 25.04-RC.1

@bugclerk
Copy link
Contributor

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Jan 30, 2025
@AlexKarpov98 AlexKarpov98 added the backport-25.04-RC.1 Fangtooth RC1 label Jan 30, 2025
@AlexKarpov98
Copy link
Contributor Author

backport

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants