Support email whitlisting

This commit is contained in:
Joseph Garrone
2021-04-15 12:20:08 +02:00
parent e1c310d383
commit b291526b13
4 changed files with 56 additions and 5 deletions

View File

@ -65,6 +65,7 @@ If you already have a Keycloak custom theme, it can be easily ported to Keycloak
- [Possible workarounds](#possible-workarounds)
- [Implement context persistence (optional)](#implement-context-persistence-optional)
- [Kickstart video](#kickstart-video)
- [Email domain whitelist](#email-domain-whitelist)
# How to use
@ -342,3 +343,8 @@ flash of the blank html before the js bundle have been evaluated
*NOTE: keycloak-react-theming was renamed keycloakify since this video was recorded*
[![kickstart_video](https://user-images.githubusercontent.com/6702424/108877866-f146ee80-75ff-11eb-8120-003b3c5f6dd8.png)](https://youtu.be/xTz0Rj7i2v8)
# Email domain whitelist
If you want to restrict the emails domain that can register, you can use [this plugin](https://github.com/micedre/keycloak-mail-whitelisting)
and `kcRegisterContext["authorizedMailDomains"]` to validate on.

View File

@ -147,6 +147,43 @@
<#recover>
</#attempt>
})()
})(),
"authorizedMailDomains": (function (){
<#attempt>
return "${authorizedMailDomains!''}" || undefined;
<#recover>
</#attempt>
})(),
"authorizedMailDomains": (function(){
var out = undefined;
<#attempt>
<#if authorizedMailDomains??>
out = [];
<#attempt>
<#list authorizedMailDomains as authorizedMailDomain>
out.push((function (){
<#attempt>
return "${authorizedMailDomain}";
<#recover>
</#attempt>
})());
</#list>
<#recover>
</#attempt>
</#if>
<#recover>
</#attempt>
return out;
})(),
}
</script>

View File

@ -124,6 +124,7 @@ export declare namespace KcContext {
passwordRequired: boolean;
recaptchaRequired: boolean;
recaptchaSiteKey?: string;
authorizedMailDomains?: string[];
};
export type Info = Common & {

View File

@ -162,7 +162,14 @@ export const kcRegisterContext: KcContext.Register = {
"formData": {}
},
"passwordRequired": true,
"recaptchaRequired": false
"recaptchaRequired": false,
"authorizedMailDomains": [
"example.com",
"another-example.com",
"*.yet-another-example.com",
"*.example.com",
"hello-world.com"
]
};
export const kcInfoContext: KcContext.Info = {