Skip to content

335 feature request automatically send user invite link#336

Open
Aravinda-HWK wants to merge 3 commits into
LSFLK:mainfrom
Aravinda-HWK:335-feature-request-automatically-send-user-invite-link
Open

335 feature request automatically send user invite link#336
Aravinda-HWK wants to merge 3 commits into
LSFLK:mainfrom
Aravinda-HWK:335-feature-request-automatically-send-user-invite-link

Conversation

@Aravinda-HWK
Copy link
Copy Markdown
Collaborator

📌 Description

This PR is to add the user invite email send flow with the primary domain contact@domain_name email address to the users' secondary email address by the admin.


🔍 Changes Made

  • Update the sample resources to create the primary OU, user schema, and contact user.
  • Update the deployment.yaml file with those values read from the .env file

✅ Checklist (Email System)

  • Core services tested (SMTP, IMAP, mail storage, end-to-end delivery)
  • Security & compliance verified (auth via Thunder IDP, TLS, DKIM/SPF/DMARC, spam/virus filtering)
  • Configuration & deployment checked (configs generated, Docker/Compose updated)
  • Reliability confirmed (error handling, logging, monitoring)
  • Documentation & usage notes updated (README, deployment, API)

🧪 Testing Instructions


📷 Screenshots / Logs (if applicable)


⚠️ Notes for Reviewers

@Aravinda-HWK Aravinda-HWK requested a review from maneeshaxyz May 18, 2026 11:51
@Aravinda-HWK Aravinda-HWK self-assigned this May 18, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request automates the setup of domain-specific resources for Thunder, including the creation of Organization Units, user schemas, and contact users via shell scripts and API calls. It also integrates SMTP configuration by deriving values from the primary domain and updating the deployment configuration. Feedback highlights a security concern regarding logging generated passwords to stdout and suggests refining sed patterns in gen-thunder.sh to be more precise by anchoring matches and preserving indentation.

if [[ "$HTTP_CODE" == "201" ]] || [[ "$HTTP_CODE" == "200" ]]; then
log_success "User '${CONTACT_USERNAME}' created"
log_info "Username: ${CONTACT_USERNAME}"
log_info "Password: ${CONTACT_PASSWORD}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-high high

Logging the generated password to stdout is a security risk, as these logs may be persisted in container logs or monitoring systems. Since this script is intended for automated setup, consider providing the password via an environment variable (which is already supported via THUNDER_SMTP_PASSWORD) and only generating/printing it as a last resort. If it must be printed, ensure the environment is secure and logs are handled appropriately.

Comment on lines +67 to +69
sed -i'' -e "/^email:/,/^[^ ]/ s|host:.*|host: \"${SMTP_HOST}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|username:.*|username: \"${SMTP_USERNAME}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|from_address:.*|from_address: \"${SMTP_FROM_ADDRESS}\"|" "${THUNDER_DEPLOYMENT_FILE}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The sed substitution patterns are a bit broad and could accidentally match other keys that contain these strings (e.g., smtp_host: or backup_host:). It's safer to anchor the match to the start of the line and preserve indentation using a capture group. Additionally, the range /^email:/,/^[^ ]/ can be fragile if there are comments starting at the first column within the email: block, as sed will stop the range at the first such comment. Quoting numeric or string values in the generated YAML is acceptable per repository guidelines.

Suggested change
sed -i'' -e "/^email:/,/^[^ ]/ s|host:.*|host: \"${SMTP_HOST}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|username:.*|username: \"${SMTP_USERNAME}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|from_address:.*|from_address: \"${SMTP_FROM_ADDRESS}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|^\([[:space:]]*\)host:.*|\1host: \"${SMTP_HOST}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|^\([[:space:]]*\)username:.*|\1username: \"${SMTP_USERNAME}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|^\([[:space:]]*\)from_address:.*|\1from_address: \"${SMTP_FROM_ADDRESS}\"|" "${THUNDER_DEPLOYMENT_FILE}"
References
  1. In shell scripts that generate YAML, it is acceptable to quote numeric values as strings if the consuming application is not strict about the data type.

sed -i'' -e "/^email:/,/^[^ ]/ s|username:.*|username: \"${SMTP_USERNAME}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|from_address:.*|from_address: \"${SMTP_FROM_ADDRESS}\"|" "${THUNDER_DEPLOYMENT_FILE}"
if [[ -n "${SMTP_PASSWORD}" ]]; then
sed -i'' -e "/^email:/,/^[^ ]/ s|password:.*|password: \"${SMTP_PASSWORD}\"|" "${THUNDER_DEPLOYMENT_FILE}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Anchoring the match to the start of the line is recommended here as well to avoid accidental matches with other keys. Quoting the value as a string is acceptable per repository guidelines.

Suggested change
sed -i'' -e "/^email:/,/^[^ ]/ s|password:.*|password: \"${SMTP_PASSWORD}\"|" "${THUNDER_DEPLOYMENT_FILE}"
sed -i'' -e "/^email:/,/^[^ ]/ s|^\([[:space:]]*\)password:.*|\1password: \"${SMTP_PASSWORD}\"|" "${THUNDER_DEPLOYMENT_FILE}"
References
  1. In shell scripts that generate YAML, it is acceptable to quote numeric values as strings if the consuming application is not strict about the data type.

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.

Feature Request: Automatically Send User Invite Link

1 participant