Skip to content

Commit b68e43e

Browse files
committed
Add force_password_change_first_login config setting
1 parent ae1a6ae commit b68e43e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

schemas/qwc-db-auth.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@
131131
"ip_blacklist_max_attempt_count": {
132132
"description": "After how many failed login attempts an IP will be blacklisted. Should be less than max_login_attempts. See also ip_blacklist_duration. Default: 10",
133133
"type": "integer"
134+
},
135+
"force_password_change_first_login": {
136+
"description": "Whether to force users to change the password on first login. Default: `false`",
137+
"type": "boolean"
134138
}
135139
},
136140
"required": [

src/db_auth.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def __init__(self, tenant, mail, app):
9696
self.totp_issuer_name = config.get('totp_issuer_name', 'QWC Services')
9797
self.ip_blacklist_duration = config.get('ip_blacklist_duration', 300)
9898
self.ip_blacklist_max_attempt_count = config.get('ip_blacklist_max_attempt_count', 10)
99+
self.force_password_change_first_login = config.get('force_password_change_first_login', False)
99100

100101
db_engine = DatabaseEngine()
101102
self.config_models = ConfigModels(
@@ -184,8 +185,9 @@ def login(self):
184185
# force password change on first sign in of default admin user
185186
# NOTE: user.last_sign_in_at will be set after successful auth
186187
force_password_change = (
187-
user and user.name == self.DEFAULT_ADMIN_USER
188-
and user.last_sign_in_at is None
188+
user and user.last_sign_in_at is None and (
189+
user.name == self.DEFAULT_ADMIN_USER or self.force_password_change_first_login
190+
)
189191
)
190192

191193
# check if password has expired

0 commit comments

Comments
 (0)