← Back to Pull requests

Check password requirements on login #427

Open
mgaffigan opened this pull request with 94 lines diff across 2 files
View on GitHub
mgaffigan mgaffigan commented on Aug 29, 2026 19:59 UTC
Author

Changing password requirements does not affect current users. This PR modifies the login process to check requirements and handle them the same as password expiration, using the existing grace period functionality.

<img width="521" height="318" alt="image" src="https://github.com/user-attachments/assets/9c2013a1-7b10-4174-acbd-4c2ca9f8ea19" />

Note: command does not seem to handle expired passwords well.

Note to reviewers: Most of this change-set is whitespace changes due to indentation. See https://github.com/OpenIntegrationEngine/engine/pull/427/changes?w=1

Diff: 94 lines (+55 / -39) across 2 files Reviewer: NicoPiel Review duration: 109519m
All Vouch review confidence checks passed
Residual risk 0.08 = Change Risk (0.39) × (1 − Review Confidence (0.79)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 94 lines diff across 2 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.72 · 5 substantive comment(s)
0.72
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
79%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.272
Real PR Conversation Timeline
8 items
github-actions[bot] github-actions[bot] commented on Aug 29, 2026 20:04 UTC
Bot

Test Results


675 tests  ±0   675 ✅ ±0   2m 1s ⏱️ + 1m 7s
114 suites ±0     0 💤 ±0 
114 files   ±0     0 ❌ ±0 

Results for commit 0cf7b7fe. ± Comparison against base commit 423df182.

[test-results]:data:application/gzip;base64,H4sIAEE7k2oC/13MSw6DIBSF4a0Yxh1wrYjtZhq5cBNSlYbHyHTvBfsQO/y/k5yVkZ1MYNcGoDs1LCQbq9TJj9G6pUALGfIYy9xL8a1bSIj/dLePTPwHNNrpAMZ75z/i07J/ljhevmV/3Lo63Lr+QzfPNuZgHEkqSaYFpQ1ILjXQoHs05wFRdRcAIUhxYs8XbdALawkBAAA=

NicoPiel NicoPiel approved these changes on Aug 29, 2026 22:05 UTC
Approved Reviewer

Approved these changes.

pacmano1 pacmano1 commented on Aug 29, 2026 23:57 UTC
Contributor

What does this do when I try to grab a token to make API calls? If it denies the token, we need to work through that.

mgaffigan mgaffigan commented on Aug 31, 2026 14:08 UTC
Author

@pacmano1

What does this do when I try to grab a token to make API calls? If it denies the token, we need to work through that.

Nothing in the above limits logins, it just returns the flag that the password needs to be changed in the response to the login. Exactly the same as an "expired" password.

gibson9583 gibson9583 commented on Sep 03, 2026 21:04 UTC
Contributor

@pacmano1

> > What does this do when I try to grab a token to make API calls? If it denies the token, we need to work through that.

> Nothing in the above limits logins, it just returns the flag that the password needs to be changed in the response to the login. Exactly the same as an "expired" password.

@mgaffigan are you sure? wont this affect a few things:

1. CLI - anything that isnt a plain SUCCESS gets a cant log into server.
2. grace period - with a >0 grace period or a -1 grace period, it can cause lockouts (but that may be OK, but contradicts your statement)

mgaffigan mgaffigan commented on Sep 06, 2026 18:41 UTC
Author

@gibson9583

@mgaffigan are you sure? wont this affect a few things:

I'm sure that it uses the exact same response and grace period as an expired password. No new response statuses were added, nor any new grace period logic.

1. CLI - anything that isnt a plain SUCCESS gets a cant log into server.

Agreed, that seems like a bug in CLI. It is the current expired password behavior, though.

2. grace period - with a >0 grace period or a -1 grace period, it can cause lockouts

Agreed, but those have to be manually configured, and is the existing behavior of expired passwords.

tonygermano tonygermano commented on code on Oct 06, 2026 23:21 UTC
Code Review
server/src/main/java/com/mirth/connect/server/controllers/DefaultUserController.java:1
@@ -333,51 +333,61 @@ public LoginStatus authorizeUser(String username, String plainPassword, String s
             LoginStatus loginStatus = null;
 
             if (authorized) {
+                long currentTime = System.currentTimeMillis();
+                String changeReason = null;
+
                 // If password expiration is enabled, do checks now
-                if (passwordRequirements.getExpiration() > 0) {
-                    long passwordTime = credentials.getPasswordDate().getTimeInMillis();
-                    long currentTime = System.currentTimeMillis();
-
-                    // If the password is expired, do grace period checks
-                    if (loginRequirementsChecker.isPasswordExpired(passwordTime, currentTime)) {
-                        // Let 0 be infinite grace period, -1 be no grace period
-                        if (passwordRequirements.getGracePeriod() == 0) {
-                            loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, "Your password has expired. Please change your password now.", validUser.getUsername());
-                        } else if (passwordRequirements.getGracePeriod() > 0) {
-                            // If there has never been a grace time, start it now
-                            long gracePeriodStartTime;
-                            if (validUser.getGracePeriodStart() == null) {
-                                gracePeriodStartTime = currentTime;
-
-                                Map<String, Object> gracePeriodMap = new HashMap<String, Object>();
-                                gracePeriodMap.put("id", validUser.getId());
-                                gracePeriodMap.put("gracePeriodStart", Calendar.getInstance());
-
-                                SqlConfig.getInstance().getSqlSessionManager().update("User.startGracePeriod", gracePeriodMap);
-                            } else {
-                                gracePeriodStartTime = validUser.getGracePeriodStart().getTimeInMillis();
-                            }
-
-                            long graceTimeRemaining = loginRequirementsChecker.getGraceTimeRemaining(gracePeriodStartTime, currentTime);
-                            if (graceTimeRemaining > 0) {
-                                loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, "Your password has expired. You are required to change your password in the next " + loginRequirementsChecker.getPrintableGraceTimeRemaining(graceTimeRemaining) + ".", validUser.getUsername());
-                            }
-                        }
+                if ((passwordRequirements.getExpiration() > 0) 
+                    && loginRequirementsChecker.isPasswordExpired(credentials.getPasswordDate().getTimeInMillis(), currentTime)) {
+                    changeReason = "Your password has expired.";
+                } else {
+                    // Check if it meets the current requirements
+                    List<String> requirementFailures = PasswordRequirementsChecker.getInstance().doesPasswordMeetRequirements(null, plainPassword, passwordRequirements);
+
+                    if (requirementFailures != null) {
+                        changeReason = "Your password does not meet requirements: " + StringUtils.join(requirementFailures, "; ") + ".";
+                    }
+                }
 
-                        // If there is no grace period or it has passed, FAIL_EXPIRED
-                        if (loginStatus == null) {
-                            loginStatus = new LoginStatus(LoginStatus.Status.FAIL_EXPIRED, "Your password has expired. Please contact an administrator to have your password reset.");
+                // If a change is required, handle grace period checks
+                if (changeReason != null) {
+                    // Let 0 be infinite grace period, -1 be no grace period
+                    if (passwordRequirements.getGracePeriod() == 0) {
+                        loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, changeReason + " Please change your password now.", validUser.getUsername());
+                    } else if (passwordRequirements.getGracePeriod() > 0) {
+                        // If there has never been a grace time, start it now
+                        long gracePeriodStartTime;
+                        if (validUser.getGracePeriodStart() == null) {
+                            gracePeriodStartTime = currentTime;
+
+                            Map<String, Object> gracePeriodMap = new HashMap<String, Object>();
+                            gracePeriodMap.put("id", validUser.getId());
+                            gracePeriodMap.put("gracePeriodStart", Calendar.getInstance());
+
+                            SqlConfig.getInstance().getSqlSessionManager().update("User.startGracePeriod", gracePeriodMap);
+                        } else {
+                            gracePeriodStartTime = validUser.getGracePeriodStart().getTimeInMillis();
                         }
 
-                        /*
-                         * Reset the user's grace period if it isn't being used but one was
-                         * previously set. This should only happen if a user is in a grace period
-                         * before grace periods are disabled.
-                         */
-                        if ((passwordRequirements.getGracePeriod() <= 0) && (validUser.getGracePeriodStart() != null)) {
-                            SqlConfig.getInstance().getSqlSessionManager().update("User.clearGracePeriod", validUser.getId());
+                        long graceTimeRemaining = loginRequirementsChecker.getGraceTimeRemaining(gracePeriodStartTime, currentTime);
+                        if (graceTimeRemaining > 0) {
+                            loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, changeReason + " You are required to change your password in the next " + loginRequirementsChecker.getPrintableGraceTimeRemaining(graceTimeRemaining) + ".", validUser.getUsername());
                         }
                     }
+
+                    // If there is no grace period or it has passed, FAIL_EXPIRED
+                    if (loginStatus == null) {
+                        loginStatus = new LoginStatus(LoginStatus.Status.FAIL_EXPIRED, changeReason + " Please contact an administrator to have your password reset.");

Recommendation: If the password is weak but not strictly expired, we should perhaps bypass the gracePeriod lockout and always treat a requirement failure as SUCCESS_GRACE_PERIOD (forcing them to the change password screen immediately). Let me know your thoughts on this, but we definitely want to avoid a scenario where an admin tweaks a policy and creates 500 support tickets instantly.

If people desire it to be as strict as implemented, perhaps we can add an "autoexpireWeakPassword" mirth.property.

question: do you know if the API restricts any actions for SUCCESS_GRACE_PERIOD logins (even normal expired logins)? Or is it only the swing client that forces the password reset?

We also may want to log a searchable event when a user authenticates successfully with a weak password.

Reviewers
Assignees
mgaffigan mgaffigan
Labels
risk: low confidence: 79.3% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 38.7% (MEDIUM) · Higher = larger blast radius
38.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 79.3% · Lower = rushed or shallow review
79.3%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 8% · Safe to merge
8%