Menu

Post image 1
Post image 2
Post image 3
Post image 4
Post image 5
Post image 6
Post image 7
Post image 8
1 / 8
0

Dynamic Email Domain Validation in Keycloak with a Custom Authenticator

DEV Community·Bartek Gałęzowski·3 months ago
#Uf8pSz3x
#dev#keycloak#domain#email#flow#login
Reading 0:00
15s threshold

Introduction Keycloak ships with a built-in mechanism for restricting user registration by email domain — but it's static. Changing the allow-list means touching realm configuration and redeploying. For B2B SaaS products that onboard new tenants regularly, that's an operational bottleneck you don't want. The right solution is to move domain policy out of Keycloak entirely and delegate it to a backend service that can be updated at runtime. This article walks through building a custom Keycloak Authenticator — called domain-email-validator — that does exactly that: at login time, it calls an external API to decide whether the user's email domain is permitted. By the end, you'll understand the full architecture, the Java implementation, how to wire it into both browser and IDP flows, and the operational tradeoffs involved. Why Static Domain Restrictions Fall Short in B2B Products Keycloak's native domain restriction works well for single-tenant deployments with a fixed list of approved domains.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More