[keycloak-user] SAML IdP automatically link account
Glenn Campbell
campbellg at teds.com
Fri Aug 26 09:54:56 EDT 2016
Sigbjørn,
Thank you for your suggestions. They have been extremely helpful. I changed
my custom authenticator to extend AbstractIdpAuthenticator and the code I
put in the authenticateImpl method to get the behavior I want is almost
trivial:
UserModel existingUser =
context.getSession().users().getUserByUsername(brokerContext.getModelUsername(),
context.getRealm());
if (existingUser != null) {
context.setUser(existingUser);
context.success();
} else {
context.failure(AuthenticationFlowError.UNKNOWN_USER);
}
}
I suspect there is more I need to do in this method, such as the part you
mention about the FederatedIdentityModel. I'm not sure what needs to be
done with that. But your suggestions have got me moving in the right
direction.
Thanks again for your help.
Glenn
On Thu, Aug 25, 2016 at 10:18 AM, Sigbjørn Dybdahl <sigbjorn at fifty-five.com>
wrote:
> Hi Glenn,
>
> This seems familiar to what I implemented recently with a custom
> authenticator. That is, upon response from my trusted IdP the authenticate
> function does the following:
>
> 1. gets the BrokeredIdentityContext from the client session (check
> out AbstractIdpAuthenticator for an example of how it's done)
> 2. adding the values in the BrokeredIdentiyContext to the user (by
> creating a FederatedIdentityModel and adding it to the user)
> 3. setting the user to the AuthenticationFlowContext
> 4. calling success on the AuthenticationFlowContext
>
> Hopefully this will help you find what's not working with your
> implementation.
>
>
> Sigbjørn
>
> On 25 August 2016 at 15:12, Glenn Campbell <campbellg at teds.com> wrote:
>
>> I still haven't gotten anywhere with this. Here's what I've tried so far:
>>
>> 1) modifying First Broker Login flow as follows -
>> Review Profile - disabled
>> Create User If Unique - alternative
>> Handle Existing Account - alternative
>> everything under Handle Existing Account that can be disabled I have
>> disabled
>>
>> Result: I authenticate with the remote SAML server but my local Keycloak
>> server displays an error screen saying "Invalid username or password".
>>
>>
>> 2) created a custom authentication flow containing the following -
>> Create User If Unique - alternative
>> A custom authenticator class with an authenticate method that just calls
>> the success method of the AuthenticationFlowContext.
>>
>> Result: I authenticate with the remote SAML server but my local Keycloak
>> server displays an error screen saying "Invalid username or password".
>>
>>
>> As always, any suggestions would be greatly appreciated.
>>
>> On Tue, Aug 23, 2016 at 9:49 AM, Glenn Campbell <campbellg at teds.com>
>> wrote:
>>
>>> I have a SAML IdP that is used only for authentication and a separate
>>> database that contains information about the users, including roles. I've
>>> set up the database in User Federation and the SAML IdP in Identity
>>> Providers.
>>>
>>> The problem I have is that when users log in they are prompted to link
>>> to an existing account. This is confusing for them because from their
>>> perspective the only account they know about is the one on the SAML IdP.
>>>
>>> Is it possible to configure this Identity Provider to be "trusted" so
>>> that the accounts are linked automatically? I started looking into creating
>>> a custom authenticator based on the documentation and the custom
>>> authenticator in the example code but I don't see what the necessary steps
>>> are to cause the automatic account linking.
>>>
>>> Any suggestions would be greatly appreciated.
>>>
>>
>>
>> _______________________________________________
>> keycloak-user mailing list
>> keycloak-user at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/keycloak-user
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160826/0057c736/attachment.html
More information about the keycloak-user
mailing list