Skip to content
Menu
DevSecOps Now!!!
  • About
  • Certifications
  • Contact
  • Courses
  • DevSecOps Consulting
  • DevSecOps Tools
  • Training
  • Tutorials
DevSecOps Now!!!

Complete Guide: Migrating Legacy Wizbrand Users to Keycloak & Customizing Email Templates

Posted on October 23, 2025

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

When you integrated Keycloak SSO into Wizbrand, new users began being created in both Wizbrand and Keycloak.
However, existing users (created before Keycloak integration) only exist in Wizbrand’s database.
To unify authentication, we need to migrate old users into Keycloak while keeping their Wizbrand data intact.

This tutorial explains:

  1. How to migrate existing users into Keycloak with automation
  2. How to handle email verification / password reset flows
  3. How to add a “no-email” mode (so users reset passwords during next login)
  4. How to fix redirect & email-sending errors
  5. How to fully customize Keycloak’s email UI to a modern, branded template

Architecture Summary

ComponentDescription
Wizbrand BackendLaravel-based service managing your app users
KeycloakAuth provider for SSO, OAuth2, OpenID Connect
CommunicationLaravel Artisan command uses Keycloak Admin API
FlowUsers migrated → Actions set → Email sent → Login triggers password reset

Files Involved

FilePurpose
app/Services/RoleMapper.phpMaps Wizbrand user roles/groups to Keycloak roles
app/Console/Commands/MigrateUsersToKeycloak.phpMain migration logic
app/Console/Kernel.phpRegisters the command for Artisan
app/Services/KeycloakAdminService.phpHandles Keycloak API calls (already implemented)

Updated Migration Command

Here’s the final version of app/Console/Commands/MigrateUsersToKeycloak.php
It includes:

  • --no-email → skip sending emails
  • --lifespan → custom expiry time
  • Graceful error handling
  • No method renaming or removal

(You already have this updated version; keep it as your base.)

Key usage examples:

# Normal migration + verification email
php artisan kc:migrate --limit=50 --email-verify

# Send emails with a 30-day valid link
php artisan kc:migrate --limit=50 --email-verify --lifespan=2592000

# Skip emails; users reset password on next login
php artisan kc:migrate --limit=50 --email-verify --no-email

Understanding Each Option

OptionDescription
--limitNumber of users to process in one run
--offsetStart offset for pagination
--dry-runSimulate migration without writing to Keycloak
--email-verifyAdds VERIFY_EMAIL to required actions
--lifespanLifespan of email action link (default: 1 day)
--redirectOptional callback URL after password reset
--onlyComma-separated DB IDs for targeted migration
--whereAdd SQL conditions like email like '%@wizbrand.com'
--include-disabledInclude inactive/disabled users
--no-emailSkip sending emails and force reset on next login

Common Errors & Fixes

Invalid Redirect URI

Error:

Invalid redirect uri

Fix:

  1. In Keycloak → Clients → wizbrand-web
  2. Add your redirect: http://wz-account-admin-ms/auth/callback
  3. Save and re-run your command.

Invalid Sender Address ‘null’

Error:

Failed to send execute actions email: Invalid sender address 'null'

Fix:
Configure SMTP in Realm Settings → Email

FieldExample
Fromno-reply@wizbrand.com
Hostsmtp.gmail.com
Port587
EncryptionStartTLS
Usernameyour-email
PasswordApp Password
Test Connection✅ must succeed

Tip — Infinite Token is NOT Possible

Keycloak action links (password reset, verification) are JWT-based and must expire.
However, you can:

  • Extend their lifespan (e.g., 30–90 days) using: --lifespan=2592000
  • Set a global default:
    • Realm Settings → Tokens → Default Admin-Initiated Action Lifespan → 30d

Forcing Reset at Next Login (No Email)

When --no-email is used:

  • No email link is sent.
  • Keycloak sets UPDATE_PASSWORD and VERIFY_EMAIL as required actions.
  • User will be forced to reset password during their next login.

To verify:

  1. Go to Users → [user] → Required Actions
  2. You’ll see: UPDATE_PASSWORD VERIFY_EMAIL
  3. After user completes reset, list becomes empty.

Customizing the Email Design (Wizbrand Branded)

The default email looks basic.
You can fully rebrand it to match Wizbrand’s identity.

Folder Structure

/opt/keycloak/themes/wizbrand/
├─ theme.properties
├─ messages/messages_en.properties
└─ email/
   ├─ html/execute-actions.ftl
   └─ text/execute-actions.ftl

