[client] Unexport GetServerPublicKey, add HealthCheck method#5735
[client] Unexport GetServerPublicKey, add HealthCheck method#5735
Conversation
Internalize server key fetching into Login, Register, GetDeviceAuthorizationFlow, and GetPKCEAuthorizationFlow methods, removing the need for callers to fetch and pass the key separately. Replace the exported GetServerPublicKey with a HealthCheck() error method for connection validation, keeping IsHealthy() bool for non-blocking background monitoring. Fix test encryption to use correct key pairs (client public key as remotePubKey instead of server private key).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR centralizes management-server public key handling inside the management client API: callers no longer fetch or pass the server key. Signatures for Login/Register and authorization-flow RPCs were simplified, HealthCheck/IsHealthy were added, and call sites/tests/mocks were updated accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Client/Auth
participant Mgmt as ManagementClient (GrpcClient)
participant Server as Management Server
App->>Mgmt: Login(sysInfo, pubSSHKey, dnsLabels)
note right of Mgmt: GrpcClient.Login (exported)\nfetches server key internally
Mgmt->>Mgmt: getServerPublicKey()
Mgmt->>Server: GetPublicKey (gRPC)
Server-->>Mgmt: serverPublicKey
Mgmt->>Mgmt: encrypt login request with serverPublicKey
Mgmt->>Server: Login(encryptedRequest)
Server-->>Mgmt: LoginResponse (encrypted)
Mgmt->>Mgmt: decrypt LoginResponse
Mgmt-->>App: LoginResponse / error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Describe your changes
Simplify the Client interface without modifying any underlying logic. The encryption/decryption behavior is identical, key retrieval is just moved inside the methods that need it.
Fix test encryption to use correct key pairs (client public key as remotePubKey instead of server private key).
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit
New Features
Bug Fixes
Refactor