What is the idea behind IIdentity and IPrincipal in .NET

前端 未结 4 1508
清歌不尽
清歌不尽 2021-01-30 16:23

So, what is the purpose for existence of both IIdentity and IPrincipal, and not some IIdentityMergedWithPrincipal? When is it not enough t

4条回答
  •  梦如初夏
    2021-01-30 17:02

    A principal is the security context of a user.

    In the case of .NET, a principal supports the concept of having more than one identity (This has nothing to do with claims yet). This is particularly important when it comes to semantics that developers need to deal with when it comes to user identity. You may be called on as a developer to support multiple identities coming from different sources (identity providers IdPs), for example: Twitter, Google, whatever.

    So what's the different between a IPrincipal and IIDentity? IPrincipal is the security context (for a single thread), and the IIDentity is the set of attributes associated with that user coming from a specific identity provider / authority.

提交回复
热议问题