[GH-ISSUE #4234] Gitlab provider based on group membership #8297

Open
opened 2026-08-05 01:17:14 -04:00 by saavagebueno · 1 comment
Owner

Originally created by @msslava on GitHub (Jul 28, 2025).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/4234

Hi!
My goal is to get authentication working based on gitlab group membership.
Is it possible with Gitlab provider?

Right now it seems like no.
But maybe it wouldn't be hard to implement?
Otherwise, right now it seems like a very strange way to sign in without user scope.

Thanks!

Originally created by @msslava on GitHub (Jul 28, 2025). Original GitHub issue: https://github.com/netbirdio/netbird/issues/4234 Hi! My goal is to get authentication working based on gitlab group membership. Is it possible with Gitlab provider? Right now it seems like no. But maybe it wouldn't be hard to implement? Otherwise, right now it seems like a very strange way to sign in without user scope. Thanks!
saavagebueno added the feature-request label 2026-08-05 01:17:14 -04:00
Author
Owner

@vmax commented on GitHub (May 27, 2026):

For GitLab + NetBird generic OIDC with embedded Dex, the claim name is a bit misleading.

GitLab emits groups as groups_direct, but NetBird management does not validate the raw GitLab token. It validates the token issued by embedded Dex. So the working flow is:

GitLab groups_direct -> Dex groups -> NetBird JWT group sync

What worked for me:

In /var/lib/netbird/idp.db, update the Dex connector config to map GitLab’s claim into Dex’s groups claim:

  UPDATE connector
  SET config = json_set(
    config,
    '$.scopes', json('["openid","profile","email"]'),
    '$.claimMapping', json('{"groups":"groups_direct"}'),
    '$.insecureEnableGroups', json('true')
  )
  WHERE id = '<gitlab_connector_id>';

Do not add the groups scope for GitLab in this setup. GitLab rejected it with:

  The requested scope is invalid, unknown, or malformed.

In the management DB, NetBird must read Dex’s emitted claim, not GitLab’s original claim:

  UPDATE accounts
  SET
    settings_jwt_groups_enabled = 1,
    settings_jwt_groups_claim_name = 'groups',
    settings_groups_propagation_enabled = 1
  WHERE id = '<account_id>';

Then restart NetBird/Dex and do a clean login.

Expected result:

  SELECT id, name, issued FROM groups;

shows the GitLab group, for example:

... | test_group | jwt

The confusing part is that setting settings_jwt_groups_claim_name = 'groups_direct' looks correct when inspecting the GitLab JWT, but it does not work with embedded Dex because NetBird receives Dex’s JWT. Dex has to map groups_direct to groups first.

Possible product fix: for generic OIDC connectors, expose Dex claimMapping in the UI/API, or add a GitLab preset that sets claimMapping.groups = groups_direct without adding a groups scope.

<!-- gh-comment-id:4555887050 --> @vmax commented on GitHub (May 27, 2026): For GitLab + NetBird generic OIDC with embedded Dex, the claim name is a bit misleading. GitLab emits groups as `groups_direct`, but NetBird management does not validate the raw GitLab token. It validates the token issued by embedded Dex. So the working flow is: `GitLab groups_direct -> Dex groups -> NetBird JWT group sync` What worked for me: In `/var/lib/netbird/idp.db`, update the Dex connector config to map GitLab’s claim into Dex’s `groups` claim: ```sql UPDATE connector SET config = json_set( config, '$.scopes', json('["openid","profile","email"]'), '$.claimMapping', json('{"groups":"groups_direct"}'), '$.insecureEnableGroups', json('true') ) WHERE id = '<gitlab_connector_id>'; ``` Do **not** add the groups scope for GitLab in this setup. GitLab rejected it with: ``` The requested scope is invalid, unknown, or malformed. ``` In the management DB, NetBird must read Dex’s emitted claim, not GitLab’s original claim: ``` UPDATE accounts SET settings_jwt_groups_enabled = 1, settings_jwt_groups_claim_name = 'groups', settings_groups_propagation_enabled = 1 WHERE id = '<account_id>'; ``` Then restart NetBird/Dex and do a clean login. Expected result: ``` SELECT id, name, issued FROM groups; ``` shows the GitLab group, for example: ... | test_group | jwt The confusing part is that setting `settings_jwt_groups_claim_name = 'groups_direct'` looks correct when inspecting the GitLab JWT, but it does not work with embedded Dex because NetBird receives Dex’s JWT. Dex has to map groups_direct to groups first. Possible product fix: for generic OIDC connectors, expose Dex `claimMapping` in the UI/API, or add a GitLab preset that sets `claimMapping.groups = groups_direct` without adding a `groups` scope.
Sign in to join this conversation.
No Label feature-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#8297