Question about getting/setting Claims in ClaimsPrincipal using extension methods #3876
-
Hi All, According to this link (#2806 (reply in thread)), Rocky recommends creating extension methods for getting/setting claims since we can no longer create our own The quote is "Therefore, as a strategy, you should use ClaimsPrincipal and ClaimsIdentity as they are, and put any custom data you need into Claims. You can then direct access those Claims, or use extension methods to make it a little easier within your code." My issue with that is that while it's fine to store primitive types in Claims, it becomes a problem when you have to store complex types, such as CSLA classes. This would require the use of the So the options i see are as follows:
Or possibly I have a fundamental misunderstanding of how this should work? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
You can't store anything other than primitive types in a I haven't given any thought to more complex types that might be "part of a claim". My first instinct is to suggest that the claim would provide the key necessary to retrieve any more complex object. You'd only retrieve the complex object in the case that an authorization rule is executing to check the claim, and so you'd get the complex object within the rule's execute method. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
There is one mobile app, two asp.net ones, and one WinForms one. I wonder if skipping the Claim implementation and using Rocky’s client side caching support is better. @rockfordlhotka, does that support our multi client implementation? |
Beta Was this translation helpful? Give feedback.
This is a part of the in memory cache I'm using at work. Maybe it helps/gives ideas to implement yours: #3645 (comment)