send_email_through_keyclock
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| send_email_through_keyclock [2026/03/09 05:26] – sonali | send_email_through_keyclock [2026/03/09 08:00] (current) – sonali | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | < | ||
| + | |||
| + | A system where users can log in using their **email Id /Username + Email OTP** instead of username/ | ||
| + | |||
| + | **Make Email OTP Java SPI ** | ||
| + | |||
| # Run this to find the Keycloak container: | # Run this to find the Keycloak container: | ||
| Line 20: | Line 26: | ||
| We need email-otp-authenticator JAR if it is not available | We need email-otp-authenticator JAR if it is not available | ||
| - | 1. Download the email-otp-authenticator JAR | + | **1. Download the email-otp-authenticator JAR** |
| < | < | ||
| Line 27: | Line 33: | ||
| </ | </ | ||
| - | 2. Copy into the running container | + | **2. Copy into the running container** |
| < | < | ||
| docker cp email-otp-authenticator.jar keycloak_app:/ | docker cp email-otp-authenticator.jar keycloak_app:/ | ||
| Line 34: | Line 39: | ||
| </ | </ | ||
| - | 3. Run build inside the container (registers the provider) | + | **3. Run build inside the container (registers the provider)** |
| + | < | ||
| + | # Verify it's there | ||
| + | docker exec keycloak_app ls / | ||
| + | |||
| + | </ | ||
| < | < | ||
| Line 41: | Line 51: | ||
| </ | </ | ||
| - | 4. Restart the container | + | **4. Restart the container** |
| < | < | ||
| docker restart keycloak_app | docker restart keycloak_app | ||
| Line 50: | Line 59: | ||
| # Now let's set up the Email OTP flow. Go to Keycloak Admin Console at [[https:// | # Now let's set up the Email OTP flow. Go to Keycloak Admin Console at [[https:// | ||
| - | 1. First configure SMTP (if not already done) | + | **1. First configure SMTP (if not already done)** |
| - | Realm Settings → \Email Host: smtp.gmail.com, | + | Realm Settings → Email |
| - | 2. Create Email OTP Authentication \Flow Go to Authentication → Flows → Create \flow Name: Browser Email OTP → \Save Add step → Username Password Form → \Required Add step → Email OTP → Required | + | Host: smtp.gmail.com, |
| - | 3. Bind the \flow Client → account → Advance Override realm authentication flow bindings. →Browser Flow → Browser email otp | + | Port: 587 |
| - | Customize | + | From: from email id |
| - | # check current email template python3 -c " import \zipfile with zipfile.ZipFile(' | + | Username: your username, |
| + | |||
| + | Password: your app | ||
| + | |||
| + | password Enable StartTLS → Save → Test connection | ||
| + | |||
| + | **2. Create Email OTP Authentication Flow** | ||
| < | < | ||
| - | print(z.read(' | + | Go to Authentication → Flows → Create flow Name: Browser Email OTP |
| + | → Save Add step → Username Password Form → Required Add step → | ||
| + | Email OTP → Required | ||
| </ | </ | ||
| + | **3. Bind the flow** | ||
| + | |||
| + | Client → account → Advance Override realm authentication flow bindings. →Browser Flow → Browser email otp | ||
| + | |||
| + | **Customize email content** | ||
| + | < | ||
| + | python3 -c " | ||
| + | |||
| + | </ | ||
| + | |||
| + | # check current email template | ||
| + | |||
| + | < | ||
| + | python3 -c " | ||
| + | import zipfile | ||
| + | with zipfile.ZipFile(' | ||
| + | print(z.read(' | ||
| " | " | ||
| + | |||
| + | </ | ||
| # To customize the email text, create a custom Keycloak theme. Run these commands on the droplet: | # To customize the email text, create a custom Keycloak theme. Run these commands on the droplet: | ||
| Line 115: | Line 151: | ||
| # Invalid otp issue\\ | # Invalid otp issue\\ | ||
| - | The OTP field name sent by our server might not match what the extension expects. Let me check:\\ | + | The OTP field name sent by our server might not match what the extension expects. Let me check: |
| < | < | ||
| - | python3 -c "\\ | + | |
| - | import zipfile\\ | + | python3 -c "\ |
| - | with zipfile.ZipFile(' | + | import zipfile\ |
| - | print(z.read(' | + | with zipfile.ZipFile(' |
| + | print(z.read(' | ||
| " | " | ||
| + | |||
| </ | </ | ||
| - | - Browser email otp Flow order should be \\ | + | **# Browser email otp Flow order should be** \\ |
| - | Username Form | + | Username Form → Required (first)\\ |
| - | Email OTP Form → Required | + | Email OTP Form → Required (second) |
| - | Dont do this | + | **# Dont do this** |
| - No required user action available in user details\\ | - No required user action available in user details\\ | ||
send_email_through_keyclock.1773033980.txt.gz · Last modified: by sonali
