Comments (5)
Hi,
I've managed to overcome this issue by creating a new JsonConverter that ignores the ClaimsPrincipal
public class JsonClaimsPrincipalConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return (objectType == typeof(ClaimsPrincipal));
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var objectToSerialize = new { }; //create the object you want to serialize here, based on your dynamic conditions
new JsonSerializer().Serialize(writer, objectToSerialize); //serialize the object to the current writer
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
Not sure if that was supposed to be intendent? Maybe it should not ignore the entire object, but just extract the Claims list and reconstruct the ClaimsPrincipal on Read?
At least I can login using this, not sure if all features of Identity are still available.
from aspnetcore.identity.documentdb.
I tried adding a pull request with some new converters. Unsure if they will fit all scenarios though. #18
from aspnetcore.identity.documentdb.
Hi,
I am having the same error. I created a basic .Net Core 2.0 MVC Web application and added external login functionality to it. Everything works fine with SQL Server but when I am using this package, result = await _userManager.AddLoginAsync
throws exception similar to what it is mentioned above.
Apparently, the user document is being created in the DocumentDB but external logins are not being added because of the error.
Thanks.
from aspnetcore.identity.documentdb.
@rafaykh90 Thanks to the PRs of @joaomatossilva and @projecteon, with the current bits this should work fine now (without any code changes on your side for now, which might change if we can't get the back compat issue discussed in #17 sorted out). I'll try to get a prerelease NuGet package out there soon, in the meantime you could download the latest bits yourself.
from aspnetcore.identity.documentdb.
A cheese workaround for JsonClaimConverter issues.
[JsonProperty(PropertyName = "claims")] [JsonConverter(typeof(JsonClaimConverter))] public IList<Claim> Claims { get; set; }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
IList<Claim> claims = new List<Claim>();
JToken jt = JObject.ReadFrom(reader);
for (int i = 0; i < jt.Count(); i++)
{
string type = jt.Values<string>("Type").FirstOrDefault();
string value = jt.Values<string>("Value").FirstOrDefault();
string valueType = jt.Values<string>("ValueType").FirstOrDefault();
string issuer = jt.Values<string>("Issuer").FirstOrDefault();
string originalIssuer = jt.Values<string>("OriginalIssuer").FirstOrDefault();
claims.Add(new Claim(type, value, valueType, issuer, originalIssuer));
}
return claims;
}
from aspnetcore.identity.documentdb.
Related Issues (20)
- Has anyone got this running in a web api project? HOT 1
- Not able to compile samples in Visual Studio for Mac HOT 1
- remove claim does not work HOT 3
- AspNetCore 2.0 HOT 8
- deserializing claims
- Unable to log back in after creating a user, null as part of the Claims Process
- Take document db collection name as parameter HOT 1
- Claims cannot be deserialized HOT 3
- ObjectDisposedException HOT 1
- Missing method exception after upgrading to SDK 2.1.3
- Question - How are the document updated? HOT 1
- TypeLoadException: Method 'NormalizeName' in type 'LookupNormalizer' does not have an implementation HOT 5
- SSL should be enabled in the sample
- AddDefaultDocumentClientForIdentity is missing from NuGet package HOT 3
- Is it considered to change dependency to Microsoft.Azure.Cosmos?
- Use IDocumentClient instead of DocumentClient HOT 1
- Subclass Userstore to allow using it without any RoleStore
- Adding samples how to use and manage Roles HOT 1
- Getting exception BadRequestException: Cross partition query is required but disabled. Please set x-ms-documentdb-query-enablecrosspartition to true, specify x-ms-documentdb-partitionkey, or revise your query to avoid this exception. HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspnetcore.identity.documentdb.