File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Authentication.Abstractions/src Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ public AuthenticationProperties Clone()
6565 /// Collection of parameters that are passed to the authentication handler. These are not intended for
6666 /// serialization or persistence, only for flowing data between call sites.
6767 /// </summary>
68+ [ JsonIgnore ]
6869 public IDictionary < string , object ? > Parameters { get ; }
6970
7071 /// <summary>
Original file line number Diff line number Diff line change @@ -320,6 +320,12 @@ public void Roundtrip_Serializes_With_SystemTextJson()
320320 props . Parameters . Add ( "baz" , "quux" ) ;
321321
322322 var json = JsonSerializer . Serialize ( props ) ;
323+
324+ // Verify that Parameters was not serialized
325+ Assert . NotNull ( json ) ;
326+ Assert . DoesNotContain ( "baz" , json ) ;
327+ Assert . DoesNotContain ( "quux" , json ) ;
328+
323329 var deserialized = JsonSerializer . Deserialize < AuthenticationProperties > ( json ) ;
324330
325331 Assert . NotNull ( deserialized ) ;
@@ -339,6 +345,20 @@ public void Roundtrip_Serializes_With_SystemTextJson()
339345 Assert . Equal ( 0 , deserialized . Parameters . Count ) ;
340346 }
341347
348+ [ Fact ]
349+ public void Parameters_Is_Not_Deserialized_With_SystemTextJson ( )
350+ {
351+ var json = @"{""Parameters"":{""baz"":""quux""}}" ;
352+
353+ var deserialized = JsonSerializer . Deserialize < AuthenticationProperties > ( json ) ;
354+
355+ Assert . NotNull ( deserialized ) ;
356+
357+ // Ensure that parameters is not deserialized from a raw payload
358+ Assert . NotNull ( deserialized ! . Parameters ) ;
359+ Assert . Equal ( 0 , deserialized . Parameters . Count ) ;
360+ }
361+
342362 public class MyAuthenticationProperties : AuthenticationProperties
343363 {
344364 public new DateTimeOffset ? GetDateTimeOffset ( string key )
You can’t perform that action at this time.
0 commit comments