On 5/8/21 7:49 PM, Rui DeSousa wrote:
On May 7, 2021, at 4:47 PM, Vipin Madhusoodanan <vipin.madhusoodanan@xxxxxxxxx> wrote:
Can someone help with suggestions or ideas for a workaround to achieve this?
You can audit the table and log when the user change their password. Once you have that information you can easily determine if the user has not changed their password over a given period of time.
1. Create a table with the current password hash:
select usename, usesysid, passwd, now() as audit_dateinto passwd_auditfrom pg_shadow;
alter table passwd_auditadd constraint spasswd_audit_pkeyprimary key (usesysid, audit_date);
2. Create a view that will show which passwords have changed since last audited
create or replace view passwd_audit_reportasselect s.usename, s.usesysid, s.passwd, now() as audit_datefrom pg_shadow sjoin (select pa.usesysid, pa.passwdfrom passwd_audit pajoin (select usesysid, max(audit_date) as audit_datefrom passwd_auditgroup by usesysid) idx on idx.usesysid = pa.usesysidand idx.audit_date is not distinct from pa.audit_date) a on a.usesysid = s.usesysidand a.passwd is distinct from s.passwd;
3. Run the view periodically to find changed passwords and record them in the audit table (daily/hourly/etc).
insert into passwd_auditselect *from passwd_audit_reportreturning *;
--
Angular momentum makes the world go 'round.
Angular momentum makes the world go 'round.