Repository navigation
Replies: 1 comment
|
any update of this? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello Everyone,
Creating this issue to have a discussion and understand the challenges on why keycloak never looked to support notifications for passwords that are going to expire.
Currently it supports that when user is expired, user is forced to change the password. But it will be a great feature to configure a notificaiton before expiry.
The password expiry is calculated based on the expiry value set at realm level and created_date. Based on these values, we can calculate the number of days that password is expiring.
Something like this :
int daysToExpirePassword = context.getRealm().getPasswordPolicy().getDaysToExpirePassword();
long currentTime = Time.toMillis(Time.currentTime()); // Use Time.currentTimeMillis()
// Calculate expiry threshold in milliseconds
long expiryThreshold = currentTime + TimeUnit.DAYS.toMillis(7);
// Check if password is expiring within 7 days
if (password.getCreatedDate() <= expiryThreshold) {
// If so, return the creation date
return password.getCreatedDate();
} else {
// Password is not expiring within 7 days, so return null
return null;
}
Based on these days, we can filter the users and then get the user details like username, userid, emailId and then a notification in the form of mail or an alert can be triggered. Thoughts?
All reactions