theme.properties

parent=keycloak
types=email
locales=en

HTML Template (Beautiful Modern UI)

email/html/execute-actions.ftl

(abridged summary — full version above in chat)

Features:

  • Wizbrand logo & dark header
  • Clean card layout
  • “Continue & secure my account” button
  • Action list (e.g., Update Password, Verify Email)
  • Expiry notice & fallback link
  • Responsive design (works in Gmail, Outlook, Apple Mail)

Plain Text Fallback

email/text/execute-actions.ftl — simple message body for clients that block HTML.


Select Theme in Keycloak

  1. Go to Realm Settings → Themes
  2. Set Email Theme = wizbrand
  3. Save
  4. Restart Keycloak if needed --spi-theme-cache-themes=false --spi-theme-cache-templates=false

Preview of the Styled Email (Conceptually)

(You can imagine this layout)

╔══════════════════════════════════════╗
║ Wizbrand Logo                        ║
╠══════════════════════════════════════╣
║  Action required to secure your account
║  Click below to reset your credentials
║  [ Continue & Secure My Account ]     ║
║  This link expires in 30 days.        ║
╠══════════════════════════════════════╣
║  Need help? Contact support@wizbrand.com
╚══════════════════════════════════════╝

Folder Path & Permissions (Linux/Docker)

If Keycloak runs in Docker:

docker cp ./wizbrand keycloak:/opt/keycloak/themes/wizbrand
docker exec -it keycloak chmod -R 755 /opt/keycloak/themes/wizbrand
docker restart keycloak

If self-hosted on Linux:

sudo mkdir -p /opt/keycloak/themes/wizbrand
sudo chown -R keycloak:keycloak /opt/keycloak/themes/wizbrand
sudo systemctl restart keycloak

Optional Enhancements

FeatureDescription
Resend pending actionsUse a cron job to resend execute-actions-email to users who haven’t completed verification
Auto-detect SMTP errorsCatch Invalid sender in logs and automatically switch to --no-email
Multi-client redirectAdd --client-id override to target different Keycloak clients
Error metricsLog success/error counts for daily monitoring

Verification Checklist

CheckResult
php artisan kc:migrate runs without ERR✅
Keycloak email config tested✅
Wizbrand redirect whitelisted✅
Email theme = wizbrand✅
Email styling verified✅
Required actions visible in KC✅
User resets password successfully✅

Key Benefits Achieved

Seamless migration of legacy users
Stronger password reset and verification enforcement
Optional email-less password reset
100% branded, professional email communication
Automated, repeatable process for future imports


Example: Full Command Lifecycle

Initial Import

php artisan kc:migrate --limit=100 --email-verify --lifespan=2592000

If SMTP fails

php artisan kc:migrate --limit=100 --email-verify --no-email

Weekly resend pending resets

php artisan kc:resend-actions --verify --lifespan=604800

Final Outcome

After completing this setup:

  • All Wizbrand users (old + new) are in Keycloak.
  • New users use standard registration.
  • Old users either:
    • Receive a Wizbrand-branded email to reset credentials, or
    • Are forced to reset at next login (no email mode).
  • Emails now look professional and consistent with Wizbrand’s identity.
Post Views: 643
  • Keycloak
  • migrate users to keycloak
  • Migrating Legacy Wizbrand Users to Keycloak
  • Migrating user
  • user migration on keycloak
