Closed thoemmi closed 11 years ago
Wow, thanks! I was planning to implement this really soon but you have beaten me to it :)
However, I don't want to store the roles separately. What I want is to store them as claim value. If you could make that change too, I would be more than happy to check this in. After that and a few more tests, I would like to push the stable v1 to nuget.org :)
I've added one more commit. Is it like what you had in mind?
@thoemmi yes, exactly like that :) merged it and pushed the new version to nuget.org: https://www.nuget.org/packages/AspNet.Identity.RavenDB will add some more tests and sample before releasing the stable v1.
Thanks again for the contribution and feel free to push any more code.
Hi @thoemmi,
I decided the remove the IUserRoleStore support from this library. There are several reasons. A role is also a claim. We managed to do that a little by storing roles as claims but ClaimsIdentityFactory
currently have the following code inside the CreateAsync
method:
if (manager.SupportsUserRole)
{
IList<string> list = await manager.GetRolesAsync(user.Id);
foreach (string current in list)
{
claimsIdentity.AddClaim(new Claim(this.RoleClaimType, current, "http://www.w3.org/2001/XMLSchema#string"));
}
}
if (manager.SupportsUserClaim)
{
claimsIdentity.AddClaims(await manager.GetClaimsAsync(user.Id));
}
So, a role will be represented as a claim on the ClaimsIdentity twice.
So the identity framework demands that you either implement IUserRoleStore
or IUserClaimStore
, but not both? Or should we store roles not as claims but as a separate user property as I coded in my original PR?
@thoemmi yep, if you want to support IUserRoleStore
and IUserClaimStore
, you should store roles separately. Or, replace the default ClaimsIdentityFactory
on UserManager<TUser>
at the application level.
I really don't want to store roles separately.
Unit tests are included