I am trying to build a claims aware Application using MembershipReboot library for authentication Thinktecture.IdentityModel.45 for authorization. As far as tutorials go, they are all adding Claims manually to the "UserClaims" Table (not sure which library added that), which contains the UserID, the Type of the Claim and the Value. I would like to add the claims programmatically to this table, but I am not sure how to do this in a obvious way.

有帮助吗?

解决方案

You can add/remove claims via the AddClaim/RemoveClaim API on the UserAccount class. See the SingleTenantWebApp sample for an example:

https://github.com/brockallen/BrockAllen.MembershipReboot/blob/master/samples/SingleTenant/SingleTenantWebApp/Areas/UserAccount/Controllers/HomeController.cs#L28

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top