-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Adds support for custom identity resources and claims * Adds support for custom identity resources and claims. Uses generic version for JsonConverter
- Loading branch information
Showing
2 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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,28 @@ | ||
using System; | ||
using System.Security.Claims; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace OpenIdConnectServer.Utils | ||
{ | ||
public class ClaimJsonConverter : JsonConverter<Claim> | ||
{ | ||
public override void WriteJson(JsonWriter writer, Claim value, JsonSerializer serializer) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
|
||
public override Claim ReadJson(JsonReader reader, Type objectType, Claim existingValue, bool hasExistingValue, | ||
JsonSerializer serializer) | ||
{ | ||
var jObject = JObject.Load(reader); | ||
var type = jObject["Type"].Value<string>(); | ||
var val = jObject["Value"].Value<string>(); | ||
|
||
return new Claim(type, val); | ||
} | ||
|
||
public override bool CanRead => true; | ||
public override bool CanWrite => false; | ||
} | ||
} |