8000 Failed authentication: java.lang.NullPointerException: Cannot invoke "org.keycloak.models.UserModel.getFederationLink()" because "this.delegate" is null · Issue #28100 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Failed authentication: java.lang.NullPointerException: Cannot invoke "org.keycloak.models.UserModel.getFederationLink()" because "this.delegate" is null #28100

Closed

Description

@fjf2002

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

identity-brokering, ldap

Describe the bug

I'm using Keycloak v24.0.1 with both

  • another keycloak server as an identity provider (let's call that "foo")
  • an LDAP User federation (with Kerberos SSO).

I had tested both separately and it worked. But when BOTH are enabled, the following occurs, see the descriptions in the sections below.

As soon as I disable the LDAP user federation, it will work.

I should add, the LDAP user federation is configured as follows:

  • Edit mode: UNSYNCED
  • Import Users: On
  • Sync Registrations: Off

Version

24.0.1

Regression

  • The issue is a regression

Expected behavior

Successful login with the "foo" keycloak IDP

Actual behavior

After the steps described in "How to Reproduce", the GUI shows "An Error occurred", and the log shows:

2024-03-20 15:37:29,305 WARN  [org.keycloak.services] (executor-thread-10) KC-SERVICES0013: Failed authentication: java.lang.NullPointerException: Cannot invoke "org.keycloak.models.UserModel.getFederationLink()" because "this.delegate" is null
	at org.keycloak.models.utils.UserModelDelegate.getFederationLink(UserModelDelegate.java:195)
	at org.keycloak.storage.ldap.LDAPStorageProvider.lambda$decorateUserProfile$23(LDAPStorageProvider.java:1115)
	at org.keycloak.userprofile.AttributeMetadata.isSelected(AttributeMetadata.java:132)
	at org.keycloak.userprofile.DefaultAttributes.configureMetadata(DefaultAttributes.java:332)
	at org.keycloak.userprofile.DefaultAttributes.<init>(DefaultAttributes.java:87)
	at org.keycloak.userprofile.DeclarativeUserProfileProvider.createAttributes(DeclarativeUserProfileProvider.java:112)
	at org.keycloak.userprofile.DeclarativeUserProfileProvider.createUserProfile(DeclarativeUserProfileProvider.java:139)
	at org.keycloak.userprofile.DeclarativeUserProfileProvider.create(DeclarativeUserProfileProvider.java:122)
	at org.keycloak.authentication.authenticators.broker.IdpReviewProfileAuthenticator.actionImpl(IdpReviewProfileAuthenticator.java:196)
	at org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.action(AbstractIdpAuthenticator.java:93)
	at org.keycloak.authentication.DefaultAuthenticationFlow.processAction(DefaultAuthenticationFlow.java:151)
	at org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:987)

How to Reproduce?

  • Go to the keycloak login form
  • Click the button at the bottom to sign in with the "foo" keycloak IDP
  • At the "foo" keycloak IDP, choose a user not yet known to our own idp, and without email address, and login.
  • After redirect back at our IDP, the "Update Account Information" form shows up. Enter an Email address and click "submit".
  • Now the errors occur as described in "Actual behavior".

Anything else?

No response

Activity

  1. pedroigor commented on Mar 20, 2024

    @pedroigor
    Contributor

    @fjf2002 Did you manage to have both working on previous versions?

  2. self-assigned this
    on Mar 20, 2024
  3. fjf2002 commented on Mar 21, 2024

    @fjf2002
    ContributorAuthor

    @pedroigor: Unknown.
    Do you expect me to setup Keycloak v23 or v22 and test that?

  4. ArminRadmueller commented on Mar 22, 2024

    @ArminRadmueller

    same problem with Verion 24.0.1 and Microsoft Entra ID.
    I have noticed that if you create the social link on a user manually, the login with Entra ID works.

  5. pedroigor commented on Mar 25, 2024

    @pedroigor
    Contributor

    @ArminRadmueller @fjf2002 I think I know what is going on. During the first broker login flow we are not dealing with the fact that the federation link (basically, the user federation provider ID) does not exist. See https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/authentication/authenticators/broker/IdpReviewProfileAuthenticator.java#L115.

    We need to override the getFederationLink and return null in that case.

    We also don't have enough coverage for brokering and LDAP enabled at the same time. We should update our test suite to cover such usage.

  6. added a commit that references this issue on Mar 26, 2024
    e88998c
  7. 3 remaining items

  8. added this to the 25.0.0 milestone on Mar 26, 2024
  9. added a commit that references this issue on Mar 26, 2024
    a470711
  10. added a commit that references this issue on Mar 26, 2024
    a060f6e
  11. pedroigor commented on Mar 26, 2024

    @pedroigor
    Contributor

    @fjf2002 Please, let me know if that fix works well for you. I managed to reproduce it in that test by enabling Kerberos to a realm without running any other step to authenticate the user but just log in from the broker.

    I hope it is enough to cover this usage.

  12. ArminRadmueller commented on Mar 27, 2024

    @ArminRadmueller

    Unfortunately I don't know exactly how to test. Would it be possible to release this fix in a 24.0.3?

  13. fjf2002 commented on Mar 27, 2024

    @fjf2002
    ContributorAuthor

    I have tested using the nightly build. Works. Thank You for patching that quickly.

  14. added 2 commits that reference this issue on Apr 16, 2024
    d7947bb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0