Repository navigation
[client] mobile MDM bridge — iOS + Android setMDMPolicyFetcher entrypoint #6435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,375
−591
Merged
Changes from 24 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
db2c9b6
MDM Android mobile wiring
riccardomanfrin bec26d5
Removes dead code
riccardomanfrin 8741954
Removes static vars
riccardomanfrin 0340893
Now we need to apply MDM in the GetConfig
riccardomanfrin b2c5732
You now need to explicitly call these around
riccardomanfrin 7715c38
Adds iOS wiring
riccardomanfrin e1ffb16
Merge branch 'main' into mdm_integration (with unresolved conflict ma…
riccardomanfrin e92aa7d
Resolve merge conflicts from main
riccardomanfrin f91f9fc
Convey MDM overlay config to Debug Bundle output
riccardomanfrin 76fd144
Merge remote-tracking branch 'origin/main' into mdm_integration
riccardomanfrin 982626c
Solved conflict in client.go
riccardomanfrin faa1962
Fixup helper withMDMPolicy -> configWithMDM
riccardomanfrin e4d4b44
Fixup after merge
riccardomanfrin 12789d1
Merge branch 'main' into mdm_integration
riccardomanfrin c41d439
Resolve merge conflicts
riccardomanfrin c281b15
[client] Move MDM enforcement logic into a shared Go layer (#7319)
pappz ec4b99b
Merge branch 'main' into mdm_integration
pappz 116e1d3
Merge branch 'main' into mdm_integration
riccardomanfrin 5d15ac0
[client] Resolve the main merge conflicts in the MDM integration
riccardomanfrin d96d22a
[client] Reject explicit empty PSK when MDM enforces a pre-shared key
pappz 47238e0
[client] Apply MDM overlay on the preloaded iOS config in Run
pappz 42f0a63
[client] Gate non-active profile logout behind the MDM profiles switch
pappz 3234ce7
[client] Resolve the managed management URL through the MDM overlay o…
pappz 047715a
[client] Clean up MDM review leftovers
pappz c1e2e20
[client] Check remote jobs and local metrics keys in the mobile MDM c…
pappz a52c7ba
[client] Silence the deprecated PreSharedKey lint in the login confli…
pappz 86d6f7d
[client] Publish the mobile MDM loader and detector atomically
pappz a2b1c99
[client] Report the MDM-overlaid remote jobs value from mobile Prefer…
pappz 1b0dd66
[client] Stop persisting the MDM-overlaid config after mobile logins
pappz ca548ea
[client] Document that the MDM overlay on Config is not reversible
pappz cb5efcd
[client] Re-resolve the tvOS preloaded config before every MDM overlay
pappz c019700
[client] Serve the MDM-managed management URL without touching the co…
pappz 204360e
[client] Align the MDM loader docs with the fetcher precedence and ma…
pappz 9364512
[client] Clean up MDM review nits
pappz b65f493
[client] Fix int policy values coercing to bool in the MDM test helper
pappz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //go:build android | ||
|
|
||
| package android | ||
|
|
||
| import ( | ||
| "github.com/netbirdio/netbird/client/internal/profilemanager" | ||
| "github.com/netbirdio/netbird/client/mdm" | ||
| ) | ||
|
|
||
| // SetMDMPolicyFetcher registers the native-provided MDM policy fetcher on | ||
| // this Client; passing nil disables MDM enforcement. | ||
| func (c *Client) SetMDMPolicyFetcher(p PolicyFetcher) { | ||
| c.mdmLoader = loaderFor(p) | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
|
||
| c.mdmDetector = mdm.NewChangeDetector(c.mdmLoader) | ||
| } | ||
|
|
||
| // HasMDMPolicyChanged re-reads the managed configuration and reports whether | ||
| // it changed since the last observation; call it from the native OS-change | ||
| // notification and restart the engine only on true. | ||
| func (c *Client) HasMDMPolicyChanged() bool { | ||
| if c.mdmDetector == nil { | ||
| return false | ||
| } | ||
| return c.mdmDetector.Changed() | ||
| } | ||
|
|
||
| // GetRestrictionsJSON returns the UI enforcement snapshot derived from the | ||
| // active MDM policy, in the JSON shape shared with the desktop frontend. | ||
| func (c *Client) GetRestrictionsJSON() (string, error) { | ||
| return mdm.BuildRestrictions(c.mdmLoader.Load()).JSON() | ||
| } | ||
|
|
||
| func (c *Client) applyMDMOverlay(cfg *profilemanager.Config) { | ||
| if cfg == nil || c.mdmLoader == nil { | ||
| return | ||
| } | ||
| cfg.ApplyMDMPolicy(c.mdmLoader.Load()) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package android | ||
|
|
||
| import ( | ||
| "github.com/netbirdio/netbird/client/mdm" | ||
| ) | ||
|
|
||
| // PolicyFetcher is implemented by the native layer to return the current | ||
| // managed configuration as a JSON-encoded object string; "" means no MDM | ||
| // source is present. | ||
| type PolicyFetcher interface { | ||
| FetchJSON() string | ||
| } | ||
|
|
||
| func loaderFor(p PolicyFetcher) *mdm.Loader { | ||
| if p == nil { | ||
| return mdm.NewJSONLoader(nil) | ||
| } | ||
| return mdm.NewJSONLoader(p.FetchJSON) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.