ASP.NET Core Identity impersonate specific user

前端 未结 1 1317
情书的邮戳
情书的邮戳 2021-01-05 20:07

Let\'s say I have the following roles:

  1. Admin

  2. User

I want Admin role to impersonate specific user account with User role,

相关标签:
1条回答
  • 2021-01-05 20:32

    There is a blog post about impersonation in Asp.Net Core HERE. I am just searching for such a solution, so I have not tried implementing it yet. However it seems you are on the right track. There are only slight differences between your code and Max's.

    Basically you need to replace the cookie at the browser side. So, for the next request the server "thinks" its someone else logged in. At least that's what I understood so far. This is why you better save the original identity in the cookie as well, thus you could switch back to the original user when needed.

    I get back when I have a working solutions anyway.

    0 讨论(0)
提交回复
热议问题