[PR #3296] [MERGED] [management] refactor auth #17054

Closed
opened 2026-08-05 04:06:51 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/3296
Author: @pnmcosta
Created: 2/6/2025
Status: Merged
Merged: 2/20/2025
Merged by: @pnmcosta

Base: mainHead: refactor/auth


📝 Commits (10+)

  • 89c514b WIP auth manager
  • cfb6173 [test] token validation with custom claims extraction
  • e33cc2d [test] middleware child account switch
  • a1f86a2 [test] fix benchmarks with mocked token validation
  • 1d9a0a1 [manegement] always extract groups from token if JWTGroupsEnabled
  • 2ea30a6 clean up old claim methods
  • 6461377 amend benchmark metrics and new recorder per case
  • 285d6f5 minor typo fixes
  • 176ef54 always add old user/account id keys to context
  • e257848 upper/lower cap benchmark expectations

📊 Changes

64 files changed (+2083 additions, -1935 deletions)

View changed files

📝 client/cmd/testutil_test.go (+1 -1)
📝 client/internal/engine_test.go (+1 -1)
📝 client/server/server_test.go (+1 -1)
📝 go.mod (+1 -1)
📝 go.sum (+2 -2)
📝 management/client/client_test.go (+1 -1)
📝 management/cmd/management.go (+8 -20)
📝 management/server/account.go (+94 -220)
📝 management/server/account_test.go (+69 -162)
📝 management/server/auth/jwt/extractor.go (+71 -59)
management/server/auth/jwt/validator.go (+302 -0)
management/server/auth/manager.go (+170 -0)
management/server/auth/manager_mock.go (+54 -0)
management/server/auth/manager_test.go (+407 -0)
management/server/auth/test_data/jwks.json (+11 -0)
management/server/auth/test_data/sample_key (+27 -0)
management/server/auth/test_data/sample_key.pub (+9 -0)
📝 management/server/config.go (+0 -7)
management/server/context/auth.go (+60 -0)
📝 management/server/grpcserver.go (+17 -39)

...and 44 more files

📄 Description

Describe your changes

New Auth Manager that isolates user authentication (JWT's and PAT's) from handlers by passing a UserAuth struct in the Request's Context instead.

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/3296 **Author:** [@pnmcosta](https://github.com/pnmcosta) **Created:** 2/6/2025 **Status:** ✅ Merged **Merged:** 2/20/2025 **Merged by:** [@pnmcosta](https://github.com/pnmcosta) **Base:** `main` ← **Head:** `refactor/auth` --- ### 📝 Commits (10+) - [`89c514b`](https://github.com/netbirdio/netbird/commit/89c514b2d62c541869501ffe621cae461f586404) WIP auth manager - [`cfb6173`](https://github.com/netbirdio/netbird/commit/cfb61732662cf72c2e956d01428e75eab199a7d2) [test] token validation with custom claims extraction - [`e33cc2d`](https://github.com/netbirdio/netbird/commit/e33cc2d908da0f8d63dae8a6e8ce7cbcf0b8db1d) [test] middleware child account switch - [`a1f86a2`](https://github.com/netbirdio/netbird/commit/a1f86a23c1d7c20678b6a34f62459607217fdb7f) [test] fix benchmarks with mocked token validation - [`1d9a0a1`](https://github.com/netbirdio/netbird/commit/1d9a0a12ec2e86ee772087f5fc2b7c2c2a189387) [manegement] always extract groups from token if JWTGroupsEnabled - [`2ea30a6`](https://github.com/netbirdio/netbird/commit/2ea30a6ab816bb2ef8375cfabc4e752fdbf56f38) clean up old claim methods - [`6461377`](https://github.com/netbirdio/netbird/commit/6461377400de713d6d2b48322bc4e83c5c4abba3) amend benchmark metrics and new recorder per case - [`285d6f5`](https://github.com/netbirdio/netbird/commit/285d6f5c40359930e8a77ac983190e188cc426e3) minor typo fixes - [`176ef54`](https://github.com/netbirdio/netbird/commit/176ef5469a62fdfecdfb556b6efb47a6d01bdd3d) always add old user/account id keys to context - [`e257848`](https://github.com/netbirdio/netbird/commit/e25784876b1e356206cc9958ce6946767ec8379e) upper/lower cap benchmark expectations ### 📊 Changes **64 files changed** (+2083 additions, -1935 deletions) <details> <summary>View changed files</summary> 📝 `client/cmd/testutil_test.go` (+1 -1) 📝 `client/internal/engine_test.go` (+1 -1) 📝 `client/server/server_test.go` (+1 -1) 📝 `go.mod` (+1 -1) 📝 `go.sum` (+2 -2) 📝 `management/client/client_test.go` (+1 -1) 📝 `management/cmd/management.go` (+8 -20) 📝 `management/server/account.go` (+94 -220) 📝 `management/server/account_test.go` (+69 -162) 📝 `management/server/auth/jwt/extractor.go` (+71 -59) ➕ `management/server/auth/jwt/validator.go` (+302 -0) ➕ `management/server/auth/manager.go` (+170 -0) ➕ `management/server/auth/manager_mock.go` (+54 -0) ➕ `management/server/auth/manager_test.go` (+407 -0) ➕ `management/server/auth/test_data/jwks.json` (+11 -0) ➕ `management/server/auth/test_data/sample_key` (+27 -0) ➕ `management/server/auth/test_data/sample_key.pub` (+9 -0) 📝 `management/server/config.go` (+0 -7) ➕ `management/server/context/auth.go` (+60 -0) 📝 `management/server/grpcserver.go` (+17 -39) _...and 44 more files_ </details> ### 📄 Description ## Describe your changes New Auth Manager that isolates user authentication (JWT's and PAT's) from handlers by passing a UserAuth struct in the Request's Context instead. ## Issue ticket number and link ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [x] 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 04:06:51 -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#17054