Subscribe
Login
Notify of
guest
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
  • Ultimate DevSecOps Learning Roadmap to Move from DevOps to Cloud Security
  • Complete Tutorial: Fixing Keycloak UDP Socket Exhaustion, DNS Failure, GitHub Resolution Error, and Laravel Guzzle ConnectException on a Single Server
  • Comprehensive Guide to DevSecOps in Modern Software Engineering
  • DevSecOps in Modern Software Engineering: A Comprehensive Guide for Professionals
  • Laravel Posts Installation Guide
  • Strategies to Align DevSecOps With Agile and DevOps Practices
  • How to Fix Laravel Migration Error: Field ‘id’ Doesn’t Have a Default Value in the Migrations Table
  • A Practical Guide to Proving DevSecOps Business Value for Engineering Leaders
  • Mastering Secure Software Delivery by Solving DevSecOps Adoption Challenges
  • Operationalizing Security for Faster and Safer Software Deployments
  • DevSecOps Server Security Checklist 2026: 50 Must-Check Points Before Going Live
  • The Complete DevOps Salary Overview for IT Professionals
  • The Modern DevOps Certification Guide: Roadmaps for Every Engineering Role
  • Security Champions in DevSecOps: Responsibilities and Best Practices
  • The DevSecOps Handbook for Shift-Left Security
  • Top DevSecOps Principles for Effective Secure Software Delivery
  • Guide to DevSecOps Maturity Levels for Platform and Security Teams
  • Canada PR CRS Calculator: Express Entry Points System Explained
  • Austria PR Points Calculator: Ultimate Guide to Navigating the Red-White-Red Card System
  • The Essential Guide to Enterprise DevSecOps Implementation
  • How to Set Up Claude Code Agent on a Local Windows Laptop and Use claude Command from Anywhere
  • DevOps and DevSecOps Explained: Bridging the Gap Between Speed and Security
  • Comprehensive Manual on DevOps Methodologies and Cloud Native Engineering
  • The Master Guide to Immigration Points: Calculating Your Path to Canada, Australia, and Beyond
  • How to Skip the Activation Email and Password Reset After Google Login in Keycloak Auto-Link Existing Users in First Broker Login
  • Free SSL Certificate Generation Tutorial for Any Website Using Certbot and Apache
  • The Ultimate Guide to Certified FinOps Professional: Skills, Levels, and Career Impact
  • Certified FinOps Manager: Essential Skills for Modern Cloud Operations
  • How to Use Claude AI for Programming: Complete Guide for Developers to Boost Productivity
  • The Definitive Guide to Certified FinOps Engineer: Master Cloud Value Engineering

Recent Comments

  1. emmy day on SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘provider’ in ‘field list’
  2. digital banking on Complete Tutorial: Setting Up Laravel Telescope Correctly (Windows + XAMPP + Custom Domain)
  3. SAHIL DHINGRA on How to Uninstall Xampp from your machine when it is not visible in Control panel programs & Feature ?
  4. Abhishek on MySQL: List of Comprehensive List of approach to secure MySQL servers.
  5. Kristina on Best practices to followed in .httacess to avoid DDOS attack?

Archives

  • June 2026
  • May 2026
  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022

Categories

  • Ai
  • AI Blogging
  • AiOps
  • ajax
  • Android Studio
  • Antimalware
  • Antivirus
  • Apache
  • Api
  • API Security
  • Api Testing
  • APK
  • Aws
  • Bike Rental Services
  • ChatGPT
  • Code Linting
  • Composer
  • cPanel
  • Cyber Threat Intelligence
  • Cybersecurity
  • Data Loss Prevention
  • Database
  • dataops
  • Deception Technology
  • DeepSeek
  • Devops
  • DevSecOps
  • DevTools
  • Digital Asset Management
  • Digital Certificates
  • Docker
  • Drupal
  • emulator
  • Encryption Tools
  • Endpoint Security Tools
  • Error
  • facebook
  • Firewalls
  • Flutter
  • git
  • GITHUB
  • Google Antigravity
  • Google play console
  • Google reCAPTCHA
  • Gradle
  • Guest posting
  • health and fitness
  • IDE
  • Identity and Access Management
  • Incident Response
  • Instagram
  • Intrusion Detection and Prevention Systems
  • jobs
  • Joomla
  • Keycloak
  • Laravel
  • Law News
  • Lawyer Discussion
  • Legal Advice
  • Linkedin
  • Linkedin Api
  • Linux
  • Livewire
  • Mautic
  • Medical Tourism
  • MlOps
  • MobaXterm
  • Mobile Device Management
  • Multi-Factor Authentication
  • MySql
  • Network Traffic Analysis tools
  • Paytm
  • Penetration Testing
  • php
  • PHPMyAdmin
  • Pinterest Api
  • postify
  • Quora
  • SAST
  • SecOps
  • Secure File Transfer Protocol
  • Security Analytics Tools
  • Security Auditing Tools
  • Security Information and Event Management
  • Seo
  • Server Management Tools
  • Single Sign-On
  • Site Reliability Engineering
  • soft 404
  • software
  • SSL
  • SuiteCRM
  • SysOps
  • Threat Model
  • Twitter
  • Twitter Api
  • ubuntu
  • Uncategorized
  • Virtual Host
  • Virtual Private Networks
  • VPNs
  • Vulnerability Assessment Tools
  • Web Application Firewalls
  • Windows Processor
  • Wordpress
  • WSL (Windows Subsystem for Linux)
  • X.com
  • Xampp
  • Youtube
©2026 DevSecOps Now!!! | WordPress Theme: EcoCoded
wpDiscuz