Netbird and Keycloak connect to LDAP don't work #436

Closed
opened 2025-11-20 05:11:20 -05:00 by saavagebueno · 1 comment
Owner

Originally created by @emferrandi on GitHub (Sep 4, 2023).

Describe the problem
I'm facing an issue using Keycloak and Active Directory with Netbird.
I connected Keycloak with Windows Active Directory and I manage to connect to Netbird.
And on the Peers page, I see this error : " Request failed with status code 401. Please refresh the page if the issue continues. invalid jwt"
When I connect to Netbird using an internal user (not imported from AD), it works perfectly.

To Reproduce
Steps to reproduce the behavior:

  1. Install Netbird and Keycloak in self-hosted mode
  2. Configure Keycloak to connect to LDAP
  3. Try to connect to user imported from LDAP

Expected behavior
See Peer information from the URL

Screenshots
image

Additional context
Difference between user :

  • Classic user in Keycloak :
{
    "id":"3f3ce19d-52cf-4579-b5b7-d499d6006e32",
    "createdTimestamp":1690813563692,
    "username":"user",
    "enabled":true,
    "totp":false,
    "emailVerified":false,
    "firstName":"user",
    "lastName":"user",
    "email":"user@mail.com",
    "attributes":{
        "wt_pending_invite":["false"],
        "wt_account_id":["cj3shulxxxx738xxxxg"]
    },
    "disableableCredentialTypes":[],
    "requiredActions":[],
    "notBefore":0,
    "access":{
        "manageGroupMembership":true,
        "view":true,
        "mapRoles":true,
        "impersonate":false,
        "manage":true
    }
}
  • User imported from AD :
{
    "id":"1cxxx9d7-f0xx-4fxx-bbxx-18749xxxxba7b",
    "createdTimestamp":1693477962721,
    "username":"UserAD",
    "enabled":true,
    "totp":false,
    "emailVerified":false,
    "firstName":"UserAD",
    "lastName":"Name",
    "email":"UserAD@mail.com",
    "federationLink":"738xx269-d0xx-49xx-xx09-4223xxxxa336",
    "attributes":{
        "LDAP_ENTRY_DN":["CN=UserAD,OU=Utilisateurs,OU=xxx,DC=xxx,DC=xxx"],
        "createTimestamp":["20190516124504.0Z"],
        "modifyTimestamp":["20230831104958.0Z"],
        "LDAP_ID":["xxx"]
    },
    "disableableCredentialTypes":[],
    "requiredActions":[],
    "notBefore":0,
    "access":{
        "manageGroupMembership":true,
        "view":true,
        "mapRoles":true,
        "impersonate":false,
        "manage":true
    }
}

After looking the code, you are using wt_account_id and wt_pending_invite. These two variables are not in user imported from LDAP...

The problem seems to come from this file : https://github.com/netbirdio/netbird/blob/main/management/server/idp/keycloak.go

Originally created by @emferrandi on GitHub (Sep 4, 2023). **Describe the problem** I'm facing an issue using Keycloak and Active Directory with Netbird. I connected Keycloak with Windows Active Directory and I manage to connect to Netbird. And on the Peers page, I see this error : " Request failed with status code 401. Please refresh the page if the issue continues. invalid jwt" When I connect to Netbird using an internal user (not imported from AD), it works perfectly. **To Reproduce** Steps to reproduce the behavior: 1. Install Netbird and Keycloak in self-hosted mode 2. Configure Keycloak to connect to LDAP 3. Try to connect to user imported from LDAP **Expected behavior** See Peer information from the URL **Screenshots** ![image](https://github.com/netbirdio/netbird/assets/92516978/14c4b1ec-89f7-4196-8f00-32d67f7094cd) **Additional context** Difference between user : - Classic user in Keycloak : ``` { "id":"3f3ce19d-52cf-4579-b5b7-d499d6006e32", "createdTimestamp":1690813563692, "username":"user", "enabled":true, "totp":false, "emailVerified":false, "firstName":"user", "lastName":"user", "email":"user@mail.com", "attributes":{ "wt_pending_invite":["false"], "wt_account_id":["cj3shulxxxx738xxxxg"] }, "disableableCredentialTypes":[], "requiredActions":[], "notBefore":0, "access":{ "manageGroupMembership":true, "view":true, "mapRoles":true, "impersonate":false, "manage":true } } ``` - User imported from AD : ``` { "id":"1cxxx9d7-f0xx-4fxx-bbxx-18749xxxxba7b", "createdTimestamp":1693477962721, "username":"UserAD", "enabled":true, "totp":false, "emailVerified":false, "firstName":"UserAD", "lastName":"Name", "email":"UserAD@mail.com", "federationLink":"738xx269-d0xx-49xx-xx09-4223xxxxa336", "attributes":{ "LDAP_ENTRY_DN":["CN=UserAD,OU=Utilisateurs,OU=xxx,DC=xxx,DC=xxx"], "createTimestamp":["20190516124504.0Z"], "modifyTimestamp":["20230831104958.0Z"], "LDAP_ID":["xxx"] }, "disableableCredentialTypes":[], "requiredActions":[], "notBefore":0, "access":{ "manageGroupMembership":true, "view":true, "mapRoles":true, "impersonate":false, "manage":true } } ``` After looking the code, you are using wt_account_id and wt_pending_invite. These two variables are not in user imported from LDAP... The problem seems to come from this file : https://github.com/netbirdio/netbird/blob/main/management/server/idp/keycloak.go
Author
Owner

@emferrandi commented on GitHub (Oct 10, 2023):

After the last upgrade (version 0.23.7), the issue is fix.
Thanks for your upgrade.

@emferrandi commented on GitHub (Oct 10, 2023): After the last upgrade (version 0.23.7), the issue is fix. Thanks for your upgrade.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#436