microsoftgraph / microsoftgraph/msgraph-sdk-powershell
Switch From Using Unmaintained Newtonsoft.Json to Using System.Text.Json in Powershell Authentication Module
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 898
- Forks
- 230
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 31
Description
Describe the bug
The Newtonsoft.Json dependency of the SDK's authentication module, is no longer actively maintained. In the past we have also encountered trust issues with the signed Newtonsoft.Json package throwing verificationError 18 which interprets to
"Your file is signed but we don't trust it"
and PS SDK users, have raised this too as an issue for them. See https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2741 and https://github.com/JamesNK/Newtonsoft.Json/issues/2755
Expected behavior
Avoid Newtonsoft.Json related issues mentioned above by switching to System.Text.Json
How to reproduce
The task will include writing tests to cover the affected code segments and mitigate against any regressions before switching to system.text.json.
The current tricky work is the Json DOM handling in the 3 files below
- https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/dev/src/Authentication/Authentication/Common/GraphSettings.cs
- https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/dev/src/Authentication/Authentication/Common/GraphSettingsConverter.cs
- https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/dev/src/Authentication/Authentication/Helpers/StringUtil.cs
It should be easier to replace JsonConvert.SerializeObject with JsonSerializer.Seralize in other files like https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/f06dcb11f2064bcd73ba3393dc9523c9bd45235f/src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs#L579
Acceptance Criteria
- 100% test coverage on affected files/files originally using Newtonsoft.Json package
- Working authentication module with the tests passing and using System.Text.Json instead of Newtonsoft.Json
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading GraphSettings.cs, GraphSettingsConverter.cs, and StringUtil.cs, then inspect the other authentication files using Newtonsoft.Json, including InvokeMgGraphRequest.cs. Add tests for the affected code and verify the authentication module passes all tests while using System.Text.Json and no longer relying on Newtonsoft.Json.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, json, powershell
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100