sagitta-ignis / dreamcore

.Net Core repository of your dreams (soon)
2 stars 0 forks source link

Default UserService based on claims #3

Open arcange opened 4 years ago

arcange commented 4 years ago

While executing http requests, we often need to get some information about current user (authenticated api calls).

I suggest we store user data in claims at authentication time in order to access them from memory. Claims are standards, and many claims keys are already defined in base library (firstname, lastname, email, ...). Maybe there even are TOO many standard keys, so we should find a way to reduce the possibilities to application needs (through some UserHelper or any typed interface)

sagitta-ignis commented 4 years ago

Use of typed interface with declarative annotations for mapping with claims keys sounds neat and readable :

class User {
   [Claim(ClaimTypes.Sid)]
   public string Id { get: set; }

   [Claim(ClaimTypes.Name)]
   public string Name { get: set; }
}