Skip to content

Instantly share code, notes, and snippets.

@Elektordi
Last active July 2, 2025 14:26
Show Gist options
  • Save Elektordi/5ad622d5ebba3a6ba5eaaf8d43d2b7cf to your computer and use it in GitHub Desktop.
Save Elektordi/5ad622d5ebba3a6ba5eaaf8d43d2b7cf to your computer and use it in GitHub Desktop.
Keycloak login using IDP only
{
"authenticators": [
{
"name": "Identity Provider Selector",
"fileName": "login-idp.js",
"description": "(Guillaume Genty, 2025)"
}
]
}
<#import "template.ftl" as layout>
<@layout.registrationLayout displayMessage=!messagesPerField.existsError('username'); section>
<#if section = "header">
${msg("loginAccountTitle")}
<#elseif section = "socialProviders" >
<#if realm.password && social?? && social.providers?has_content>
<div id="kc-social-providers" class="${properties.kcFormSocialAccountSectionClass!}">
<ul class="${properties.kcFormSocialAccountListClass!}">
<#list social.providers as p>
<a data-once-link data-disabled-class="${properties.kcFormSocialAccountListButtonDisabledClass!}" id="social-${p.alias}"
class="${properties.kcFormSocialAccountListButtonClass!}"
type="button" href="${p.loginUrl}">
<#if p.iconClasses?has_content>
<i class="${properties.kcCommonLogoIdP!} ${p.iconClasses!}" aria-hidden="true"></i>
<span class="${properties.kcFormSocialAccountNameClass!} kc-social-icon-text">${p.displayName!}</span>
<#else>
<span class="${properties.kcFormSocialAccountNameClass!}">${p.displayName!}</span>
</#if>
</a>
</#list>
</ul>
</div>
</#if>
</#if>
</@layout.registrationLayout>
// Bindings: script, realm, user, session, authenticationSession, httpRequest, LOG
function authenticate(context) {
var challenge = context.form().createForm("login-idp.ftl");
context.challenge(challenge);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment