Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password warning (Mail expiration notification) #823

Merged
merged 20 commits into from
Mar 12, 2025
Merged

Conversation

gsanchietti
Copy link
Member

@gsanchietti gsanchietti commented Mar 6, 2025

Install

Install the custom core image:

curl https://raw.githubusercontent.com/NethServer/ns8-core/main/core/install.sh > install.sh 
bash install.sh ghcr.io/nethserver/core:mail_notification
create-cluster rl1.leader.cluster0.gs.nethserver.net:55820 10.5.4.0/24 Nethesis,1234

Setup custom images for Samba and OpenLDAP:

redis-cli hset cluster/override/modules samba ghcr.io/nethserver/samba:mail_notify
redis-cli hset cluster/override/modules openldap ghcr.io/nethserver/openldap:mail_notify

Then, install:

  • an internal OpenLDAP
  • an internal Active Directory

Mail example:
image

Usage example (deprecated)

  1. Configure SMTP settings
  2. Configure a password expiration for a domain.

Using default template:

 api-cli run cluster/set-password-warning --data '{"domain": "leader.cluster0.gs.nethserver.net", "notification": true, "days": 1000, "mail_from": "no-reply@nethserver.org", "mail_template_name": "default_en"}'

For a custom template, first create the file named custom.txt like:

Dear $user ($name) of domain $domain.
Your password is going to expire in $days days.
Change it here: $portal_url

Then, use:

 api-cli run cluster/set-password-warning --data '{"domain": "leader.cluster0.gs.nethserver.net", "notification": true, "days": 1000, "mail_from": "no-reply@nethserver.org", "mail_template_name": "custom", "mail_template_content": "'$(cat custom.txt | base64 -w0)'", "mail_subject": "my expiriation"}'
  1. Create a user,
  2. Modify an existing user or add user a new one, using the user manager portal
  3. Execute the notify script:
systemctl start password-warning.service

See also:

github-actions bot pushed a commit that referenced this pull request Mar 6, 2025
@gsanchietti gsanchietti self-assigned this Mar 6, 2025
github-actions bot pushed a commit that referenced this pull request Mar 6, 2025
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
New info can be used to expose password expiration
on the UI and also to send notification about password expiration
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
New info can be used to expose password expiration
on the UI and also to send notification about password expiration
github-actions bot pushed a commit that referenced this pull request Mar 7, 2025
github-actions bot pushed a commit that referenced this pull request Mar 10, 2025
github-actions bot pushed a commit that referenced this pull request Mar 10, 2025
github-actions bot pushed a commit that referenced this pull request Mar 10, 2025
Configure mail notification for a given user domain
github-actions bot pushed a commit that referenced this pull request Mar 12, 2025
github-actions bot pushed a commit that referenced this pull request Mar 12, 2025
@gsanchietti gsanchietti requested a review from andre8244 March 12, 2025 14:04
The timer will lunch the notifier script every night
The subject is now part of the notification template:
this will simplify the configuration for the user.
Changes:
- remove upload template action
- allow only one custom template for each domain
github-actions bot pushed a commit that referenced this pull request Mar 12, 2025
Copy link
Contributor

@andre8244 andre8244 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a label fix and we're good, no need to request review again

github-actions bot pushed a commit that referenced this pull request Mar 12, 2025
github-actions bot pushed a commit that referenced this pull request Mar 12, 2025
Changes:
- read custom template from new redis position
- allow templating of the mail subject
If the cluster has a mail instance already installed,
send the notification to the local user mail address.

Other change: do not send notificaiton to user
without password expiration
When the mail is sent as HTML, new lines are not preserved
if the body is just plain text.

Now the script tries to understand if the mail body is an HTML or not
and set the mime type accordingly.
Use the user domain as for the sender address:
it's better suited then the node FQDN
github-actions bot pushed a commit that referenced this pull request Mar 12, 2025
@gsanchietti gsanchietti merged commit 87cb645 into main Mar 12, 2025
3 checks passed
@gsanchietti gsanchietti deleted the mail_notification branch March 12, 2025 16:52
@gsanchietti gsanchietti changed the title Mail notification Password warning (Mail expiration notification) Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants