[PR #1368] [MERGED] Enable JWT group-based user authorization #13597

Open
opened 2026-08-05 02:08:45 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/1368
Author: @bcmmbaga
Created: 12/8/2023
Status: Merged
Merged: 12/11/2023
Merged by: @bcmmbaga

Base: mainHead: allow-jwt-groups


📝 Commits (3)

  • eb05099 Extend management API to support list of allowed JWT groups (#1366)
  • 924abb5 Add JWT group-based user authorization (#1373)
  • 2bb0e04 Optimize JWT group check in auth middleware to cover nil and empty allowed groups

📊 Changes

8 files changed (+133 additions, -10 deletions)

View changed files

📝 management/server/account.go (+4 -0)
📝 management/server/http/accounts_handler.go (+9 -0)
📝 management/server/http/accounts_handler_test.go (+5 -1)
📝 management/server/http/api/openapi.yml (+6 -0)
📝 management/server/http/api/types.gen.go (+3 -0)
📝 management/server/http/handler.go (+9 -6)
📝 management/server/http/middleware/auth_middleware.go (+62 -1)
📝 management/server/http/middleware/auth_middleware_test.go (+35 -2)

📄 Description

Describe your changes

  • Extend the update account endpoint /api/accounts/{accountId} to accommodate the introduction of a new optional field, jwt_allow_groups. This field enables the specification of groups whose members are permitted access to Netbird when utilizing JWT Group Propagation.
curl -X PUT http://localhost:33073/api/accounts/<ACCOUNT_ID> \
-H 'Accept: application/json' \
-H 'Authorization: Token <PAT>' \
-d '{
	"settings": {
		"groups_propagation_enabled": true,
		"jwt_allow_groups": [
			"NetBird", "Admins"
		],
		"jwt_groups_claim_name": "groups",
		"jwt_groups_enabled": true,
		"peer_login_expiration": 86400,
		"peer_login_expiration_enabled": true
	}
}'

  • Add user group-based authorization. This implementation checks for JWT group propagation and jwt_allow_groups settings. Users attempting authentication without membership in the specified group list will have their authentication rejected. Additionally, if no allow groups are set, all users will be authenticated seamlessly.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/1368 **Author:** [@bcmmbaga](https://github.com/bcmmbaga) **Created:** 12/8/2023 **Status:** ✅ Merged **Merged:** 12/11/2023 **Merged by:** [@bcmmbaga](https://github.com/bcmmbaga) **Base:** `main` ← **Head:** `allow-jwt-groups` --- ### 📝 Commits (3) - [`eb05099`](https://github.com/netbirdio/netbird/commit/eb050992c1fbcbbb4c830bc2bfcb628c3a5f5230) Extend management API to support list of allowed JWT groups (#1366) - [`924abb5`](https://github.com/netbirdio/netbird/commit/924abb5ddc5ae85cb4d7866d4e25fae633b24de1) Add JWT group-based user authorization (#1373) - [`2bb0e04`](https://github.com/netbirdio/netbird/commit/2bb0e0485b537477b41bdef8eede3d4f89e71def) Optimize JWT group check in auth middleware to cover nil and empty allowed groups ### 📊 Changes **8 files changed** (+133 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `management/server/account.go` (+4 -0) 📝 `management/server/http/accounts_handler.go` (+9 -0) 📝 `management/server/http/accounts_handler_test.go` (+5 -1) 📝 `management/server/http/api/openapi.yml` (+6 -0) 📝 `management/server/http/api/types.gen.go` (+3 -0) 📝 `management/server/http/handler.go` (+9 -6) 📝 `management/server/http/middleware/auth_middleware.go` (+62 -1) 📝 `management/server/http/middleware/auth_middleware_test.go` (+35 -2) </details> ### 📄 Description ## Describe your changes - Extend the update account endpoint /api/accounts/{accountId} to accommodate the introduction of a new optional field, jwt_allow_groups. This field enables the specification of groups whose members are permitted access to Netbird when utilizing JWT Group Propagation. ``` curl -X PUT http://localhost:33073/api/accounts/<ACCOUNT_ID> \ -H 'Accept: application/json' \ -H 'Authorization: Token <PAT>' \ -d '{ "settings": { "groups_propagation_enabled": true, "jwt_allow_groups": [ "NetBird", "Admins" ], "jwt_groups_claim_name": "groups", "jwt_groups_enabled": true, "peer_login_expiration": 86400, "peer_login_expiration_enabled": true } }' ``` - Add user group-based authorization. This implementation checks for JWT group propagation and jwt_allow_groups settings. Users attempting authentication without membership in the specified group list will have their authentication rejected. Additionally, if no allow groups are set, all users will be authenticated seamlessly. ## Issue ticket number and link - #1194 ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 02:08:45 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#13597