mirror of
https://github.com/zitadel/zitadel
synced 2024-11-22 00:39:36 +00:00
fb8cd18f93
# Which Problems Are Solved Some organizations / customers have the requirement, that there users regularly need to change their password. ZITADEL already had the possibility to manage a `password age policy` ( thought the API) with the maximum amount of days a password should be valid, resp. days after with the user should be warned of the upcoming expiration. The policy could not be managed though the Console UI and was not checked in the Login UI. # How the Problems Are Solved - The policy can be managed in the Console UI's settings sections on an instance and organization level. - During an authentication in the Login UI, if a policy is set with an expiry (>0) and the user's last password change exceeds the amount of days set, the user will be prompted to change their password. - The prompt message of the Login UI can be customized in the Custom Login Texts though the Console and API on the instance and each organization. - The information when the user last changed their password is returned in the Auth, Management and User V2 API. - The policy can be retrieved in the settings service as `password expiry settings`. # Additional Changes None. # Additional Context - closes #8081 --------- Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
84 lines
1.8 KiB
SQL
84 lines
1.8 KiB
SQL
WITH login_names AS (SELECT
|
|
u.id user_id
|
|
, u.instance_id
|
|
, u.resource_owner
|
|
, u.user_name
|
|
, d.name domain_name
|
|
, d.is_primary
|
|
, p.must_be_domain
|
|
, CASE WHEN p.must_be_domain
|
|
THEN concat(u.user_name, '@', d.name)
|
|
ELSE u.user_name
|
|
END login_name
|
|
FROM
|
|
projections.login_names3_users u
|
|
JOIN lateral (
|
|
SELECT
|
|
p.must_be_domain
|
|
FROM
|
|
projections.login_names3_policies p
|
|
WHERE
|
|
u.instance_id = p.instance_id
|
|
AND (
|
|
(p.is_default IS TRUE AND p.instance_id = $2)
|
|
OR (p.instance_id = $2 AND p.resource_owner = u.resource_owner)
|
|
)
|
|
ORDER BY is_default
|
|
LIMIT 1
|
|
) p ON TRUE
|
|
JOIN
|
|
projections.login_names3_domains d
|
|
ON
|
|
u.instance_id = d.instance_id
|
|
AND u.resource_owner = d.resource_owner
|
|
WHERE
|
|
u.instance_id = $2
|
|
AND u.id = $1
|
|
)
|
|
SELECT
|
|
u.id
|
|
, u.creation_date
|
|
, u.change_date
|
|
, u.resource_owner
|
|
, u.sequence
|
|
, u.state
|
|
, u.type
|
|
, u.username
|
|
, (SELECT array_agg(ln.login_name)::TEXT[] login_names FROM login_names ln GROUP BY ln.user_id, ln.instance_id) login_names
|
|
, (SELECT ln.login_name login_names_lower FROM login_names ln WHERE ln.is_primary IS TRUE) preferred_login_name
|
|
, h.user_id
|
|
, h.first_name
|
|
, h.last_name
|
|
, h.nick_name
|
|
, h.display_name
|
|
, h.preferred_language
|
|
, h.gender
|
|
, h.avatar_key
|
|
, h.email
|
|
, h.is_email_verified
|
|
, h.phone
|
|
, h.is_phone_verified
|
|
, h.password_change_required
|
|
, h.password_changed
|
|
, m.user_id
|
|
, m.name
|
|
, m.description
|
|
, m.secret
|
|
, m.access_token_type
|
|
, count(*) OVER ()
|
|
FROM projections.users13 u
|
|
LEFT JOIN
|
|
projections.users13_humans h
|
|
ON
|
|
u.id = h.user_id
|
|
AND u.instance_id = h.instance_id
|
|
LEFT JOIN
|
|
projections.users13_machines m
|
|
ON
|
|
u.id = m.user_id
|
|
AND u.instance_id = m.instance_id
|
|
WHERE
|
|
u.id = $1
|
|
AND u.instance_id = $2
|
|
LIMIT 1
|
|
; |