---
title: "Building a Keycloak Email Change Plugin"
description: "A custom Keycloak SPI plugin lets external systems learn about user email changes, which Keycloak doesn't natively notify on."
url: "https://swe.quest/articles/building-a-keycloak-email-change-plugin-21d5812795100fd8"
canonical: "https://neon.com/blog/building-a-keycloak-email-change-plugin"
source: "Neon"
published: "2025-04-09"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["identity-auth","jvm"]
---

# Building a Keycloak Email Change Plugin

A post on [Neon](https://swe.quest/sources/neon.md), published 2025-04-09, 4 min read, How-to. Original: [https://neon.com/blog/building-a-keycloak-email-change-plugin](https://neon.com/blog/building-a-keycloak-email-change-plugin)

## Summary

A custom Keycloak SPI plugin lets external systems learn about user email changes, which Keycloak doesn't natively notify on. It adds a RealmResourceProvider REST endpoint (update-user-email) that authorizes the caller, mints an action token and sends a confirmation email to the new address. A custom action token handler, adapted from UpdateEmailActionTokenHandler, then validates and applies the change, marks the email verified, clears pending email actions and optionally logs out other sessions. It also unlinks all federated social identities, since they were tied to the old email, and calls the backend to sync external data. Deployment needs a META-INF/services registration file and the plugin jar on the Keycloak instance.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)

## Prerequisites

- Keycloak realms and users
- Java JAX-RS ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))
- Java service provider interfaces ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))

## Keywords

Keycloak, RealmResourceProvider, UpdateEmailActionTokenHandler, SPI, Neon

## Related posts

- [Auth setup with Neon, Keycloak and Koyeb](https://swe.quest/articles/auth-setup-with-neon-keycloak-and-koyeb-120106d3cf82095b.md): Neon · 2023-12-15 · Medium · 5 min read · Identity & auth, PostgreSQL, Deployment
  Keycloak can use Neon serverless Postgres as its backing store, with the Keycloak server deployed as a container on Koyeb.
- [Managed Better Auth is now an OAuth provider, with MCP support](https://swe.quest/articles/managed-better-auth-is-now-an-oauth-provider-with-mcp-support-613f00a7521407ac.md): Neon · 2026-11-02 · Medium · 5 min read · Identity & auth, AI agents, PostgreSQL
  Neon's Managed Better Auth now supports the OAuth Provider plugin, turning an auth instance into an OAuth 2.1 authorization server that both companion apps and MCP clients can use to sign users in.
- [Enterprise-managed auth for MCP: Claude can now issue the identity assertion](https://swe.quest/articles/enterprise-managed-auth-for-mcp-claude-can-now-issue-the-identity-assertion-aa52985ca7fe5bc7.md): Supabase · 2026-11-03 · Medium · 3 min read · Identity & auth, AI agents
  Claude can now act as the issuer of the signed ID-JAG (Identity Assertion JWT Authorization Grant) for the Supabase MCP server, enabling enterprise-managed authorization for organizations whose identity provider doesn't support the MCP Enterprise-Managed Authorization extension (previously effectively only Okta).
- [Security Disclosure Recommendation: Redeploy Buckets and Reconnect GitHub After the Credential Reset](https://swe.quest/articles/security-disclosure-recommendation-redeploy-buckets-and-reconnect-github-after-3877fd6f9ee92bd0.md): Railway · 2026-10-22 · Medium · 4 min read · Incidents & postmortems, Identity & auth, Security, Deployment
  After a security disclosure, Railway invalidated and regenerated S3 access keys for every storage bucket and removed the GitHub tokens it held, including GHCR registry tokens stored on services.
- [JSON Web Keys (JWK): Rotating Cryptographic Keys at Zalando](https://swe.quest/articles/json-web-keys-jwk-rotating-cryptographic-keys-at-zalando-70034281fe17c9eb.md): Zalando Engineering · 2025-01-20 · Medium · 4 min read · Identity & auth, Cryptography
  Zalando's OIDC identity provider rotates its JWT signing keys automatically on a schedule, using a phased process so clients are never disrupted.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
